84 lines
3.1 KiB
YAML
84 lines
3.1 KiB
YAML
name: Architecture Lint
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
merge_group:
|
|
types: [checks_requested]
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
# Pull requests can supersede one another safely. Pushes compare each commit
|
|
# with its own before-SHA, so never cancel a push run before that comparison
|
|
# completes. Merge-queue runs are keyed by their own merge-group SHA for the
|
|
# same reason, and are likewise never cancelled: the queue reads a cancelled
|
|
# check as a failure and ejects the pull request.
|
|
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.sha }}
|
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
lint:
|
|
name: Architecture boundaries do not regress
|
|
# Checkout receives the short-lived job token. Keep this credential-bearing
|
|
# path on GitHub-hosted capacity during the external-runner pilot.
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
|
with:
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
|
|
- name: Run linter tests
|
|
run: python3 scripts/lint-architecture.test.py
|
|
|
|
# One step rather than one per event. Each event names the baseline
|
|
# commit differently, and a `merge_group` run has neither of the two the
|
|
# split steps used to read: no `event.pull_request`, no `event.before`.
|
|
# Under the old shape it would have run the linter tests and silently
|
|
# linted nothing, which is the worst possible outcome for a required
|
|
# check — green, and having compared the branch against nothing.
|
|
- name: Resolve the architecture baseline
|
|
id: baseline
|
|
env:
|
|
EVENT_NAME: ${{ github.event_name }}
|
|
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
|
MERGE_GROUP_BASE_SHA: ${{ github.event.merge_group.base_sha }}
|
|
PUSH_BEFORE: ${{ github.event.before }}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
case "${EVENT_NAME}" in
|
|
pull_request) BASE_REF="${PR_BASE_SHA}" ;;
|
|
# The queue branch is cut from this commit, so it is the merge
|
|
# group's equivalent of the pull request's base.
|
|
merge_group) BASE_REF="${MERGE_GROUP_BASE_SHA}" ;;
|
|
push) BASE_REF="${PUSH_BEFORE}" ;;
|
|
# The updater dispatches this workflow against its stable bot
|
|
# branch, so the main branch fork point is the PR baseline.
|
|
workflow_dispatch) BASE_REF="$(git merge-base HEAD origin/main)" ;;
|
|
*) BASE_REF="" ;;
|
|
esac
|
|
|
|
if [[ -z "${BASE_REF}" ]]; then
|
|
echo "No baseline commit for event '${EVENT_NAME}'." >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "base-ref=${BASE_REF}" >> "$GITHUB_OUTPUT"
|
|
echo "Architecture baseline: ${BASE_REF}"
|
|
|
|
- name: Lint architecture
|
|
env:
|
|
ARCHITECTURE_BASE_REF: ${{ steps.baseline.outputs.base-ref }}
|
|
run: >-
|
|
python3 scripts/lint-architecture.py --all
|
|
--baseline-base-ref "$ARCHITECTURE_BASE_REF"
|
|
--allow-missing-base-baseline
|