Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 80 additions & 2 deletions .github/actions/gate/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,49 @@ inputs:
description: Where dx coverage writes its lcov report.
required: false
default: ""
baseline:
description: Name for this job's failing labels, such as check-linux_x86_64. A push reads and writes main-baseline-<name>; a pull request writes failing-<name>.
required: false
default: ""
runs:
using: composite
steps:
- name: Find the last main baseline
id: previous
if: ${{ inputs.baseline != '' && github.event_name == 'push' }}
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
NAME: main-baseline-${{ inputs.baseline }}
HEAD_SHA: ${{ github.sha }}
shell: bash
run: |
candidates="$(gh api "repos/$REPO/actions/artifacts?name=$NAME&per_page=100" --jq '[.artifacts[] | select((.expired | not) and .workflow_run.head_branch == "main" and .workflow_run.head_repository_id == .workflow_run.repository_id)] | sort_by(.created_at) | reverse | .[:10][] | "\(.id) \(.workflow_run.id) \(.workflow_run.head_sha)"')"
while read -r id run sha; do
[ -n "$id" ] || continue
status="$(gh api "repos/$REPO/compare/$sha...$HEAD_SHA" --jq .status)"
case "$status" in ahead | identical) ;; *) echo "gate: skip $NAME from run $run, $sha is $status of HEAD"; continue ;; esac
echo "gate: $NAME from run $run at $sha"
{ echo "id=$id"; echo "run=$run"; } >> "$GITHUB_OUTPUT"
if [ "$status" = ahead ]; then
git fetch --no-tags --depth=1 origin "$sha"
echo "sha=$sha" >> "$GITHUB_OUTPUT"
fi
exit 0
done <<<"$candidates"
echo "gate: no $NAME artifact from an ancestor of HEAD yet"
- name: Download the last main baseline
if: ${{ steps.previous.outputs.id != '' }}
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
artifact-ids: ${{ steps.previous.outputs.id }}
run-id: ${{ steps.previous.outputs.run }}
github-token: ${{ github.token }}
path: ${{ runner.temp }}/baseline-previous
- name: Pin the affected base
env:
EVENT_NAME: ${{ github.event_name }}
PUSH_BEFORE: ${{ github.event.before }}
PUSH_BEFORE: ${{ steps.previous.outputs.sha || github.event.before }}
MERGE_GROUP_BASE: ${{ github.event.merge_group.base_sha }}
shell: bash
run: |
Expand All @@ -35,9 +71,12 @@ runs:
tags=-no-coverage,-dx-no-coverage-collector,$tags
fi
report=()
if [ "$COMMAND" = check ]; then
report=(--max-findings 0)
fi
if [ -n "$LCOV" ]; then
mkdir -p "$(dirname "$LCOV")"
report=(--report "lcov=$LCOV")
report+=(--report "lcov=$LCOV")
fi
bazel build "$@" @rules_dx//:dx
built="$(bazel cquery "$@" --output=files @rules_dx//:dx | grep -E '/dx(\.exe)?$')"
Expand All @@ -52,6 +91,45 @@ runs:
# shellcheck disable=SC2086
set -- $BAZEL_CONFIG $BB_ARGS
bazel run --noshow_progress "$@" @rules_dx//tools/ci/producers:producers_bin -- --test-log-tails --dx "${RUNNER_TEMP:-/tmp}/gate.json"
- name: Record the failing labels
id: failing
if: ${{ !cancelled() && inputs.baseline != '' }}
env:
NAME: ${{ github.event_name == 'push' && 'main-baseline' || 'failing' }}-${{ inputs.baseline }}
OUTCOME: ${{ steps.check.outcome }}
shell: bash
run: |
out="$RUNNER_TEMP/failing/$NAME.json"
mkdir -p "${out%/*}"
previous=""
if [ -d "$RUNNER_TEMP/baseline-previous" ]; then
previous="$(find "$RUNNER_TEMP/baseline-previous" -name '*.json' -print -quit)"
fi
if [ "$OUTCOME" = success ] && [ -z "$previous" ]; then
echo '{"labels":[]}' > "$out"
exit 0
fi
args=(--failing-labels --out "$out" --dx "$RUNNER_TEMP/gate.json")
if [ -n "$previous" ]; then
args+=(--previous "$previous")
fi
# shellcheck disable=SC2086
set -- $BAZEL_CONFIG $BB_ARGS
bazel run --noshow_progress "$@" @rules_dx//tools/ci/producers:producers_bin -- "${args[@]}"
- name: Check the failing labels hold no secret
id: scan-failing
if: ${{ !cancelled() && steps.failing.outcome == 'success' }}
uses: ./.github/actions/assert-no-secret
with:
path: ${{ runner.temp }}/failing
- name: Upload the failing labels
if: ${{ !cancelled() && steps.scan-failing.outcome == 'success' && (github.event_name == 'pull_request' || (github.event_name == 'push' && steps.previous.outcome == 'success' && (steps.check.outcome == 'success' || steps.check.outcome == 'failure'))) }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: ${{ github.event_name == 'push' && 'main-baseline' || 'failing' }}-${{ inputs.baseline }}
path: ${{ runner.temp }}/failing
retention-days: ${{ github.event_name == 'push' && 30 || 7 }}
overwrite: true
- name: Verify the base dx compared against
if: ${{ !cancelled() && steps.check.outcome != 'skipped' }}
shell: bash
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- `release-e2e.yml`: on a `v0.0.0-e2e.*` tag push, calls `reusable-release.yml` from this repository with the `//tools/testing/release_e2e` fixtures: `a_github` alone, or `a_github` then `b_refuses` when the tag contains `partial`. `b_refuses` keeps the placeholder tag `v0.0.0-dryrun`, so its dry run passes and its publish fails.
- `reusable-docs.yml`: `docs-check` plus `docs-publish` (GitHub Pages).
- `docs.yml`: on a push to `main` that changes a page in the user book (`docs/`, `tools/docs/`, the root and example READMEs), or by dispatch, runs `reusable-docs.yml` and publishes the book to https://devhusdk.github.io/rules_dx/. Its `docs` job and the `ci.yml` `docs` job share the `docs-pages-<ref>` concurrency group, so two Pages deploys never overlap.
- `ci.yml`: on pull requests and in the merge queue, runs `dx check --affected` and `dx coverage --affected --report lcov=$RUNNER_TEMP/coverage/lcov.info` on `linux_x86_64`, `linux_arm64`, `macos_arm64`, `windows_x86_64` and `windows_arm64`, as the jobs `check (<platform>)` and `coverage (<platform>)`. Both use `.github/actions/gate`, which pins the base with `gate_base`: the pull request base, or the queue base in the merge queue. The gate runs dx from a copy outside `bazel-bin`, because the Bazel runs inside dx can rebuild dx and Windows cannot replace a running exe. `check (linux_x86_64)` also runs `dx generate` on the whole repo. In the merge queue, each `check` job fails when an `evidence/*` status on the pull request head is not green. Each coverage job uploads its `lcov.info` as `coverage-<platform>` for 7 days. Run the same locally with `tools/dx check --affected` and `tools/dx coverage --affected`. Every other job runs only on schedule or dispatch, and the `ci` job then requires all of them. A failed Windows preflight build uploads `rmeta-diagnostics-<platform>`.
- `ci.yml`: on pull requests and in the merge queue, runs `dx check --affected` and `dx coverage --affected --report lcov=$RUNNER_TEMP/coverage/lcov.info` on `linux_x86_64`, `linux_arm64`, `macos_arm64`, `windows_x86_64` and `windows_arm64`, as the jobs `check (<platform>)` and `coverage (<platform>)`. Both use `.github/actions/gate`, which pins the base with `gate_base`: the pull request base, or the queue base in the merge queue. The gate runs dx from a copy outside `bazel-bin`, because the Bazel runs inside dx can rebuild dx and Windows cannot replace a running exe. `check (linux_x86_64)` also runs `dx generate` on the whole repo. In the merge queue, each `check` job fails when an `evidence/*` status on the pull request head is not green. Each coverage job uploads its `lcov.info` as `coverage-<platform>` for 7 days. On a push to `main` the same `check` and `coverage` jobs run with `--keep_going` and upload the target labels that fail as `main-baseline-<job>-<platform>` for 30 days. The baseline keeps a label from the last baseline until a run reaches that target again, and the push compares against the commit of that last baseline. On a pull request each job uploads its failing labels as `failing-<job>-<platform>`. The `baseline-diff` job then fails only on labels that are not in the newest `main-baseline-<job>-<platform>`, and lists them in its job summary. Run the same locally with `tools/dx check --affected` and `tools/dx coverage --affected`. Every other job runs only on schedule or dispatch, and the `ci` job then requires all of them. A failed Windows preflight build uploads `rmeta-diagnostics-<platform>`.
- When the `evidence.yml` test task fails, `producers_bin --test-log-tails` prints the last 80 lines of each failing test's `test.log` in its own `::group::` in the job log, for the first 20 failing tests.
- `ci.yml` jobs `preflight`, `quality-matrix` and `launch-heavy` upload the compact execution log of their test step as `exec-log-<job>-<platform>` for 7 days. To see why spawns missed the cache, download the artifact from two runs and run `bazel run //tools/testing:determinism_check -- diff <first.log> <second.log>`. It prints the 20 slowest remote-cacheable spawns that ran in the second run (`--top N` changes the count), each with the inputs, args and env that differ from the first run, or why it could not hit the cache. Before those lines, up to 5 `origin:` lines follow each differing input back through the spawns that made it, to a changed source file, to a spawn the first run does not have or whose args or env differ, or to a spawn that gave a different output from the same inputs. Last, `not remote cacheable, ran every time:` lists the count and total time of the spawns that cannot be cached, such as test runs, per mnemonic.
- `ci.yml` job `determinism` runs five shards. Each builds a fifth of the top-level packages that hold one target of each `lang.json` entry_points kind, plus `//appimage/...` (shard 0), `//cli/archive/...` (shard 1), `//android/private/packaging/...` (shard 2), `//msix/tests/...` (shard 3) or `//deploy/private/...` (shard 4), twice in fresh output bases with no cache and compares the execution logs against `tools/ci/determinism_allowlist.txt`.
Expand All @@ -29,7 +29,7 @@

## Main health

`ci.yml` runs every job on `workflow_dispatch` and a daily schedule (`17 3 * * *`, UTC) against the default branch head. Pull requests and the merge queue run only the `check` and `coverage` jobs. There are no push triggers. Runs share one concurrency group per ref (`ci-ci-<ref>`): a new push cancels the pull request run, and a new run on main replaces only the queued one. The repository cache prune runs after scheduled or dispatched main runs. A red scheduled run opens or updates one issue titled `ci: scheduled run is failing` (the `scheduled-report` job). The next green scheduled run closes it. After each scheduled or dispatched run on main, the same job rewrites the pinned issue labelled `known-red` with the test labels that failed in that run. GitHub may delay or drop scheduled runs under load.
`ci.yml` runs every job on `workflow_dispatch` and a daily schedule (`17 3 * * *`, UTC) against the default branch head. Pull requests and the merge queue run only the `check` and `coverage` jobs, and pull requests also `baseline-diff`. A push to `main` runs only the `check` and `coverage` jobs. Runs share one concurrency group per ref (`ci-ci-<ref>`, and `ci-ci-push-refs/heads/main` for pushes): a new push cancels the older pull request or push run, and a new scheduled or dispatched run on main replaces only the queued one. The repository cache prune runs after scheduled or dispatched main runs. A red scheduled run opens or updates one issue titled `ci: scheduled run is failing` (the `scheduled-report` job). The next green scheduled run closes it. After each scheduled or dispatched run on main, the same job rewrites the pinned issue labelled `known-red` with the test labels that failed in that run. GitHub may delay or drop scheduled runs under load.

The platform table is `PLATFORMS` in `tools/ci/input_validation/src/lib.rs`; `input_validation_test` pins every other copy to it.

Expand Down
77 changes: 74 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: ci

on:
push:
branches: [main]
pull_request:
merge_group:
types: [checks_requested]
Expand All @@ -18,9 +20,9 @@ env:
MSYS2_ARG_CONV_EXCL: "//"

concurrency:
# One run per ref: a new push cancels the pull request run; a new dispatch or scheduled run on main replaces only the queued one.
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
# A newer push cancels the older run; a scheduled or dispatched run on main only replaces a queued one.
group: ci-${{ github.workflow }}-${{ github.event_name == 'push' && 'push-' || '' }}${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }}

