GitLab CI
The pipeline has two jobs. The job assay runs the project judgement with the code quality report, records the metrics, writes the trend and keeps the snapshots. The job assay-merge-request is the pull request job: the gate on the change of a merge request. Both follow the steps of every pipeline (Pipelines).
The pipeline
Section titled “The pipeline”assay: image: dart:3.11 cache: key: assay-snapshots-$CI_COMMIT_REF_SLUG paths: - assay-snapshots/ when: always script: - dart pub get - | ASSAY_VERSION=$(sed -n '/^ assay_lints:$/,/^ [a-z]/s/^ version: "\(.*\)"$/\1/p' pubspec.lock) dart pub global activate assay_cli "$ASSAY_VERSION" export PATH="$PATH:${PUB_CACHE:-$HOME/.pub-cache}/bin" if [ ! -d assay-snapshots ] && curl --fail --silent --show-error --location --output assay-snapshots.zip --header "JOB-TOKEN: $CI_JOB_TOKEN" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/artifacts/$CI_DEFAULT_BRANCH/download?job=assay&search_recent_successful_pipelines=true"; then unzip -q -o assay-snapshots.zip 'assay-snapshots/*' || true; rm assay-snapshots.zip; fi dart test --coverage-path=coverage/lcov.info assay gate --coverage coverage/lcov.info --duplication --snapshot assay-snapshots/ --reporter console --reporter gitlab:gl-code-quality.json || verdict=$? assay metrics --coverage coverage/lcov.info --snapshot assay-snapshots/ assay trend assay-snapshots/ --reporter console --reporter html:build/assay-trend.html exit "${verdict:-0}" artifacts: when: always paths: - assay-snapshots/ - build/assay-trend.html reports: codequality: gl-code-quality.json
assay-merge-request: image: dart:3.11 rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" variables: GIT_DEPTH: 0 # the history of both branches, for the merge-base script: - dart pub get - | ASSAY_VERSION=$(sed -n '/^ assay_lints:$/,/^ [a-z]/s/^ version: "\(.*\)"$/\1/p' pubspec.lock) dart pub global activate assay_cli "$ASSAY_VERSION" export PATH="$PATH:${PUB_CACHE:-$HOME/.pub-cache}/bin" if curl --fail --silent --show-error --location --output assay-snapshots.zip --header "JOB-TOKEN: $CI_JOB_TOKEN" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/artifacts/$CI_DEFAULT_BRANCH/download?job=assay&search_recent_successful_pipelines=true"; then unzip -q -o assay-snapshots.zip 'assay-snapshots/*' || true; rm assay-snapshots.zip; fi dart test --coverage-path=coverage/lcov.info assay gate --scope changed --base "$CI_MERGE_REQUEST_DIFF_BASE_SHA" --coverage coverage/lcov.info --duplication --compare-with assay-snapshots/ --reporter console --reporter markdown:assay-summary.md artifacts: when: always expose_as: assay summary paths: - assay-summary.md- The job
assaykeeps a chain of snapshots for each branch in its cache. A branch with none starts from the default branch’s latest snapshots. - Its script keeps the gate’s exit code and ends with it after the metrics and the trend, so the job fails as the gate did and its records are kept.
- The job
assay-merge-requestcannot read the default branch’s cache (a protected branch’s), so it downloads the snapshots from the artifact of the jobassaythere, with its own token. - GitLab checks out the commit, not the branch, so the records name no branch and the summary block reads
Since 3f1c2ab (2026-11-20). - The limits of the cache and the API: GitLab CI.