Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

ci: stop running the PR checks on every push (#9892)

teo7d01b1d48be8
diff --git a/.agents/skills/run-ci/SKILL.md b/.agents/skills/run-ci/SKILL.md
index 7a307859fa..560b919277 100644
--- a/.agents/skills/run-ci/SKILL.md
+++ b/.agents/skills/run-ci/SKILL.md
@@ -23,9 +23,8 @@ instead of local checks: every run costs CI compute.
CI runs when someone asks for it, not on every push. Adding the `run-ci` label
to a PR runs every check on its head commit (the `PR CI` workflow), and the
label disappears as the run starts. The result is the `CI gate` commit status on
-that commit. The merge gate is `CI gate` passing on the PR's latest commit, so
-every push needs a new run before the PR can merge (see the end of this page
-for the switch-over).
+that commit. `main` requires `CI gate` to pass on the PR's latest commit, so
+every push needs a new run before the PR can merge.
## Run it
@@ -86,9 +85,3 @@ A fork run uses the fork's workflow files, so a fork that changes `.github/` or
`tooling/xtask/crates/xtask_workflows` gets `CI gate` failure (`fork changes CI
workflows`). To test it, a maintainer reviews it, pushes it to a branch here,
and runs CI on a PR from that branch.
-
-## While the switch is in progress
-
-The checks still run on every push as well, and `main` still requires their
-old status checks (`Web App Status Check`, `Cloud Storage Status Check`,
-`Infra Status Check`) until its ruleset requires `CI gate`.
diff --git a/.github/workflows/android-play-release.yml b/.github/workflows/android-play-release.yml
index 0a143096ca..89d7393b09 100644
--- a/.github/workflows/android-play-release.yml
+++ b/.github/workflows/android-play-release.yml
@@ -210,8 +210,25 @@ jobs:
ours='^((Web App / )?(Android Native Check|Web App Status Check|iOS Native Check)|Android Play Release|Re-run the native check|Android Release Drift|android-play/|CI gate$)'
deadline=$(( $(date +%s) + WAIT_MINUTES * 60 ))
while true; do
- checks=$(gh pr checks "$PR_NUMBER" --repo "$GH_REPO" --json name,bucket \
- | jq -c --arg ours "$ours" '[.[] | select(.name | test($ours) | not)]')
+ all_checks=$(gh pr checks "$PR_NUMBER" --repo "$GH_REPO" --json name,bucket,description)
+ # The checks only exist once someone has run PR CI on this head; its CI gate
+ # fails with the native check, so only the gate's description is read here.
+ gate=$(jq -r '[.[] | select(.name == "CI gate") | .description][0] // ""' <<<"$all_checks")
+ case "$gate" in
+ "" | "Not run on this commit."*)
+ echo "CI has not run on ${head_sha:0:10}. Run it (gh api repos/${GH_REPO}/issues/${PR_NUMBER}/labels -f "labels[]=run-ci"), then re-add android-update once it passes." >&2
+ exit 1
+ ;;
+ "Running on"* | "Passed on"* | "Failed:"*) ;;
+ *)
+ echo "CI could not run on ${head_sha:0:10}: ${gate}. Re-add android-update once it passes." >&2
+ exit 1
+ ;;
+ esac
+ checks=$(jq -c --arg ours "$ours" '[.[] | select(.name | test($ours) | not)]' <<<"$all_checks")
+ if [[ "$gate" == "Running on"* ]]; then
+ checks=$(jq -c '. + [{name: "CI gate", bucket: "pending"}]' <<<"$checks")
+ fi
failing=$(jq -r '[.[] | select(.bucket == "fail" or .bucket == "cancel") | .name] | join(", ")' <<<"$checks")
pending=$(jq -r '[.[] | select(.bucket == "pending") | .name] | join(", ")' <<<"$checks")
if [[ -n "$failing" ]]; then
diff --git a/.github/workflows/android-release-watch.yml b/.github/workflows/android-release-watch.yml
index a503ba9a52..25c6def0f9 100644
--- a/.github/workflows/android-release-watch.yml
+++ b/.github/workflows/android-release-watch.yml
@@ -71,6 +71,20 @@ jobs:
fetch -q --depth=1 origin "$1"
}
# ------------------------------------------------------------------------------
+ # The latest `PR CI` run that ran for commit $1, as {databaseId, status, url},
+ # or nothing. Every label starts a `PR CI` run, and runs for labels other than
+ # run-ci skip every job, so only a run whose Start job ran counts.
+ pr_ci_run() {
+ local id
+ for id in $(gh api "repos/${GH_REPO}/actions/workflows/pr-ci.yml/runs?head_sha=$1&event=pull_request&per_page=30" \
+ --jq '.workflow_runs[].id'); do
+ if [[ -n "$(gh api "repos/${GH_REPO}/actions/runs/${id}/jobs" \
+ --jq '.jobs[] | select(.name == "Start" and .conclusion != "skipped") | .id')" ]]; then
+ gh api "repos/${GH_REPO}/actions/runs/${id}" --jq '{databaseId: .id, status, url: .html_url}'
+ return 0
+ fi
+ done
+ }
# --- Android Play commit statuses ---------------------------------------------
# Only workflows that run main's copy may sign in to Google Play, so they
# record what they learn as commit statuses on the PR's commits, where the
@@ -132,9 +146,9 @@ jobs:
# (`merge` is GitHub's test merge commit; the gate hashes the same). When it
# is, mark the PR head `android-play/live` (the gate cannot ask Play, so it
# reads that status), and if the PR's latest `Android Native Check` job (of
- # the web app PR checks run) failed — it fails until the release is live —
- # re-run that job so the gate, and the `Web App Status Check` that depends on
- # it, go green without anyone clicking "Re-run". GH_TOKEN needs actions:write,
+ # the PR CI run) failed — it fails until the release is live — re-run the
+ # run's failed jobs so the gate, and the `CI gate` status that depends on it,
+ # go green without anyone clicking "Re-run". GH_TOKEN needs actions:write,
# pull-requests:write and statuses:write; GOOGLE_PLAY_ACCESS_TOKEN the
# androidpublisher scope.
cd apps/web
@@ -169,21 +183,20 @@ jobs:
echo " marked ${sha:0:10} android-play/live"
fi
- run=$(gh run list --workflow web-app-check-main.yml --commit "$sha" \
- --json databaseId,status,url --limit 1 --jq '.[0] // empty')
+ run=$(pr_ci_run "$sha")
if [[ -z "$run" ]]; then
- echo " no Web App Pr Checks run for this commit; skipping"
+ echo " no PR CI run for this commit; skipping"
return 0
fi
run_id=$(jq -r '.databaseId' <<<"$run")
status=$(jq -r '.status' <<<"$run")
run_url=$(jq -r '.url' <<<"$run")
if [[ "$status" != "completed" ]]; then
- echo " Web App Pr Checks run ${run_id} is ${status}; skipping"
+ echo " PR CI run ${run_id} is ${status}; skipping"
return 0
fi
job=$(gh run view "$run_id" --json jobs \
- --jq '.jobs[] | select(.name == "Android Native Check") | {id: .databaseId, conclusion}')
+ --jq '.jobs[] | select(.name == "Web App / Android Native Check") | {id: .databaseId, conclusion}')
if [[ -z "$job" ]]; then
echo " run ${run_id} has no Android Native Check job; skipping"
return 0
@@ -206,8 +219,10 @@ jobs:
echo " Android Native Check already re-run ${reruns} times and still failing; not re-running again — see ${run_url}"
return 0
fi
+ # Re-run the failed jobs, not just this one: the CI gate job that sets the
+ # required status depends on it from outside the called web workflow.
echo " re-running Android Native Check (job ${job_id} of run ${run_id}; ${reruns} automatic re-runs so far)"
- gh run rerun --job "$job_id"
+ gh run rerun "$run_id" --failed
gh pr comment "$number" --body "🤖 Android version code ${version_code} is live on Google Play. Re-ran the **Android Native Check** ([run](${run_url})); this PR can merge once it passes."
}
diff --git a/.github/workflows/cargo_deny.yml b/.github/workflows/cargo_deny.yml
index 557468073c..9a62322315 100644
--- a/.github/workflows/cargo_deny.yml
+++ b/.github/workflows/cargo_deny.yml
@@ -2,22 +2,6 @@
# Source: tooling/xtask/crates/xtask_workflows/src/workflows/cargo_deny.rs
name: cargo deny check
'on':
- pull_request:
- types:
- - opened
- - synchronize
- - reopened
- - ready_for_review
- branches:
- - main
- paths:
- - Cargo.toml
- - crates/**/Cargo.toml
- - services/**/Cargo.toml
- - tooling/xtask/**/Cargo.toml
- - Cargo.lock
- - deny.toml
- - '.github/workflows/cargo_deny.yml'
workflow_call: {}
jobs:
cargo-deny:
@@ -29,6 +13,3 @@ jobs:
uses: EmbarkStudios/cargo-deny-action@bb137d7af7e4fb67e5f82a49c4fce4fad40782fe
with:
manifest-path: Cargo.toml
-concurrency:
- group: cargo-deny-${{ github.event.action == 'labeled' && github.run_id || github.ref }}
- cancel-in-progress: true
diff --git a/.github/workflows/cargo_workspace_dependency_check.yml b/.github/workflows/cargo_workspace_dependency_check.yml
index c5cb771eda..63c76eb213 100644
--- a/.github/workflows/cargo_workspace_dependency_check.yml
+++ b/.github/workflows/cargo_workspace_dependency_check.yml
@@ -2,26 +2,6 @@
# Source: tooling/xtask/crates/xtask_workflows/src/workflows/cargo_workspace_dependency_check.rs
name: cargo workspace dependency check
'on':
- pull_request:
- types:
- - opened
- - synchronize
- - reopened
- - ready_for_review
- branches:
- - main
- paths:
- - Cargo.toml
- - crates/**/Cargo.toml
- - services/**/Cargo.toml
- - tooling/xtask/**/Cargo.toml
- - Cargo.lock
- - '.config/hakari.toml'
- - crates/workspace-hack/**
- - tooling/xtask/src/**
- - tooling/xtask/crates/xtask_deps/**
- - tooling/xtask/crates/xtask_graph/**
- - '.github/workspace-dep-closures.json'
workflow_call: {}
jobs:
dependency-check:
@@ -147,6 +127,3 @@ jobs:
- name: Teardown Nix
if: always()
uses: './.github/actions/teardown-nix'
-concurrency:
- group: cargo-workspace-dependency-check-${{ github.event.action == 'labeled' && github.run_id || github.ref }}
- cancel-in-progress: true
diff --git a/.github/workflows/check_generated.yml b/.github/workflows/check_generated.yml
index d28ebbec19..4a3007d63a 100644
--- a/.github/workflows/check_generated.yml
+++ b/.github/workflows/check_generated.yml
@@ -2,14 +2,6 @@
# Source: tooling/xtask/crates/xtask_workflows/src/workflows/check_generated.rs
name: check generated workflows
'on':
- pull_request:
- branches:
- - main
- paths:
- - tooling/xtask/**
- - crates/macro_event_topics/**
- - '.github/workflows/**'
- - '.github/kafka-cluster-topics.json'
workflow_call: {}
jobs:
check-workflows:
diff --git a/.github/workflows/check_node_modules_nix.yml b/.github/workflows/check_node_modules_nix.yml
index a4ab812365..0b0219264a 100644
--- a/.github/workflows/check_node_modules_nix.yml
+++ b/.github/workflows/check_node_modules_nix.yml
@@ -2,24 +2,6 @@
# Source: tooling/xtask/crates/xtask_workflows/src/workflows/check_node_modules_nix.rs
name: check node_modules nix
'on':
- pull_request:
- branches:
- - main
- paths:
- - bun.lock
- - packages/sdk/bun.lock
- - package.json
- - apps/**/package.json
- - packages/**/package.json
- - services/**/package.json
- - apps/web/patches/**
- - nix-support/node_modules.nix
- - nix-support/node_modules-hashes.json
- - nix/tauri-desktop.nix
- - tooling/scripts/update-node-modules-hash.sh
- - flake.nix
- - flake.lock
- - '.github/workflows/check_node_modules_nix.yml'
workflow_call: {}
permissions:
contents: read
diff --git a/.github/workflows/check_tauri_lockfiles.yml b/.github/workflows/check_tauri_lockfiles.yml
index 44bc835b95..65ffa608ed 100644
--- a/.github/workflows/check_tauri_lockfiles.yml
+++ b/.github/workflows/check_tauri_lockfiles.yml
@@ -2,17 +2,6 @@
# Source: tooling/xtask/crates/xtask_workflows/src/workflows/check_tauri_lockfiles.rs
name: check tauri lockfiles
'on':
- pull_request:
- branches:
- - main
- paths:
- - apps/web/tauri/**
- - crates/**/Cargo.toml
- - Cargo.toml
- - nix/tauri-desktop.nix
- - flake.nix
- - flake.lock
- - '.github/workflows/check_tauri_lockfiles.yml'
workflow_call: {}
permissions:
contents: read
diff --git a/.github/workflows/code_check_cloud_storage.yml b/.github/workflows/code_check_cloud_storage.yml
index e79fab801a..fe2f9c40d5 100644
--- a/.github/workflows/code_check_cloud_storage.yml
+++ b/.github/workflows/code_check_cloud_storage.yml
@@ -9,14 +9,6 @@ env:
RUST_BACKTRACE: '1'
RUSTFLAGS: '-C link-arg=-fuse-ld=lld'
'on':
- pull_request:
- types:
- - opened
- - synchronize
- - reopened
- - ready_for_review
- branches:
- - main
workflow_call: {}
jobs:
path-check:
@@ -323,7 +315,7 @@ jobs:
check:
needs:
- path-check
- if: needs.path-check.outputs.should_run == 'true' && (github.event.pull_request.draft == false || github.event.action == 'labeled')
+ if: needs.path-check.outputs.should_run == 'true'
runs-on: namespace-profile-linux-large-build;overrides.cache-tag=sccache-ci
env:
RUSTFLAGS: '-Dwarnings -Dclippy::disallowed_methods -C link-arg=-fuse-ld=mold'
@@ -523,7 +515,7 @@ jobs:
doppler-config:
needs:
- path-check
- if: needs.path-check.outputs.should_run == 'true' && (github.event.pull_request.draft == false || github.event.action == 'labeled') && needs.path-check.outputs.doppler_candidates == 'true'
+ if: needs.path-check.outputs.should_run == 'true' && needs.path-check.outputs.doppler_candidates == 'true'
runs-on: namespace-profile-linux-rust-ci;overrides.cache-tag=sccache-ci
env:
RUSTFLAGS: '-Dwarnings -Dclippy::disallowed_methods -C link-arg=-fuse-ld=mold'
@@ -754,7 +746,7 @@ jobs:
test:
needs:
- path-check
- if: needs.path-check.outputs.should_run == 'true' && (github.event.pull_request.draft == false || github.event.action == 'labeled') && needs.path-check.outputs.rust_packages != 'none' && needs.path-check.outputs.skip_tests != 'true'
+ if: needs.path-check.outputs.should_run == 'true' && needs.path-check.outputs.rust_packages != 'none' && needs.path-check.outputs.skip_tests != 'true'
runs-on: namespace-profile-linux-large-build;overrides.cache-tag=sccache-ci
env:
RUST_PACKAGES: ${{ needs.path-check.outputs.rust_packages }}
@@ -1053,7 +1045,7 @@ jobs:
build-service-bins:
needs:
- path-check
- if: needs.path-check.outputs.should_run == 'true' && (github.event.pull_request.draft == false || github.event.action == 'labeled') && needs.path-check.outputs.skip_tests != 'true' && (needs.path-check.outputs.rust_packages == 'all' || contains(needs.path-check.outputs.rust_packages, 'document_storage_service') || contains(needs.path-check.outputs.rust_packages, 'email_service') || contains(needs.path-check.outputs.rust_packages, 'authentication_service'))
+ if: needs.path-check.outputs.should_run == 'true' && needs.path-check.outputs.skip_tests != 'true' && (needs.path-check.outputs.rust_packages == 'all' || contains(needs.path-check.outputs.rust_packages, 'document_storage_service') || contains(needs.path-check.outputs.rust_packages, 'email_service') || contains(needs.path-check.outputs.rust_packages, 'authentication_service'))
runs-on: namespace-profile-linux-large-build;overrides.cache-tag=sccache-ci
env:
RUST_PACKAGES: ${{ needs.path-check.outputs.rust_packages }}
@@ -1227,7 +1219,7 @@ jobs:
graphql-schema-compat:
needs:
- path-check
- if: needs.path-check.outputs.should_run == 'true' && (github.event.pull_request.draft == false || github.event.action == 'labeled') && needs.path-check.outputs.graphql_schema == 'true'
+ if: needs.path-check.outputs.should_run == 'true' && needs.path-check.outputs.graphql_schema == 'true'
runs-on: namespace-profile-linux-small
timeout-minutes: 15
steps:
@@ -1282,6 +1274,3 @@ jobs:
done
echo "✅ All jobs passed or were skipped"
-concurrency:
- group: code-check-cloud-storage-${{ github.event.action == 'labeled' && github.run_id || github.ref }}
- cancel-in-progress: true
diff --git a/.github/workflows/code_check_conventions.yml b/.github/workflows/code_check_conventions.yml
index d8290548de..9bb75cc49a 100644
--- a/.github/workflows/code_check_conventions.yml
+++ b/.github/workflows/code_check_conventions.yml
@@ -2,14 +2,6 @@
# Source: tooling/xtask/crates/xtask_workflows/src/workflows/code_check_conventions.rs
name: conventions code check
'on':
- pull_request:
- types:
- - opened
- - synchronize
- - reopened
- - ready_for_review
- branches:
- - main
workflow_call: {}
permissions:
contents: read
@@ -42,7 +34,7 @@ jobs:
ast-grep:
needs:
- path-check
- if: needs.path-check.outputs.should_run == 'true' && (github.event.pull_request.draft == false || github.event.action == 'labeled')
+ if: needs.path-check.outputs.should_run == 'true'
name: ast-grep Conventions
runs-on: namespace-profile-linux-small;overrides.cache-tag=web-ci
steps:
@@ -89,6 +81,3 @@ jobs:
fi
echo "✅ All jobs passed or were skipped"
-concurrency:
- group: code-check-conventions-${{ github.event.action == 'labeled' && github.run_id || github.ref }}
- cancel-in-progress: true
diff --git a/.github/workflows/code_check_infra.yml b/.github/workflows/code_check_infra.yml
index a9e64f4373..3159766f5b 100644
--- a/.github/workflows/code_check_infra.yml
+++ b/.github/workflows/code_check_infra.yml
@@ -2,14 +2,6 @@
# Source: tooling/xtask/crates/xtask_workflows/src/workflows/code_check_infra.rs
name: infra code check
'on':
- pull_request:
- types:
- - opened
- - synchronize
- - reopened
- - ready_for_review
- branches:
- - main
workflow_call: {}
jobs:
path-check:
@@ -34,7 +26,7 @@ jobs:
biome-check:
needs:
- path-check
- if: needs.path-check.outputs.should_run == 'true' && (github.event.pull_request.draft == false || github.event.action == 'labeled')
+ if: needs.path-check.outputs.should_run == 'true'
name: Biome Check
runs-on: namespace-profile-linux-small;overrides.cache-tag=web-ci
steps:
@@ -60,7 +52,7 @@ jobs:
check:
needs:
- path-check
- if: needs.path-check.outputs.should_run == 'true' && (github.event.pull_request.draft == false || github.event.action == 'labeled')
+ if: needs.path-check.outputs.should_run == 'true'
runs-on: namespace-profile-linux-small;overrides.cache-tag=web-ci
steps:
- name: Checkout Repo
@@ -108,6 +100,3 @@ jobs:
fi
echo "✅ All jobs passed or were skipped"
-concurrency:
- group: code-check-infra-${{ github.event.action == 'labeled' && github.run_id || github.ref }}
- cancel-in-progress: true
diff --git a/.github/workflows/ios-app-store-release.yml b/.github/workflows/ios-app-store-release.yml
index c435e0c0f9..a1b66c5518 100644
--- a/.github/workflows/ios-app-store-release.yml
+++ b/.github/workflows/ios-app-store-release.yml
@@ -259,8 +259,25 @@ jobs:
ours='^((Web App / )?(iOS Native Check|Web App Status Check|Android Native Check)|Re-run the native check|iOS App Store Release|iOS Release Drift|CI gate$)'
deadline=$(( $(date +%s) + WAIT_MINUTES * 60 ))
while true; do
- checks=$(gh pr checks "$PR_NUMBER" --repo "$GH_REPO" --json name,bucket \
- | jq -c --arg ours "$ours" '[.[] | select(.name | test($ours) | not)]')
+ all_checks=$(gh pr checks "$PR_NUMBER" --repo "$GH_REPO" --json name,bucket,description)
+ # The checks only exist once someone has run PR CI on this head; its CI gate
+ # fails with the native check, so only the gate's description is read here.
+ gate=$(jq -r '[.[] | select(.name == "CI gate") | .description][0] // ""' <<<"$all_checks")
+ case "$gate" in
+ "" | "Not run on this commit."*)
+ echo "CI has not run on ${head_sha:0:10}. Run it (gh api repos/${GH_REPO}/issues/${PR_NUMBER}/labels -f "labels[]=run-ci"), then re-add ios-update once it passes." >&2
+ exit 1
+ ;;
+ "Running on"* | "Passed on"* | "Failed:"*) ;;
+ *)
+ echo "CI could not run on ${head_sha:0:10}: ${gate}. Re-add ios-update once it passes." >&2
+ exit 1
+ ;;
+ esac
+ checks=$(jq -c --arg ours "$ours" '[.[] | select(.name | test($ours) | not)]' <<<"$all_checks")
+ if [[ "$gate" == "Running on"* ]]; then
+ checks=$(jq -c '. + [{name: "CI gate", bucket: "pending"}]' <<<"$checks")
+ fi
failing=$(jq -r '[.[] | select(.bucket == "fail" or .bucket == "cancel") | .name] | join(", ")' <<<"$checks")
pending=$(jq -r '[.[] | select(.bucket == "pending") | .name] | join(", ")' <<<"$checks")
if [[ -n "$failing" ]]; then
diff --git a/.github/workflows/ios-release-watch.yml b/.github/workflows/ios-release-watch.yml
index 4f9df73d3d..c088416480 100644
--- a/.github/workflows/ios-release-watch.yml
+++ b/.github/workflows/ios-release-watch.yml
@@ -176,6 +176,20 @@ jobs:
fetch -q --depth=1 origin "$1"
}
# ----------------------------------------------------------------------------
+ # The latest `PR CI` run that ran for commit $1, as {databaseId, status, url},
+ # or nothing. Every label starts a `PR CI` run, and runs for labels other than
+ # run-ci skip every job, so only a run whose Start job ran counts.
+ pr_ci_run() {
+ local id
+ for id in $(gh api "repos/${GH_REPO}/actions/workflows/pr-ci.yml/runs?head_sha=$1&event=pull_request&per_page=30" \
+ --jq '.workflow_runs[].id'); do
+ if [[ -n "$(gh api "repos/${GH_REPO}/actions/runs/${id}/jobs" \
+ --jq '.jobs[] | select(.name == "Start" and .conclusion != "skipped") | .id')" ]]; then
+ gh api "repos/${GH_REPO}/actions/runs/${id}" --jq '{databaseId: .id, status, url: .html_url}'
+ return 0
+ fi
+ done
+ }
set -euo pipefail
# For each open PR labeled `ios-update` (PRS: [{number, sha, merge}]):
#
@@ -188,10 +202,9 @@ jobs:
# committed at the PR head (held for release, or live), built from the
# native tree the PR's merge result would have (`merge` is GitHub's test
# merge commit; the gate hashes the same). When it did, and the PR's latest
- # `iOS Native Check` job (of the web app PR checks run) failed — it fails
- # until Apple approves — re-run that
- # job so the gate, and the `Web App Status Check` that depends on it, go
- # green without anyone clicking "Re-run".
+ # `iOS Native Check` job (of the PR CI run) failed — it fails until Apple
+ # approves — re-run the run's failed jobs so the gate, and the `CI gate`
+ # status that depends on it, go green without anyone clicking "Re-run".
#
# GH_TOKEN needs actions:write + pull-requests:write.
cd apps/web
@@ -249,21 +262,20 @@ jobs:
fi
echo " approved by Apple"
- run=$(gh run list --workflow web-app-check-main.yml --commit "$sha" \
- --json databaseId,status,url --limit 1 --jq '.[0] // empty')
+ run=$(pr_ci_run "$sha")
if [[ -z "$run" ]]; then
- echo " no Web App Pr Checks run for this commit; skipping"
+ echo " no PR CI run for this commit; skipping"
return 0
fi
run_id=$(jq -r '.databaseId' <<<"$run")
status=$(jq -r '.status' <<<"$run")
run_url=$(jq -r '.url' <<<"$run")
if [[ "$status" != "completed" ]]; then
- echo " Web App Pr Checks run ${run_id} is ${status}; skipping"
+ echo " PR CI run ${run_id} is ${status}; skipping"
return 0
fi
job=$(gh run view "$run_id" --json jobs \
- --jq '.jobs[] | select(.name == "iOS Native Check") | {id: .databaseId, conclusion}')
+ --jq '.jobs[] | select(.name == "Web App / iOS Native Check") | {id: .databaseId, conclusion}')
if [[ -z "$job" ]]; then
echo " run ${run_id} has no iOS Native Check job; skipping"
return 0
@@ -288,8 +300,10 @@ jobs:
echo " iOS Native Check already re-run ${reruns} times and still failing; not re-running again — see ${run_url}"
return 0
fi
+ # Re-run the failed jobs, not just this one: the CI gate job that sets the
+ # required status depends on it from outside the called web workflow.
echo " re-running iOS Native Check (job ${job_id} of run ${run_id}; ${reruns} automatic re-runs so far)"
- gh run rerun --job "$job_id"
+ gh run rerun "$run_id" --failed
gh pr comment "$number" --body "📱 Apple approved iOS ${version} (build ${build}). Re-ran the **iOS Native Check** ([run](${run_url})); this PR can merge once it passes, and the next prod deploy releases it on the App Store."
}
diff --git a/.github/workflows/native-check-label.yml b/.github/workflows/native-check-label.yml
index 9216960a1d..f0343ea356 100644
--- a/.github/workflows/native-check-label.yml
+++ b/.github/workflows/native-check-label.yml
@@ -26,13 +26,27 @@ jobs:
steps:
- name: Re-run the gate job for this head
run: |
+ # The latest `PR CI` run that ran for commit $1, as {databaseId, status, url},
+ # or nothing. Every label starts a `PR CI` run, and runs for labels other than
+ # run-ci skip every job, so only a run whose Start job ran counts.
+ pr_ci_run() {
+ local id
+ for id in $(gh api "repos/${GH_REPO}/actions/workflows/pr-ci.yml/runs?head_sha=$1&event=pull_request&per_page=30" \
+ --jq '.workflow_runs[].id'); do
+ if [[ -n "$(gh api "repos/${GH_REPO}/actions/runs/${id}/jobs" \
+ --jq '.jobs[] | select(.name == "Start" and .conclusion != "skipped") | .id')" ]]; then
+ gh api "repos/${GH_REPO}/actions/runs/${id}" --jq '{databaseId: .id, status, url: .html_url}'
+ return 0
+ fi
+ done
+ }
set -euo pipefail
- # Re-run the $JOB_NAME job of the web app PR checks run for $HEAD_SHA (waiting
- # for that run to finish first: a run in progress saw the labels as they were
- # when it started). GitHub re-runs the dependent `Web App Status Check` with
- # it. A push after the label event starts a fresh run that reads the labels
- # itself, and would also have cancelled this head's run (the web suite
- # cancels in-progress runs per PR): nothing to re-run then.
+ # Re-run the $JOB_NAME job of the PR CI run for $HEAD_SHA (waiting for that run
+ # to finish first: a run in progress saw the labels as they were when it
+ # started). GitHub re-runs the jobs that depend on it with it, up to the
+ # CI gate job that sets the required status. A newer CI request starts a fresh
+ # run that reads the labels itself, and cancels this head's run: nothing to
+ # re-run then.
current=$(gh pr view "$PR_NUMBER" --repo "$GH_REPO" --json headRefOid --jq '.headRefOid')
if [[ "$current" != "$HEAD_SHA" ]]; then
echo "PR head moved from ${HEAD_SHA:0:10} to ${current:0:10}; its run reads the labels itself. Nothing to re-run."
@@ -40,16 +54,15 @@ jobs:
fi
deadline=$(( $(date +%s) + 25 * 60 ))
while true; do
- run=$(gh run list --repo "$GH_REPO" --workflow web-app-check-main.yml --commit "$HEAD_SHA" \
- --json databaseId,status,conclusion --limit 1 --jq '.[0] // empty')
+ run=$(pr_ci_run "$HEAD_SHA")
if [[ -z "$run" ]]; then
- echo "No Web App Pr Checks run for ${HEAD_SHA:0:10} yet; nothing to re-run (the next push runs the gate with the current labels)."
+ echo "No PR CI run for ${HEAD_SHA:0:10} yet; nothing to re-run (the next run reads the current labels)."
exit 0
fi
run_id=$(jq -r '.databaseId' <<<"$run")
status=$(jq -r '.status' <<<"$run")
if [[ "$status" == "completed" ]]; then
- if [[ "$(jq -r '.conclusion' <<<"$run")" == "cancelled" ]]; then
+ if [[ "$(gh run view "$run_id" --repo "$GH_REPO" --json conclusion --jq '.conclusion')" == "cancelled" ]]; then
echo "Run ${run_id} was cancelled (superseded); nothing to re-run."
exit 0
fi
@@ -63,9 +76,9 @@ jobs:
sleep 30
done
job_id=$(gh run view "$run_id" --repo "$GH_REPO" --json jobs \
- --jq ".jobs[] | select(.name == \"${JOB_NAME}\") | .databaseId")
+ --jq ".jobs[] | select(.name == \"Web App / ${JOB_NAME}\") | .databaseId")
if [[ -z "$job_id" ]]; then
- echo "Run ${run_id} has no ${JOB_NAME} job; nothing to re-run."
+ echo "Run ${run_id} has no Web App / ${JOB_NAME} job; nothing to re-run."
exit 0
fi
echo "Re-running ${JOB_NAME} (job ${job_id} of run ${run_id}) with the current labels."
diff --git a/.github/workflows/sdk-check.yml b/.github/workflows/sdk-check.yml
index d8a02dd678..02812bb5b9 100644
--- a/.github/workflows/sdk-check.yml
+++ b/.github/workflows/sdk-check.yml
@@ -2,12 +2,6 @@
# Source: tooling/xtask/crates/xtask_workflows/src/workflows/sdk_check.rs
name: SDK Check
'on':
- pull_request:
- branches:
- - main
- paths:
- - packages/sdk/**
- - '.github/workflows/sdk-check.yml'
push:
branches:
- main
@@ -42,5 +36,5 @@ jobs:
run: bun run coverage
working-directory: packages/sdk
concurrency:
- group: sdk-check-${{ github.event.action == 'labeled' && github.run_id || github.ref }}
+ group: sdk-check-${{ github.event_name == 'pull_request' && github.run_id || github.ref }}
cancel-in-progress: true
diff --git a/.github/workflows/test_macrod_update.yml b/.github/workflows/test_macrod_update.yml
index 666e8e0b94..7d995c77c2 100644
--- a/.github/workflows/test_macrod_update.yml
+++ b/.github/workflows/test_macrod_update.yml
@@ -2,12 +2,6 @@
# Source: tooling/xtask/crates/xtask_workflows/src/workflows/test_macrod_update.rs
name: Test macrod update
'on':
- pull_request:
- branches:
- - main
- paths:
- - crates/coding_agent_worker/**
- - '.github/workflows/test_macrod_update.yml'
workflow_call: {}
workflow_dispatch: {}
permissions:
diff --git a/.github/workflows/web-app-check-main.yml b/.github/workflows/web-app-check-main.yml
index e4ed2bbf90..f6df1691a3 100644
--- a/.github/workflows/web-app-check-main.yml
+++ b/.github/workflows/web-app-check-main.yml
@@ -2,14 +2,6 @@
# Source: tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main.rs
name: Web App Pr Checks
'on':
- pull_request:
- types:
- - opened
- - synchronize
- - reopened
- - ready_for_review
- branches:
- - main
workflow_call: {}
jobs:
path-check:
@@ -1418,6 +1410,3 @@ jobs:
fi
echo "All jobs passed or were skipped"
-concurrency:
- group: web-app-pr-checks-${{ github.event.action == 'labeled' && github.run_id || github.ref }}
- cancel-in-progress: true
diff --git a/apps/web/docs/ios-releases.md b/apps/web/docs/ios-releases.md
index 1aeb431b56..82f646b8ac 100644
--- a/apps/web/docs/ios-releases.md
+++ b/apps/web/docs/ios-releases.md
@@ -32,9 +32,10 @@ icon and app-name branding are Android-only.
## The flow for a PR with breaking native changes
1. **`iOS Native Check`**, a job of the web app PR checks
- (`.github/workflows/web-app-check-main.yml`), runs on every PR against
- `main`. The required `Web App Status Check` depends on it, so no branch
- ruleset change is needed. If the PR touches the iOS native code (see
+ (`.github/workflows/web-app-check-main.yml`), runs whenever CI runs on a PR
+ against `main` (the `run-ci` label). The required `CI gate` status depends
+ on it, so no branch ruleset change is needed. The release starts only
+ after CI has run on the head. If the PR touches the iOS native code (see
"What counts as native code" below) it requires:
- the iOS release numbers to be bumped relative to `main`, and
- Apple to have **approved** that exact version + build (held for
@@ -97,13 +98,13 @@ icon and app-name branding are Android-only.
(`.github/workflows/ios-release-watch.yml`, every 30 minutes) notices: for
each open PR labeled `ios-update` it asks App Store Connect whether Apple
approved the version + build at the PR head and, when it did, re-runs the
- PR's failed `iOS Native Check` job and comments. The
+ failed jobs of the PR's latest `PR CI` run and comments. The
gate turns green on its own and the PR merges if auto-merge is on.
(Re-running the job by hand works too. The watcher stops after two
automatic re-runs — counted by its own comments on the PR — so a check
failing for another reason doesn't retry forever, and GitHub refuses to
- re-run runs older than 30 days: after a review that long, push a commit to
- get a fresh run.)
+ re-run runs older than 30 days: after a review that long, add the `run-ci`
+ label to get a fresh run.)
5. The next prod deploy (`.github/workflows/release-production.yml`) ships
the web bundle, then releases the App Store version:
- The web build (`just build-prod`) reads both platform floors from
@@ -310,8 +311,7 @@ production OTLP proxy
- **Labels**: create `ios-update` and `skip-ios-update`.
- **Branch protection**: nothing to do — the gate is a job of the web app PR
- checks, and the already-required `Web App Status Check` fails when it
- fails.
+ checks, and the already-required `CI gate` status fails when it fails.
- **Doppler project `ios-release`, config `prd`** (same shape as
`macos-release/prd`, which the desktop notarization uses; that key has only
the Developer role, which cannot submit for review, hence a separate key):
diff --git a/docs/development/android.md b/docs/development/android.md
index e028a031da..a6ca9ca548 100644
--- a/docs/development/android.md
+++ b/docs/development/android.md
@@ -150,7 +150,8 @@ statuses on the PR's commits: `android-play/release` (set by the publisher
around the production promotion) and `android-play/live` (set by the watcher
once the release is live).
-**`Android Native Check`** runs on every PR against `main`. Its native tree
+**`Android Native Check`** runs whenever CI runs on a PR against `main` (the
+`run-ci` label), and the release starts only after CI has run on the head. Its native tree
excludes platform-specific desktop/iOS files and Markdown docs, which do not
ship in the Android binary (`apps/web/scripts/android-native.mjs` defines
what counts). When the Android native code changed, it requires a
@@ -160,7 +161,7 @@ The watcher sets that status only once Google has **published** the release
(through review and available to users; the edit API's `status: completed`
only describes the rollout, so the watcher also reads the release list's
`releaseLifecycleState`) with a provenance stamp matching the merge result.
-Until then the check fails and the required `Web App Status Check` fails with
+Until then the check fails and the required `CI gate` status fails with
it. Web-only pushes after the release keep it valid: the status on an earlier
commit still matches.
@@ -232,8 +233,8 @@ To release:
and a link to the run.
3. Wait for Google. The **`Android Release Watch`** workflow (every 30
minutes) notices the version code being published on production, marks
- the PR head `android-play/live`, re-runs the PR's failed
- `Android Native Check` job, and comments; the PR merges if auto-merge is
+ the PR head `android-play/live`, re-runs the failed jobs of the PR's latest
+ `PR CI` run (the `Android Native Check` among them), and comments; the PR merges if auto-merge is
on.
4. Pushes after the label: web-only commits need nothing. Native commits make
the bundle stale: **`Android Release Drift`** cancels an in-progress build,
diff --git a/docs/development/ci.md b/docs/development/ci.md
index 42b56406ca..46d61cc78f 100644
--- a/docs/development/ci.md
+++ b/docs/development/ci.md
@@ -1,6 +1,6 @@
# CI on pull requests
-CI runs on a pull request when someone adds the `run-ci` label. The `PR CI`
+CI runs on a pull request only when someone adds the `run-ci` label. The `PR CI`
workflow then runs every check on the PR's head commit, removes the label, and
reports the result as the `CI gate` commit status on that commit. Each push
leaves the new commit at `Not run on this commit`, so a PR can merge only after
@@ -14,6 +14,3 @@ The [`run-ci` skill](../../.agents/skills/run-ci/SKILL.md) has the commands,
what each `CI gate` state means, re-runs, and fork PRs. The workflows are
generated from Rust; see the
[workflows rule](../../.agents/rules/infra/github-workflows.md).
-
-Until `main`'s ruleset requires `CI gate`, the checks also still run on every
-push, and `main` still requires their old status checks.
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/android_release_watch.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/android_release_watch.rs
index f8c0ac5b22..f3a341b3ff 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/android_release_watch.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/android_release_watch.rs
@@ -84,6 +84,7 @@ fn rerun_live_checks() -> Step<Run> {
Step::new("Re-run the check on PRs whose release is live")
.run(concat!(
include_str!("scripts/android_git_fetch.sh"),
+ include_str!("scripts/pr_ci_run.sh"),
include_str!("scripts/android_play_statuses.sh"),
include_str!("scripts/android_release_watch.sh")
))
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/cargo_deny.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/cargo_deny.rs
index eed5a2e13b..a822b843bd 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/cargo_deny.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/cargo_deny.rs
@@ -2,12 +2,12 @@
//! workspace on PRs that touch manifests. Generated into `cargo_deny.yml`
//! (replaces the hand-written `cargo-deny.yml`).
-use gh_workflow::{Event, Job, PullRequest, PullRequestType, Step, Use, Workflow, WorkflowCall};
+use gh_workflow::{Event, Job, Step, Use, Workflow, WorkflowCall};
use xtask_paths::RepoGlob;
-use crate::workflows::{runners, vars};
+use crate::workflows::runners;
-/// Files whose change runs the check, on a push and in `PR CI`.
+/// Files whose change makes `PR CI` call this workflow.
pub const PATHS: &[RepoGlob<'static>] = &[
xtask_paths::repo_glob!("Cargo.toml"),
xtask_paths::repo_glob!("crates/**/Cargo.toml"),
@@ -20,22 +20,8 @@ pub const PATHS: &[RepoGlob<'static>] = &[
/// Build the workflow.
pub fn cargo_deny() -> Workflow {
- let pull_request = PullRequest::default()
- .add_branch("main")
- .add_type(PullRequestType::Opened)
- .add_type(PullRequestType::Synchronize)
- .add_type(PullRequestType::Reopened)
- .add_type(PullRequestType::ReadyForReview);
-
Workflow::new("cargo deny check")
- .on(Event::default()
- .pull_request(
- PATHS
- .iter()
- .fold(pull_request, |trigger, path| trigger.add_path(*path)),
- )
- .workflow_call(WorkflowCall::default()))
- .concurrency(vars::concurrency("cargo-deny"))
+ .on(Event::default().workflow_call(WorkflowCall::default()))
.add_job("cargo-deny", cargo_deny_job())
}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/cargo_workspace_dependency_check.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/cargo_workspace_dependency_check.rs
index 1372be6659..6031754a61 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/cargo_workspace_dependency_check.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/cargo_workspace_dependency_check.rs
@@ -9,14 +9,12 @@
//! (which drifted from the workspace toolchain) and gives the `cargo install`
//! and xtask builds warm caches instead of compiling cold on every run.
-use gh_workflow::{
- Event, Job, PullRequest, PullRequestType, Run, Step, Use, Workflow, WorkflowCall,
-};
+use gh_workflow::{Event, Job, Run, Step, Use, Workflow, WorkflowCall};
use xtask_paths::RepoGlob;
use crate::workflows::{runners, steps, vars};
-/// Files whose change runs the workflow, on a push and in `PR CI`.
+/// Files whose change makes `PR CI` call this workflow.
pub const PATHS: &[RepoGlob<'static>] = &[
xtask_paths::repo_glob!("Cargo.toml"),
xtask_paths::repo_glob!("crates/**/Cargo.toml"),
@@ -35,22 +33,8 @@ pub const PATHS: &[RepoGlob<'static>] = &[
/// Build the workflow.
pub fn cargo_workspace_dependency_check() -> Workflow {
- let pull_request = PullRequest::default()
- .add_branch("main")
- .add_type(PullRequestType::Opened)
- .add_type(PullRequestType::Synchronize)
- .add_type(PullRequestType::Reopened)
- .add_type(PullRequestType::ReadyForReview);
-
Workflow::new("cargo workspace dependency check")
- .on(Event::default()
- .pull_request(
- PATHS
- .iter()
- .fold(pull_request, |trigger, path| trigger.add_path(*path)),
- )
- .workflow_call(WorkflowCall::default()))
- .concurrency(vars::concurrency("cargo-workspace-dependency-check"))
+ .on(Event::default().workflow_call(WorkflowCall::default()))
.add_job("dependency-check", dependency_check())
.add_job("hakari-and-dep-closures", hakari_and_dep_closures())
}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/check_generated.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/check_generated.rs
index af486acc3d..91fe91e99c 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/check_generated.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/check_generated.rs
@@ -4,12 +4,12 @@
//! (and the kafka topics file) are defined in Rust" enforceable rather than
//! aspirational.
-use gh_workflow::{Event, Job, PullRequest, Step, Workflow, WorkflowCall};
+use gh_workflow::{Event, Job, Step, Workflow, WorkflowCall};
use xtask_paths::RepoGlob;
use crate::workflows::{runners, steps};
-/// Files whose change runs the workflow, on a push and in `PR CI`.
+/// Files whose change makes `PR CI` call this workflow.
pub const PATHS: &[RepoGlob<'static>] = &[
xtask_paths::repo_glob!("tooling/xtask/**"),
xtask_paths::repo_glob!("crates/macro_event_topics/**"),
@@ -19,16 +19,8 @@ pub const PATHS: &[RepoGlob<'static>] = &[
/// Build the workflow.
pub fn check_generated_workflows() -> Workflow {
- let pull_request = PullRequest::default().add_branch("main");
-
Workflow::new("check generated workflows")
- .on(Event::default()
- .pull_request(
- PATHS
- .iter()
- .fold(pull_request, |trigger, path| trigger.add_path(*path)),
- )
- .workflow_call(WorkflowCall::default()))
+ .on(Event::default().workflow_call(WorkflowCall::default()))
.add_job("check-workflows", check_workflows())
}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/check_node_modules_nix.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/check_node_modules_nix.rs
index fbb6dce34b..dbe1959a21 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/check_node_modules_nix.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/check_node_modules_nix.rs
@@ -2,12 +2,12 @@
//! derivation still matches the committed lockfile/package manifests. Generated
//! into `check_node_modules_nix.yml`.
-use gh_workflow::{Event, Job, Level, Permissions, PullRequest, Step, Workflow, WorkflowCall};
+use gh_workflow::{Event, Job, Level, Permissions, Step, Workflow, WorkflowCall};
use xtask_paths::RepoGlob;
use crate::workflows::{runners, steps};
-/// Files whose change runs the workflow, on a push and in `PR CI`.
+/// Files whose change makes `PR CI` call this workflow.
pub const PATHS: &[RepoGlob<'static>] = &[
xtask_paths::repo_glob!("bun.lock"),
xtask_paths::repo_glob!("packages/sdk/bun.lock"),
@@ -27,20 +27,12 @@ pub const PATHS: &[RepoGlob<'static>] = &[
/// Build the workflow.
pub fn check_node_modules_nix() -> Workflow {
- let pull_request = PullRequest::default().add_branch("main");
-
Workflow::new("check node_modules nix")
.permissions(Permissions {
contents: Some(Level::Read),
..Default::default()
})
- .on(Event::default()
- .pull_request(
- PATHS
- .iter()
- .fold(pull_request, |trigger, path| trigger.add_path(*path)),
- )
- .workflow_call(WorkflowCall::default()))
+ .on(Event::default().workflow_call(WorkflowCall::default()))
.add_job(
"check-linux-node-modules-nix",
check_linux_node_modules_nix(),
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/check_tauri_lockfiles.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/check_tauri_lockfiles.rs
index 67caabfc2a..06a97b8e44 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/check_tauri_lockfiles.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/check_tauri_lockfiles.rs
@@ -9,14 +9,12 @@
//! runs only for those.
//! Generated into `check_tauri_lockfiles.yml`.
-use gh_workflow::{
- Event, Expression, Job, Level, Permissions, PullRequest, Step, Use, Workflow, WorkflowCall,
-};
+use gh_workflow::{Event, Expression, Job, Level, Permissions, Step, Use, Workflow, WorkflowCall};
use xtask_paths::RepoGlob;
use crate::workflows::{runners, steps, vars};
-/// Files whose change runs the workflow, on a push and in `PR CI`.
+/// Files whose change makes `PR CI` call this workflow.
pub const PATHS: &[RepoGlob<'static>] = &[
xtask_paths::repo_glob!("apps/web/tauri/**"),
xtask_paths::repo_glob!("crates/**/Cargo.toml"),
@@ -29,20 +27,12 @@ pub const PATHS: &[RepoGlob<'static>] = &[
/// Build the workflow.
pub fn check_tauri_lockfiles() -> Workflow {
- let pull_request = PullRequest::default().add_branch("main");
-
Workflow::new("check tauri lockfiles")
.permissions(Permissions {
contents: Some(Level::Read),
..Default::default()
})
- .on(Event::default()
- .pull_request(
- PATHS
- .iter()
- .fold(pull_request, |trigger, path| trigger.add_path(*path)),
- )
- .workflow_call(WorkflowCall::default()))
+ .on(Event::default().workflow_call(WorkflowCall::default()))
.add_job("check-tauri-lockfiles", check_tauri_lockfiles_job())
.add_job("check-tauri-vendoring", check_tauri_vendoring_job())
}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage.rs
index 261dac6a2a..5a597a010c 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage.rs
@@ -11,8 +11,7 @@
//! `graphql-schema-compat` run alongside `test`.
use gh_workflow::{
- Container, Env, Event, Expression, Job, Port, PullRequest, PullRequestType, Run, Step,
- Workflow, WorkflowCall,
+ Container, Env, Event, Expression, Job, Port, Run, Step, Workflow, WorkflowCall,
};
use xtask_paths::RuntimePath;
@@ -28,18 +27,8 @@ mod test;
/// Build the workflow.
pub fn code_check_cloud_storage() -> Workflow {
Workflow::new("cloud storage code check")
- .on(Event::default()
- .pull_request(
- PullRequest::default()
- .add_branch("main")
- .add_type(PullRequestType::Opened)
- .add_type(PullRequestType::Synchronize)
- .add_type(PullRequestType::Reopened)
- .add_type(PullRequestType::ReadyForReview),
- )
- .workflow_call(WorkflowCall::default()))
+ .on(Event::default().workflow_call(WorkflowCall::default()))
.map(vars::with_global_env)
- .concurrency(vars::concurrency("code-check-cloud-storage"))
.add_job("path-check", path_check())
.add_job("check", check())
.add_job("doppler-config", doppler_config())
@@ -137,7 +126,7 @@ fn doppler_config() -> Job {
steps::gated_job()
.timeout_minutes(45u32)
.cond(Expression::new(
- "needs.path-check.outputs.should_run == 'true' && (github.event.pull_request.draft == false || github.event.action == 'labeled') && needs.path-check.outputs.doppler_candidates == 'true'",
+ "needs.path-check.outputs.should_run == 'true' && needs.path-check.outputs.doppler_candidates == 'true'",
))
.runs_on(runners::Runner::RustCi.with_cache_tag(vars::CI_CACHE_TAG))
.map(with_check_env)
@@ -163,7 +152,7 @@ fn graphql_schema_compat() -> Job {
steps::gated_job()
.timeout_minutes(15u32)
.cond(Expression::new(
- "needs.path-check.outputs.should_run == 'true' && (github.event.pull_request.draft == false || github.event.action == 'labeled') && needs.path-check.outputs.graphql_schema == 'true'",
+ "needs.path-check.outputs.should_run == 'true' && needs.path-check.outputs.graphql_schema == 'true'",
))
.runs_on(runners::Runner::Small.to_string())
.add_step(steps::checkout(false, false).add_with(("fetch-depth", 2)))
@@ -182,7 +171,7 @@ fn test() -> Job {
steps::gated_job()
.timeout_minutes(90u32)
.cond(Expression::new(
- "needs.path-check.outputs.should_run == 'true' && (github.event.pull_request.draft == false || github.event.action == 'labeled') && needs.path-check.outputs.rust_packages != 'none' && needs.path-check.outputs.skip_tests != 'true'",
+ "needs.path-check.outputs.should_run == 'true' && needs.path-check.outputs.rust_packages != 'none' && needs.path-check.outputs.skip_tests != 'true'",
))
.runs_on(runners::Runner::Large.with_cache_tag(vars::CI_CACHE_TAG))
.add_env((
@@ -250,7 +239,7 @@ fn build_service_bins() -> Job {
}
const BUILD_SERVICE_BINS_CONDITION: &str = "needs.path-check.outputs.should_run == 'true' \
- && (github.event.pull_request.draft == false || github.event.action == 'labeled') \
+ \
&& needs.path-check.outputs.skip_tests != 'true' \
&& (needs.path-check.outputs.rust_packages == 'all' \
|| contains(needs.path-check.outputs.rust_packages, 'document_storage_service') \
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_conventions.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_conventions.rs
index 0a4b87008a..6ebc57fb77 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_conventions.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_conventions.rs
@@ -8,8 +8,7 @@
//! conventions from `docs/development/style-guide.md` at the repo root.
use gh_workflow::{
- Event, Expression, Job, Level, Permissions, PullRequest, PullRequestType, Run, Step, Use,
- Workflow, WorkflowCall,
+ Event, Expression, Job, Level, Permissions, Run, Step, Use, Workflow, WorkflowCall,
};
use crate::workflows::{runners, steps, vars};
@@ -28,17 +27,7 @@ pub fn code_check_conventions() -> Workflow {
contents: Some(Level::Read),
..Default::default()
})
- .on(Event::default()
- .pull_request(
- PullRequest::default()
- .add_branch("main")
- .add_type(PullRequestType::Opened)
- .add_type(PullRequestType::Synchronize)
- .add_type(PullRequestType::Reopened)
- .add_type(PullRequestType::ReadyForReview),
- )
- .workflow_call(WorkflowCall::default()))
- .concurrency(vars::concurrency("code-check-conventions"))
+ .on(Event::default().workflow_call(WorkflowCall::default()))
.add_job("path-check", path_check())
.add_job("ast-grep", ast_grep())
.add_job("status-check", status_check())
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_infra.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_infra.rs
index 02c4f22a0c..6db20b25ba 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_infra.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_infra.rs
@@ -4,9 +4,7 @@
//! `Infra Status Check`, which is unchanged, so branch protection is
//! unaffected by the file rename).
-use gh_workflow::{
- Event, Expression, Job, PullRequest, PullRequestType, Run, Step, Use, Workflow, WorkflowCall,
-};
+use gh_workflow::{Event, Expression, Job, Run, Step, Use, Workflow, WorkflowCall};
use crate::workflows::{
runners,
@@ -26,17 +24,7 @@ fn infra_runner() -> String {
/// Build the workflow.
pub fn code_check_infra() -> Workflow {
Workflow::new("infra code check")
- .on(Event::default()
- .pull_request(
- PullRequest::default()
- .add_branch("main")
- .add_type(PullRequestType::Opened)
- .add_type(PullRequestType::Synchronize)
- .add_type(PullRequestType::Reopened)
- .add_type(PullRequestType::ReadyForReview),
- )
- .workflow_call(WorkflowCall::default()))
- .concurrency(vars::concurrency("code-check-infra"))
+ .on(Event::default().workflow_call(WorkflowCall::default()))
.add_job("path-check", path_check())
.add_job("biome-check", biome_check())
.add_job("check", check())
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/ios_release_watch.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/ios_release_watch.rs
index 9b5e1625f5..a379fb4439 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/ios_release_watch.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/ios_release_watch.rs
@@ -101,6 +101,7 @@ fn rerun_approved_checks() -> Step<Run> {
Step::new("Re-run the check on PRs whose release Apple approved")
.run(concat!(
include_str!("scripts/ios_native_tree.sh"),
+ include_str!("scripts/pr_ci_run.sh"),
include_str!("scripts/ios_release_watch.sh")
))
.shell("bash")
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/native_check_label.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/native_check_label.rs
index b53dd9e9c1..84b52060ac 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/native_check_label.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/native_check_label.rs
@@ -1,14 +1,14 @@
//! `Native Check Label` — re-runs the `iOS Native Check` or `Android Native
-//! Check` job of the web app PR checks when the matching `skip-ios-update` /
+//! Check` job of the PR's `PR CI` run when the matching `skip-ios-update` /
//! `skip-android-update` label is added to or removed from a PR. The gates
-//! live in that workflow (so the required `Web App Status Check` covers
-//! them), and re-running the whole web suite on every label event would be
-//! wasteful, so this re-runs just the one job; GitHub re-runs the status
-//! check that depends on it. A run still in progress saw the labels as they
-//! were when it started, so it is waited for first; a run cancelled by a
-//! later push, or a head that has since moved, is left alone (the newer run
-//! reads the labels itself). This job is not a required check: it can take
-//! up to 25 minutes while waiting, and the release preconditions ignore it.
+//! live in the web workflow that run calls (so the required `CI gate` covers
+//! them), and re-running all of CI on every label event would be wasteful, so
+//! this re-runs just the one job; GitHub re-runs the jobs that depend on it.
+//! A run still in progress saw the labels as they were when it started, so it
+//! is waited for first; a superseded run, or a head that has since moved, is
+//! left alone (the newer run reads the labels itself). This job is not a
+//! required check: it can take up to 25 minutes while waiting, and the release
+//! preconditions ignore it.
use gh_workflow::{
Event, Expression, Job, Level, Permissions, PullRequest, PullRequestType, Step, Workflow,
@@ -53,7 +53,10 @@ fn rerun_job() -> Job {
))
.add_step(
Step::new("Re-run the gate job for this head")
- .run(include_str!("scripts/native_check_rerun.sh"))
+ .run(concat!(
+ include_str!("scripts/pr_ci_run.sh"),
+ include_str!("scripts/native_check_rerun.sh")
+ ))
.shell("bash"),
)
}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/android_release_preconditions.sh b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/android_release_preconditions.sh
index e7b9c4996a..00652b6882 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/android_release_preconditions.sh
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/android_release_preconditions.sh
@@ -55,8 +55,25 @@ echo "Releasing Android version code ${version_code}."
ours='^((Web App / )?(Android Native Check|Web App Status Check|iOS Native Check)|Android Play Release|Re-run the native check|Android Release Drift|android-play/|CI gate$)'
deadline=$(( $(date +%s) + WAIT_MINUTES * 60 ))
while true; do
- checks=$(gh pr checks "$PR_NUMBER" --repo "$GH_REPO" --json name,bucket \
- | jq -c --arg ours "$ours" '[.[] | select(.name | test($ours) | not)]')
+ all_checks=$(gh pr checks "$PR_NUMBER" --repo "$GH_REPO" --json name,bucket,description)
+ # The checks only exist once someone has run PR CI on this head; its CI gate
+ # fails with the native check, so only the gate's description is read here.
+ gate=$(jq -r '[.[] | select(.name == "CI gate") | .description][0] // ""' <<<"$all_checks")
+ case "$gate" in
+ "" | "Not run on this commit."*)
+ echo "CI has not run on ${head_sha:0:10}. Run it (gh api repos/${GH_REPO}/issues/${PR_NUMBER}/labels -f "labels[]=run-ci"), then re-add android-update once it passes." >&2
+ exit 1
+ ;;
+ "Running on"* | "Passed on"* | "Failed:"*) ;;
+ *)
+ echo "CI could not run on ${head_sha:0:10}: ${gate}. Re-add android-update once it passes." >&2
+ exit 1
+ ;;
+ esac
+ checks=$(jq -c --arg ours "$ours" '[.[] | select(.name | test($ours) | not)]' <<<"$all_checks")
+ if [[ "$gate" == "Running on"* ]]; then
+ checks=$(jq -c '. + [{name: "CI gate", bucket: "pending"}]' <<<"$checks")
+ fi
failing=$(jq -r '[.[] | select(.bucket == "fail" or .bucket == "cancel") | .name] | join(", ")' <<<"$checks")
pending=$(jq -r '[.[] | select(.bucket == "pending") | .name] | join(", ")' <<<"$checks")
if [[ -n "$failing" ]]; then
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/android_release_watch.sh b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/android_release_watch.sh
index 174c00a0d2..0b6b5ea1c4 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/android_release_watch.sh
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/android_release_watch.sh
@@ -5,9 +5,9 @@ set -euo pipefail
# (`merge` is GitHub's test merge commit; the gate hashes the same). When it
# is, mark the PR head `android-play/live` (the gate cannot ask Play, so it
# reads that status), and if the PR's latest `Android Native Check` job (of
-# the web app PR checks run) failed — it fails until the release is live —
-# re-run that job so the gate, and the `Web App Status Check` that depends on
-# it, go green without anyone clicking "Re-run". GH_TOKEN needs actions:write,
+# the PR CI run) failed — it fails until the release is live — re-run the
+# run's failed jobs so the gate, and the `CI gate` status that depends on it,
+# go green without anyone clicking "Re-run". GH_TOKEN needs actions:write,
# pull-requests:write and statuses:write; GOOGLE_PLAY_ACCESS_TOKEN the
# androidpublisher scope.
cd apps/web
@@ -42,21 +42,20 @@ check_pr() {
echo " marked ${sha:0:10} android-play/live"
fi
- run=$(gh run list --workflow web-app-check-main.yml --commit "$sha" \
- --json databaseId,status,url --limit 1 --jq '.[0] // empty')
+ run=$(pr_ci_run "$sha")
if [[ -z "$run" ]]; then
- echo " no Web App Pr Checks run for this commit; skipping"
+ echo " no PR CI run for this commit; skipping"
return 0
fi
run_id=$(jq -r '.databaseId' <<<"$run")
status=$(jq -r '.status' <<<"$run")
run_url=$(jq -r '.url' <<<"$run")
if [[ "$status" != "completed" ]]; then
- echo " Web App Pr Checks run ${run_id} is ${status}; skipping"
+ echo " PR CI run ${run_id} is ${status}; skipping"
return 0
fi
job=$(gh run view "$run_id" --json jobs \
- --jq '.jobs[] | select(.name == "Android Native Check") | {id: .databaseId, conclusion}')
+ --jq '.jobs[] | select(.name == "Web App / Android Native Check") | {id: .databaseId, conclusion}')
if [[ -z "$job" ]]; then
echo " run ${run_id} has no Android Native Check job; skipping"
return 0
@@ -79,8 +78,10 @@ check_pr() {
echo " Android Native Check already re-run ${reruns} times and still failing; not re-running again — see ${run_url}"
return 0
fi
+ # Re-run the failed jobs, not just this one: the CI gate job that sets the
+ # required status depends on it from outside the called web workflow.
echo " re-running Android Native Check (job ${job_id} of run ${run_id}; ${reruns} automatic re-runs so far)"
- gh run rerun --job "$job_id"
+ gh run rerun "$run_id" --failed
gh pr comment "$number" --body "🤖 Android version code ${version_code} is live on Google Play. Re-ran the **Android Native Check** ([run](${run_url})); this PR can merge once it passes."
}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/ios_release_preconditions.sh b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/ios_release_preconditions.sh
index 44c6523bde..6539b3cce9 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/ios_release_preconditions.sh
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/ios_release_preconditions.sh
@@ -40,8 +40,25 @@ fi
ours='^((Web App / )?(iOS Native Check|Web App Status Check|Android Native Check)|Re-run the native check|iOS App Store Release|iOS Release Drift|CI gate$)'
deadline=$(( $(date +%s) + WAIT_MINUTES * 60 ))
while true; do
- checks=$(gh pr checks "$PR_NUMBER" --repo "$GH_REPO" --json name,bucket \
- | jq -c --arg ours "$ours" '[.[] | select(.name | test($ours) | not)]')
+ all_checks=$(gh pr checks "$PR_NUMBER" --repo "$GH_REPO" --json name,bucket,description)
+ # The checks only exist once someone has run PR CI on this head; its CI gate
+ # fails with the native check, so only the gate's description is read here.
+ gate=$(jq -r '[.[] | select(.name == "CI gate") | .description][0] // ""' <<<"$all_checks")
+ case "$gate" in
+ "" | "Not run on this commit."*)
+ echo "CI has not run on ${head_sha:0:10}. Run it (gh api repos/${GH_REPO}/issues/${PR_NUMBER}/labels -f "labels[]=run-ci"), then re-add ios-update once it passes." >&2
+ exit 1
+ ;;
+ "Running on"* | "Passed on"* | "Failed:"*) ;;
+ *)
+ echo "CI could not run on ${head_sha:0:10}: ${gate}. Re-add ios-update once it passes." >&2
+ exit 1
+ ;;
+ esac
+ checks=$(jq -c --arg ours "$ours" '[.[] | select(.name | test($ours) | not)]' <<<"$all_checks")
+ if [[ "$gate" == "Running on"* ]]; then
+ checks=$(jq -c '. + [{name: "CI gate", bucket: "pending"}]' <<<"$checks")
+ fi
failing=$(jq -r '[.[] | select(.bucket == "fail" or .bucket == "cancel") | .name] | join(", ")' <<<"$checks")
pending=$(jq -r '[.[] | select(.bucket == "pending") | .name] | join(", ")' <<<"$checks")
if [[ -n "$failing" ]]; then
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/ios_release_watch.sh b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/ios_release_watch.sh
index 479910e010..dfb1d6337d 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/ios_release_watch.sh
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/ios_release_watch.sh
@@ -10,10 +10,9 @@ set -euo pipefail
# committed at the PR head (held for release, or live), built from the
# native tree the PR's merge result would have (`merge` is GitHub's test
# merge commit; the gate hashes the same). When it did, and the PR's latest
-# `iOS Native Check` job (of the web app PR checks run) failed — it fails
-# until Apple approves — re-run that
-# job so the gate, and the `Web App Status Check` that depends on it, go
-# green without anyone clicking "Re-run".
+# `iOS Native Check` job (of the PR CI run) failed — it fails until Apple
+# approves — re-run the run's failed jobs so the gate, and the `CI gate`
+# status that depends on it, go green without anyone clicking "Re-run".
#
# GH_TOKEN needs actions:write + pull-requests:write.
cd apps/web
@@ -71,21 +70,20 @@ check_pr() {
fi
echo " approved by Apple"
- run=$(gh run list --workflow web-app-check-main.yml --commit "$sha" \
- --json databaseId,status,url --limit 1 --jq '.[0] // empty')
+ run=$(pr_ci_run "$sha")
if [[ -z "$run" ]]; then
- echo " no Web App Pr Checks run for this commit; skipping"
+ echo " no PR CI run for this commit; skipping"
return 0
fi
run_id=$(jq -r '.databaseId' <<<"$run")
status=$(jq -r '.status' <<<"$run")
run_url=$(jq -r '.url' <<<"$run")
if [[ "$status" != "completed" ]]; then
- echo " Web App Pr Checks run ${run_id} is ${status}; skipping"
+ echo " PR CI run ${run_id} is ${status}; skipping"
return 0
fi
job=$(gh run view "$run_id" --json jobs \
- --jq '.jobs[] | select(.name == "iOS Native Check") | {id: .databaseId, conclusion}')
+ --jq '.jobs[] | select(.name == "Web App / iOS Native Check") | {id: .databaseId, conclusion}')
if [[ -z "$job" ]]; then
echo " run ${run_id} has no iOS Native Check job; skipping"
return 0
@@ -110,8 +108,10 @@ check_pr() {
echo " iOS Native Check already re-run ${reruns} times and still failing; not re-running again — see ${run_url}"
return 0
fi
+ # Re-run the failed jobs, not just this one: the CI gate job that sets the
+ # required status depends on it from outside the called web workflow.
echo " re-running iOS Native Check (job ${job_id} of run ${run_id}; ${reruns} automatic re-runs so far)"
- gh run rerun --job "$job_id"
+ gh run rerun "$run_id" --failed
gh pr comment "$number" --body "📱 Apple approved iOS ${version} (build ${build}). Re-ran the **iOS Native Check** ([run](${run_url})); this PR can merge once it passes, and the next prod deploy releases it on the App Store."
}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/native_check_rerun.sh b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/native_check_rerun.sh
index 9790ba9025..8b5b140c8d 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/native_check_rerun.sh
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/native_check_rerun.sh
@@ -1,10 +1,10 @@
set -euo pipefail
-# Re-run the $JOB_NAME job of the web app PR checks run for $HEAD_SHA (waiting
-# for that run to finish first: a run in progress saw the labels as they were
-# when it started). GitHub re-runs the dependent `Web App Status Check` with
-# it. A push after the label event starts a fresh run that reads the labels
-# itself, and would also have cancelled this head's run (the web suite
-# cancels in-progress runs per PR): nothing to re-run then.
+# Re-run the $JOB_NAME job of the PR CI run for $HEAD_SHA (waiting for that run
+# to finish first: a run in progress saw the labels as they were when it
+# started). GitHub re-runs the jobs that depend on it with it, up to the
+# CI gate job that sets the required status. A newer CI request starts a fresh
+# run that reads the labels itself, and cancels this head's run: nothing to
+# re-run then.
current=$(gh pr view "$PR_NUMBER" --repo "$GH_REPO" --json headRefOid --jq '.headRefOid')
if [[ "$current" != "$HEAD_SHA" ]]; then
echo "PR head moved from ${HEAD_SHA:0:10} to ${current:0:10}; its run reads the labels itself. Nothing to re-run."
@@ -12,16 +12,15 @@ if [[ "$current" != "$HEAD_SHA" ]]; then
fi
deadline=$(( $(date +%s) + 25 * 60 ))
while true; do
- run=$(gh run list --repo "$GH_REPO" --workflow web-app-check-main.yml --commit "$HEAD_SHA" \
- --json databaseId,status,conclusion --limit 1 --jq '.[0] // empty')
+ run=$(pr_ci_run "$HEAD_SHA")
if [[ -z "$run" ]]; then
- echo "No Web App Pr Checks run for ${HEAD_SHA:0:10} yet; nothing to re-run (the next push runs the gate with the current labels)."
+ echo "No PR CI run for ${HEAD_SHA:0:10} yet; nothing to re-run (the next run reads the current labels)."
exit 0
fi
run_id=$(jq -r '.databaseId' <<<"$run")
status=$(jq -r '.status' <<<"$run")
if [[ "$status" == "completed" ]]; then
- if [[ "$(jq -r '.conclusion' <<<"$run")" == "cancelled" ]]; then
+ if [[ "$(gh run view "$run_id" --repo "$GH_REPO" --json conclusion --jq '.conclusion')" == "cancelled" ]]; then
echo "Run ${run_id} was cancelled (superseded); nothing to re-run."
exit 0
fi
@@ -35,9 +34,9 @@ while true; do
sleep 30
done
job_id=$(gh run view "$run_id" --repo "$GH_REPO" --json jobs \
- --jq ".jobs[] | select(.name == \"${JOB_NAME}\") | .databaseId")
+ --jq ".jobs[] | select(.name == \"Web App / ${JOB_NAME}\") | .databaseId")
if [[ -z "$job_id" ]]; then
- echo "Run ${run_id} has no ${JOB_NAME} job; nothing to re-run."
+ echo "Run ${run_id} has no Web App / ${JOB_NAME} job; nothing to re-run."
exit 0
fi
echo "Re-running ${JOB_NAME} (job ${job_id} of run ${run_id}) with the current labels."
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/pr_ci_run.sh b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/pr_ci_run.sh
new file mode 100644
index 0000000000..335c3c54ed
--- /dev/null
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/pr_ci_run.sh
@@ -0,0 +1,14 @@
+# The latest `PR CI` run that ran for commit $1, as {databaseId, status, url},
+# or nothing. Every label starts a `PR CI` run, and runs for labels other than
+# run-ci skip every job, so only a run whose Start job ran counts.
+pr_ci_run() {
+ local id
+ for id in $(gh api "repos/${GH_REPO}/actions/workflows/pr-ci.yml/runs?head_sha=$1&event=pull_request&per_page=30" \
+ --jq '.workflow_runs[].id'); do
+ if [[ -n "$(gh api "repos/${GH_REPO}/actions/runs/${id}/jobs" \
+ --jq '.jobs[] | select(.name == "Start" and .conclusion != "skipped") | .id')" ]]; then
+ gh api "repos/${GH_REPO}/actions/runs/${id}" --jq '{databaseId: .id, status, url: .html_url}'
+ return 0
+ fi
+ done
+}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/sdk_check.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/sdk_check.rs
index 69211fcd30..85fbb3eb56 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/sdk_check.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/sdk_check.rs
@@ -1,4 +1,4 @@
-use gh_workflow::{Event, Job, PullRequest, Push, Run, Step, Workflow, WorkflowCall};
+use gh_workflow::{Event, Job, Push, Run, Step, Workflow, WorkflowCall};
use xtask_paths::RepoGlob;
use crate::workflows::{steps, vars};
@@ -6,7 +6,7 @@ use crate::workflows::{steps, vars};
#[cfg(test)]
mod test;
-/// Files whose change runs the workflow, on a push and in `PR CI`.
+/// Files whose change makes `PR CI` call this workflow, and that runs it on `main`.
pub const PATHS: &[RepoGlob<'static>] = &[
xtask_paths::repo_glob!("packages/sdk/**"),
xtask_paths::repo_glob!(".github/workflows/sdk-check.yml"),
@@ -16,15 +16,8 @@ pub const PATHS: &[RepoGlob<'static>] = &[
/// checked by the web app workflow's `Generated Code Check`, which builds the
/// spec binaries once for every Rust-generated artifact.
pub fn sdk_check() -> Workflow {
- let pull_request = PullRequest::default().add_branch("main");
-
Workflow::new("SDK Check")
.on(Event::default()
- .pull_request(
- PATHS
- .iter()
- .fold(pull_request, |trigger, path| trigger.add_path(*path)),
- )
// `Release SDK` publishes from `main` without re-checking the
// package, so the same suite has to guard what lands there.
.push(
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/sdk_check/test.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/sdk_check/test.rs
index 1a1484ad29..f0e74f8cf1 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/sdk_check/test.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/sdk_check/test.rs
@@ -8,11 +8,11 @@ fn rendered_yaml() -> String {
/// Merges to `main` publish, so the package suite has to guard them too.
#[test]
-fn checks_the_package_on_pull_requests_and_main() {
+fn checks_the_package_in_pr_ci_and_on_main() {
let yaml = rendered_yaml();
assert!(yaml.contains("check-package"));
- assert!(yaml.contains("pull_request:"));
+ assert!(yaml.contains("workflow_call:"));
assert!(yaml.contains("push:"));
}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/steps.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/steps.rs
index bb7b95ce21..89fbcc1225 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/steps.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/steps.rs
@@ -475,14 +475,13 @@ pub fn show_sccache_stats() -> Step<Run> {
}
/// Base for jobs gated behind `path-check`: depends on it and runs only where
-/// the path filter matched, on non-draft PRs unless the run was requested with
-/// the `PR CI` label. Shared by `check` and `test`.
+/// the path filter matched. Shared by `check` and `test`.
pub fn gated_job() -> Job {
Job::default()
.needs(vec!["path-check".to_string()])
.cond(Expression::new(
- "needs.path-check.outputs.should_run == 'true' && (github.event.pull_request.draft == false || github.event.action == 'labeled')",
- ))
+ "needs.path-check.outputs.should_run == 'true'",
+ ))
}
// ---------------------------------------------------------------------------
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/test_macrod_update.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/test_macrod_update.rs
index 6b379d83df..3cdb338ad0 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/test_macrod_update.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/test_macrod_update.rs
@@ -7,7 +7,7 @@
//! and macOS, and the launcher layout plus `install.ps1` on Windows. Nothing
//! is published. Runs on pull requests that touch macrod, and on demand.
-use gh_workflow::{Event, Job, Level, Permissions, PullRequest, Run, Step, Workflow, WorkflowCall};
+use gh_workflow::{Event, Job, Level, Permissions, Run, Step, Workflow, WorkflowCall};
use xtask_paths::RepoGlob;
use crate::workflows::{runners, steps, vars};
@@ -19,7 +19,7 @@ const E2E: &str = "crates/coding_agent_worker/e2e";
const V1: &str = "v2000.1.1.1";
const V2: &str = "v2000.1.1.2";
-/// Files whose change runs the workflow, on a push and in `PR CI`.
+/// Files whose change makes `PR CI` call this workflow.
pub const PATHS: &[RepoGlob<'static>] = &[
xtask_paths::repo_glob!("crates/coding_agent_worker/**"),
xtask_paths::repo_glob!(".github/workflows/test_macrod_update.yml"),
@@ -27,19 +27,12 @@ pub const PATHS: &[RepoGlob<'static>] = &[
/// Build the workflow.
pub fn test_macrod_update() -> Workflow {
- let pull_request = PullRequest::default().add_branch("main");
-
Workflow::new("Test macrod update")
.permissions(Permissions {
contents: Some(Level::Read),
..Default::default()
})
.on(Event::default()
- .pull_request(
- PATHS
- .iter()
- .fold(pull_request, |trigger, path| trigger.add_path(*path)),
- )
.workflow_dispatch(gh_workflow::WorkflowDispatch::default())
.workflow_call(WorkflowCall::default()))
.add_job("linux", linux_job())
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/test_macrod_update/test.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/test_macrod_update/test.rs
index 553002cafe..00c87ef9d1 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/test_macrod_update/test.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/test_macrod_update/test.rs
@@ -15,5 +15,9 @@ fn runs_the_end_to_end_tests_on_every_platform() {
assert!(yaml.contains("update_e2e.py"));
assert!(yaml.contains("windows_test.ps1"));
assert!(yaml.contains("windows_claude_code_test.ps1"));
- assert!(yaml.contains("crates/coding_agent_worker/**"));
+ assert!(
+ PATHS
+ .iter()
+ .any(|path| path.as_str() == "crates/coding_agent_worker/**")
+ );
}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/vars.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/vars.rs
index caf4f80b2a..243458e0b4 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/vars.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/vars.rs
@@ -118,12 +118,11 @@ pub fn with_global_env(workflow: Workflow) -> Workflow {
}
/// Cancel superseded runs of this workflow on the same git ref. When `PR CI`
-/// calls the workflow (a `labeled` event), the group is that run's own:
-/// `PR CI` cancels its superseded runs itself, and a requested run must not
-/// cancel, or be cancelled by, the same checks running for a push.
+/// calls the workflow, the group is that run's own, because `PR CI` cancels
+/// its own superseded runs.
pub fn concurrency(prefix: &str) -> Concurrency {
Concurrency::new(Expression::new(format!(
- "{prefix}-${{{{ github.event.action == 'labeled' && github.run_id || github.ref }}}}"
+ "{prefix}-${{{{ github.event_name == 'pull_request' && github.run_id || github.ref }}}}"
)))
.cancel_in_progress(true)
}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main.rs
index 43cda84ad2..5346bf3379 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main.rs
@@ -2,8 +2,7 @@
//! Generated into `web-app-check-main.yml`.
use gh_workflow::{
- Event, Expression, Job, Level, Permissions, PullRequest, PullRequestType, Run, Step, Strategy,
- Use, Workflow, WorkflowCall,
+ Event, Expression, Job, Level, Permissions, Run, Step, Strategy, Use, Workflow, WorkflowCall,
};
use crate::workflows::{
@@ -36,17 +35,7 @@ fn mid_web_runner() -> String {
/// Build the workflow.
pub fn web_app_check_main() -> Workflow {
Workflow::new("Web App Pr Checks")
- .on(Event::default()
- .pull_request(
- PullRequest::default()
- .add_branch("main")
- .add_type(PullRequestType::Opened)
- .add_type(PullRequestType::Synchronize)
- .add_type(PullRequestType::Reopened)
- .add_type(PullRequestType::ReadyForReview),
- )
- .workflow_call(WorkflowCall::default()))
- .concurrency(vars::concurrency("web-app-pr-checks"))
+ .on(Event::default().workflow_call(WorkflowCall::default()))
.add_job("path-check", path_check())
.add_job(android_native_check::JOB_ID, android_native_check())
.add_job("typescript", typescript())