jobs:
check:
Expand All @@ -45,6 +47,7 @@ jobs:
runner: windows-11-arm
runs-on: ${{ matrix.runner }}
permissions:
actions: read
contents: read
statuses: read
steps:
Expand Down Expand Up @@ -78,6 +81,7 @@ jobs:
- uses: ./.github/actions/gate
with:
command: check
baseline: check-${{ matrix.platform }}
- name: Check generated files across the repo
if: ${{ !cancelled() && matrix.platform == 'linux_x86_64' }}
run: |
Expand Down Expand Up @@ -106,6 +110,7 @@ jobs:
runner: windows-11-arm
runs-on: ${{ matrix.runner }}
permissions:
actions: read
contents: read
steps:
- name: Check out files in parallel
Expand All @@ -122,6 +127,7 @@ jobs:
with:
command: coverage
lcov: ${{ runner.temp }}/coverage/lcov.info
baseline: coverage-${{ matrix.platform }}
- name: Check the upload holds no secret
id: scan-coverage
if: ${{ always() }}
Expand All @@ -136,6 +142,71 @@ jobs:
path: ${{ runner.temp }}/coverage
retention-days: 7
if-no-files-found: ignore
baseline-diff:
name: baseline-diff
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
needs: [check, coverage]
timeout-minutes: 10
runs-on: ubuntu-latest
permissions:
actions: read
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: failing-*
merge-multiple: true
path: ${{ runner.temp }}/failing
- name: Compare the failing labels with the last main baseline
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
RUN_ID: ${{ github.run_id }}
SERVER: ${{ github.server_url }}
run: |
set -euo pipefail
pr="$RUNNER_TEMP/failing"
main="$RUNNER_TEMP/main-baseline"
mkdir -p "$pr" "$main"
listed="$(gh api --paginate "repos/$REPO/actions/runs/$RUN_ID/jobs?filter=latest&per_page=100" \
--jq '.jobs[].name | capture("^(?<job>check|coverage) \\((?<platform>[a-z0-9_]+)\\)$")? | "\(.job)-\(.platform)"' | sort -u)"
[ -n "$listed" ] || { echo "baseline-diff: no check or coverage job in run $RUN_ID" >&2; exit 1; }
mapfile -t jobs <<<"$listed"
bad=0
summary="$RUNNER_TEMP/baseline-diff.md"
{
echo "### Failing labels not red on main"
for job in "${jobs[@]}"; do
if [ ! -f "$pr/failing-$job.json" ]; then
echo "- \`$job\`: no failing-label result in this run"
bad=1
continue
fi
found="$(gh api "repos/$REPO/actions/artifacts?name=main-baseline-$job&per_page=100" --jq '[.artifacts[] | select((.expired | not) and .workflow_run.head_branch == "main" and .workflow_run.head_repository_id == .workflow_run.repository_id)] | sort_by(.created_at) | last // empty | "\(.id) \(.workflow_run.id) \(.workflow_run.head_sha)"')"
source="no main baseline yet"
echo '{"labels":[]}' > "$main/$job.json"
if [ -n "$found" ]; then
read -r id run sha <<<"$found"
gh api "repos/$REPO/actions/artifacts/$id/zip" > "$main/$job.zip"
unzip -p "$main/$job.zip" "main-baseline-$job.json" > "$main/$job.json"
source="main baseline ${sha:0:10} from $SERVER/$REPO/actions/runs/$run"
fi
new="$(jq -r --slurpfile main "$main/$job.json" '(.labels - $main[0].labels)[]' "$pr/failing-$job.json")"
known="$(jq -r --slurpfile main "$main/$job.json" '[.labels[] | select(IN($main[0].labels[]))] | length' "$pr/failing-$job.json")"
if [ -z "$new" ]; then
echo "- \`$job\`: no new failing labels, $known already red on main ($source)"
continue
fi
bad=1
echo "- \`$job\`: $(grep -c '' <<<"$new") new, $known already red on main ($source)"
echo
echo '```text'
printf '%s\n' "$new"
echo '```'
done
} > "$summary"
cat "$summary" >> "$GITHUB_STEP_SUMMARY"
cat "$summary"
exit "$bad"
dogfood:
name: dogfood (self-call reusable consumer workflow)
# Dogfoods the reusable file end to end on the working tree.
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ Use these steps when you or an agent start from a fresh Linux checkout, such as

An empty list means the last main run had no failing test. The issue body also links the run and names its commit.

On a pull request, the `baseline-diff` job compares each `check` and `coverage` job's failing labels with the last push to main. It fails only on labels that are not red on main, and its job summary lists them.

Until dx is built, the hooks in `.claude/settings.json` let commands run without building it. They still stop `dx deploy --apply`.

Without user namespaces, Bazel uses `processwrapper-sandbox` instead of `linux-sandbox` on its own. You need no flag.
Expand Down
Loading
Loading