diff --git a/.github/workflows/dev-checks.yml b/.github/workflows/dev-checks.yml index d2c6cff8e0..bcea74e8a6 100644 --- a/.github/workflows/dev-checks.yml +++ b/.github/workflows/dev-checks.yml @@ -7,10 +7,14 @@ on: branches: [ "main" ] merge_group: +concurrency: + group: ${{github.workflow}}-${{ github.ref }} + cancel-in-progress: true + jobs: - dev-check: + build: + name: Build Check runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 - name: Use Node.js 20 @@ -20,21 +24,60 @@ jobs: cache: 'npm' - name: Install dependencies run: npm ci - - name: Check for manual changes to API - run: npm run api:generate && [ -z "$(git status --porcelain=v1 2>/dev/null)" ] && echo "✓ No manual API changes." || echo "✗ API manually changed, please refer to the README for the procedure to follow for programmatically generated API endpoints." && [ -z "$(git status --porcelain=v1 2>/dev/null)" ] - - name: Check for circular dependencies - run: npm run circular - name: Run build run: npm run build + + lint-checks: + name: ESLint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + - name: Install dependencies + run: npm ci - name: Run lint check run: npm run lint - - name: Run unit tests - run: npm run test:coverage - - name: Run unit tests with cockpit - run: npm run test:cockpit - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 + + circular-dependencies: + name: Circular Dependencies Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + - name: Install dependencies + run: npm ci + - name: Check for circular dependencies + run: npm run circular + + api-changes: + name: Manual API Changes Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js 20 + uses: actions/setup-node@v4 with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ./coverage/junit.xml - verbose: true + node-version: 20 + cache: 'npm' + - name: Install dependencies + run: npm ci + - name: Check for manual changes to API + run: | + npm run api:generate + if [ -n "$(git status --porcelain)" ]; then + echo + echo "✗ API manually changed, please refer to the README for the procedure to follow for programmatically generated API endpoints." + exit 1 + else + echo + echo "✓ No manual API changes." + exit 0 + fi diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 735d99cf42..7dd7a378fc 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -6,6 +6,12 @@ on: workflow_dispatch: merge_group: +# this prevents multiple jobs from the same pr +# running when new changes are pushed. +concurrency: + group: ${{github.workflow}}-${{ github.ref }} + cancel-in-progress: true + jobs: playwright-tests: runs-on: diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 0000000000..16214e5da6 --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,51 @@ +name: Unit Tests + +on: + pull_request: + branches: [ "main" ] + push: + branches: [ "main" ] + merge_group: + +# this prevents multiple jobs from the same pr +# running when new changes are pushed. +concurrency: + group: ${{github.workflow}}-${{ github.ref }} + cancel-in-progress: true + +jobs: + unit-tests: + name: Service Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + - name: Install dependencies + run: npm ci + - name: Run unit tests + run: npm run test:coverage + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage/junit.xml + verbose: true + + cockpit-unit-tests: + name: Cockpit Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + - name: Install dependencies + run: npm ci + - name: Run unit tests with cockpit + run: npm run test:cockpit