GitHub Actions
The workflow has two jobs. The job gate runs the project judgement on every push to main and on every pull request, and on main it also records the metrics, writes the trend and keeps the snapshots. The job pull-request is the pull request job: the gate on the change. Both follow the steps of every pipeline (Pipelines).
The pipeline
Section titled “The pipeline”name: assayon: push: branches: [main] pull_request:
jobs: gate: runs-on: ubuntu-latest permissions: contents: read actions: read # for the SARIF upload in a private repository security-events: write # for the SARIF upload concurrency: group: assay-gate-${{ github.ref }} # one run of a branch at a time, so that no snapshot is lost steps: - uses: actions/checkout@v7 - uses: dart-lang/setup-dart@v1 with: sdk: "3.11" - name: Resolve the project's dependencies run: dart pub get - name: Install the command-line program at the version of assay_lints run: | ASSAY_VERSION=$(sed -n '/^ assay_lints:$/,/^ [a-z]/s/^ version: "\(.*\)"$/\1/p' pubspec.lock) dart pub global activate assay_cli "$ASSAY_VERSION" echo "${PUB_CACHE:-$HOME/.pub-cache}/bin" >> "$GITHUB_PATH" - name: The snapshots so far if: github.ref == 'refs/heads/main' uses: actions/cache/restore@v6 with: path: assay-snapshots key: assay-snapshots-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: assay-snapshots- - name: The tests, with coverage run: dart test --coverage-path=coverage/lcov.info - name: The gate run: assay gate --coverage coverage/lcov.info --duplication --snapshot assay-snapshots/ --reporter console --reporter github --reporter sarif:build/assay.sarif - name: The metrics if: ${{ !cancelled() && github.ref == 'refs/heads/main' }} run: assay metrics --coverage coverage/lcov.info --snapshot assay-snapshots/ - name: The trend if: ${{ !cancelled() && github.ref == 'refs/heads/main' }} run: assay trend assay-snapshots/ --reporter console --reporter html:build/assay-trend.html - name: Keep the snapshots if: ${{ !cancelled() && github.ref == 'refs/heads/main' }} uses: actions/cache/save@v6 with: path: assay-snapshots key: assay-snapshots-${{ github.run_id }}-${{ github.run_attempt }} - name: Upload the trend if: ${{ !cancelled() && github.ref == 'refs/heads/main' }} uses: actions/upload-artifact@v7 with: name: assay-trend path: build/assay-trend.html - name: Upload the SARIF report if: ${{ !cancelled() }} uses: github/codeql-action/upload-sarif@v4 with: sarif_file: build/assay.sarif category: assay
pull-request: if: github.event_name == 'pull_request' runs-on: ubuntu-latest permissions: contents: read steps: - uses: actions/checkout@v7 with: fetch-depth: 0 # the history of both branches, for the merge-base - uses: dart-lang/setup-dart@v1 with: sdk: "3.11" - name: Resolve the project's dependencies run: dart pub get - name: Install the command-line program at the version of assay_lints run: | ASSAY_VERSION=$(sed -n '/^ assay_lints:$/,/^ [a-z]/s/^ version: "\(.*\)"$/\1/p' pubspec.lock) dart pub global activate assay_cli "$ASSAY_VERSION" echo "${PUB_CACHE:-$HOME/.pub-cache}/bin" >> "$GITHUB_PATH" - name: The snapshots of the default branch uses: actions/cache/restore@v6 with: path: assay-snapshots key: assay-snapshots-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: assay-snapshots- - name: The tests, with coverage run: dart test --coverage-path=coverage/lcov.info - name: The gate on the change run: >- assay gate --scope changed --base "$(git merge-base HEAD "origin/$GITHUB_BASE_REF")" --coverage coverage/lcov.info --duplication --compare-with assay-snapshots/ --reporter console --reporter github --reporter markdown:"$GITHUB_STEP_SUMMARY"- The steps after the gate run when it fails too, so a failed gate is recorded. On a pull request the job
gatewrites a record that no step keeps. - How the cache works and when GitHub removes it: GitHub Actions: the cache.
Adapting the pipeline
Section titled “Adapting the pipeline”- Flutter: set up Flutter instead of Dart, run
flutter pub get, and test withflutter test --coverage, which writes the same file. - No code scanning: drop the SARIF upload.
- A failing test skips the gate. Add
continue-on-error: trueto the test step if the gate should judge anyway.