-
Notifications
You must be signed in to change notification settings - Fork 332
ci: per-commit fast-check gate (catch broken intermediate commits under rebase-merge) #1190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vringar
wants to merge
3
commits into
master
Choose a base branch
from
ci/per-commit-checks
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| name: Per-commit checks | ||
| # Rebase-and-merge lands every PR commit on master individually, but CI only | ||
| # tests the PR tip / merge-queue-candidate tip. This gate runs the FAST static | ||
| # checks on each commit so a broken-in-isolation commit can't ship. It does NOT | ||
| # run the browser suite — runtime regressions stay covered by the `tests` job on | ||
| # the tip + the merge queue. Cheap 80/20 for intermediate commits. | ||
| on: | ||
| pull_request: | ||
| merge_group: | ||
| jobs: | ||
| per-commit: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: { fetch-depth: 0 } | ||
| - uses: ./.github/actions/setup | ||
| - name: Determine commit range | ||
| run: | | ||
| if [ "${{ github.event_name }}" = merge_group ]; then | ||
| echo "BASE=${{ github.event.merge_group.base_sha }}" >> "$GITHUB_ENV" | ||
| echo "HEAD=${{ github.event.merge_group.head_sha }}" >> "$GITHUB_ENV" | ||
| else | ||
| echo "BASE=${{ github.event.pull_request.base.sha }}" >> "$GITHUB_ENV" | ||
| echo "HEAD=${{ github.event.pull_request.head.sha }}" >> "$GITHUB_ENV" | ||
| fi | ||
| - name: Fast checks on each commit | ||
| # GitHub's default run shell is `bash -e`; we deliberately disable | ||
| # errexit (`set +e`) so the loop visits every commit and aggregates all | ||
| # failures into `fail` instead of aborting on the first one. | ||
| run: | | ||
| set +e -uo pipefail | ||
| fail=0 | ||
| # The conda `openwpm` env was built by ./.github/actions/setup from the | ||
| # checked-out tip's environment.yaml. Remember the hash of that file so | ||
| # we only rebuild the env when a commit actually changes the deps. | ||
| LAST_ENV_HASH=$(sha256sum environment.yaml | cut -d' ' -f1) | ||
| for c in $(git rev-list --reverse "$BASE..$HEAD"); do | ||
| echo "::group::$(git log -1 --format='%h %s' "$c")" | ||
| git checkout -q "$c" | ||
| # Conda is the slow setup, so only re-run it when THIS commit's | ||
| # environment.yaml differs from the last one the env was built with. | ||
| # On change, recreate the env (same path the initial setup used) and | ||
| # update the baseline so later unchanged commits stay cheap. | ||
| commit_env_hash=$(sha256sum environment.yaml | cut -d' ' -f1) | ||
| if [ "$commit_env_hash" != "$LAST_ENV_HASH" ]; then | ||
| ./install.sh || { echo "::error::conda env rebuild failed at $c"; fail=1; } | ||
| LAST_ENV_HASH=$commit_env_hash | ||
| fi | ||
| # Static lint/type checks (black/isort/mypy/actionlint/...) on the | ||
| # files this commit changed. mypy catches undefined-name and type | ||
| # errors in the changed files — the load-bearing check. | ||
| pre-commit run --from-ref "${c}~1" --to-ref "$c" || { echo "::error::pre-commit failed at $c"; fail=1; } | ||
| # Only rebuild the extension when this commit touched it (TS compile | ||
| # is the only check that catches broken extension source). | ||
| if ! git diff --quiet "${c}~1" "$c" -- Extension/; then | ||
| # node_modules came from ./.github/actions/setup on the tip; if | ||
| # this commit changed the lockfile/manifest, refresh deps first so | ||
| # the build runs against the right dependency set. `npm ci` is | ||
| # lockfile-driven and fast, so it keeps the gate cheap. | ||
| if ! git diff --quiet "${c}~1" "$c" -- Extension/package.json Extension/package-lock.json; then | ||
| (cd Extension && npm ci) || { echo "::error::npm ci failed at $c"; fail=1; } | ||
| fi | ||
| (cd Extension && npm run build) || { echo "::error::extension build failed at $c"; fail=1; } | ||
| fi | ||
| # Import the package and collect the test suite: catches syntax | ||
| # errors / undefined names / bad imports that mypy's per-file, | ||
| # changed-files-only view can miss (e.g. a deleted symbol still | ||
| # referenced by an unchanged module). | ||
| python -c "import openwpm" || { echo "::error::import openwpm failed at $c"; fail=1; } | ||
| python -m pytest --collect-only -q >/dev/null || { echo "::error::pytest collection failed at $c"; fail=1; } | ||
| echo "::endgroup::" | ||
| done | ||
| git checkout -q "$HEAD" | ||
| exit "$fail" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.