Skip to content

ci: add CLI tests to CI pipeline #14

ci: add CLI tests to CI pipeline

ci: add CLI tests to CI pipeline #14

Workflow file for this run

name: Test CLI
on:
push:
branches:
- master
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Install npm dependencies
run: npm ci
- name: Build and package project
run: |
npm run build
npm run build-cli
npm pack
- name: Upload project artifacts
uses: actions/upload-artifact@v3
with:
name: built-project
path: codeowners-generator-*.tgz
retention-days: 5
test:
name: Test
needs: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
# - macos-latest
# - ubuntu-latest
- windows-latest
node-version:
- 12
# - 14
# - 16
# - 18
# - 20
# - 21
steps:
- name: Download project artifacts
uses: actions/download-artifact@v3
with:
name: built-project
path: .
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install project
shell: bash
run: npm i -g codeowners-generator-*.tgz
- name: Checkout repository
uses: actions/checkout@v3
- name: Test CLI
shell: bash
run: |
cd .github/test-cli-mock-project
echo "::group::Show CODEOWNERS content"
cat CODEOWNERS
echo ""
echo "::endgroup::"
echo "::group::Get Version"
codeowners-generator --version
echo "::endgroup::"
echo "::group::Move CODEOWNERS file"
mv CODEOWNERS CODEOWNERS-original
echo "::endgroup::"
echo "::group::Generate CODEOWNERS content"
codeowners-generator generate
echo "::endgroup::"
echo "::group::Diff"
diff -y -W 100 CODEOWNERS-original CODEOWNERS || true
echo "::endgroup::"
echo "::group::Check CODEOWNERS content"
# Does it like the file it generated itself?
codeowners-generator generate --check
echo "::endgroup::"