Skip to content

chore(ci): skip expensive jobs on non-source changes #1190

chore(ci): skip expensive jobs on non-source changes

chore(ci): skip expensive jobs on non-source changes #1190

Workflow file for this run

name: CI Checks
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
changes:
name: Detect changed paths
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
src: ${{ steps.filter.outputs.src }}
steps:
- uses: actions/checkout@v4
- id: filter
uses: dorny/paths-filter@v3
with:
filters: |
src:
- 'src/**'
- 'test/**'
- 'package.json'
- 'package-lock.json'
- 'tsconfig*.json'
- 'biome.json'
- '.knip.json'
- 'Dockerfile*'
- 'docker-compose*.yml'
- '.nvmrc'
- '.github/workflows/checks.yml'
commit-lint:
name: Lint commits
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
- name: Install package dependencies
run: npm ci
- name: Run commitlint
uses: wagoid/commitlint-github-action@v5
lint:
name: Lint code
runs-on: ubuntu-latest
needs: changes
if: needs.changes.outputs.src == 'true'
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
- name: Install package dependencies
run: npm ci
- name: Run Biome
run: npm run lint
- name: Run Knip
run: npm run knip
build-check:
name: Build check
runs-on: ubuntu-latest
needs: changes
if: needs.changes.outputs.src == 'true'
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
- name: Install package dependencies
run: npm ci
- name: Run build check
run: npm run build:check
test-units-and-cover:
name: Unit Tests And Coverage
runs-on: ubuntu-latest
needs:
- changes
- lint
- build-check
if: |
always() &&
needs.changes.outputs.src == 'true' &&
needs.lint.result != 'failure' &&
needs.build-check.result != 'failure'
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
- name: Install package dependencies
run: npm ci
- name: Run unit tests
run: npm run test:unit
- name: Run coverage for unit tests
run: npm run cover:unit
if: ${{ always() }}
- uses: actions/upload-artifact@v4
name: Upload coverage report for unit tests
if: ${{ always() }}
with:
name: unit-coverage-lcov
path: .coverage/unit/lcov.info
- name: Coveralls
uses: coverallsapp/github-action@master
if: ${{ always() }}
with:
path-to-lcov: ./.coverage/unit/lcov.info
flag-name: Unit
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel: true
test-integrations-and-cover:
name: Integration Tests and Coverage
runs-on: ubuntu-latest
needs:
- changes
- lint
- build-check
if: |
always() &&
needs.changes.outputs.src == 'true' &&
needs.lint.result != 'failure' &&
needs.build-check.result != 'failure'
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- name: Run integration tests
run: npm run docker:test:integration
- name: Generate Cucumber report annotations
uses: deblockt/cucumber-report-annotations-action@v1.7
if: ${{ always() }}
continue-on-error: true
with:
access-token: ${{ secrets.GITHUB_TOKEN }}
path: .test-reports/integration/report.json
- name: Run coverage for integration tests
run: npm run docker:cover:integration
- name: Coveralls
uses: coverallsapp/github-action@master
if: ${{ always() }}
with:
path-to-lcov: .coverage/integration/lcov.info
flag-name: Integration
parallel: true
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v4
name: Upload coverage report for integration tests
if: ${{ always() }}
with:
name: integration-coverage-lcov
path: .coverage/integration/lcov.info
post-tests:
name: Post Tests
runs-on: ubuntu-latest
needs:
- changes
- test-units-and-cover
- test-integrations-and-cover
if: ${{ always() }}
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
if: |
needs.test-units-and-cover.result != 'skipped' ||
needs.test-integrations-and-cover.result != 'skipped'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
changeset-check:
name: Changeset Required
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.head_ref != 'changeset-release/main'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
- name: Install package dependencies
run: npm ci
- name: Check for changeset
run: npx changeset status --since origin/${{ github.base_ref }}