Skip to content
TypeScript

ci: skip jobs a pull request cannot affect (#19587)

maria2d743c2f168f
diff --git a/.github/actions/ci-changes/action.yml b/.github/actions/ci-changes/action.yml
new file mode 100644
index 00000000000..ecf78740465
--- /dev/null
+++ b/.github/actions/ci-changes/action.yml
@@ -0,0 +1,63 @@
+name: CI changes
+description: Decide which CI jobs a change needs. See .github/scripts/ci-changes.cjs.
+outputs:
+ typecheck:
+ value: ${{ steps.detect.outputs.typecheck }}
+ build:
+ value: ${{ steps.detect.outputs.build }}
+ test:
+ value: ${{ steps.detect.outputs.test }}
+ test_packages:
+ value: ${{ steps.detect.outputs.test_packages }}
+ test_web:
+ value: ${{ steps.detect.outputs.test_web }}
+ test_server:
+ value: ${{ steps.detect.outputs.test_server }}
+ rust:
+ value: ${{ steps.detect.outputs.rust }}
+ release_smoke:
+ value: ${{ steps.detect.outputs.release_smoke }}
+ mobile_native:
+ value: ${{ steps.detect.outputs.mobile_native }}
+runs:
+ using: composite
+ steps:
+ - id: detect
+ shell: bash
+ env:
+ EVENT_NAME: ${{ github.event_name }}
+ BEFORE_SHA: ${{ github.event.before }}
+ run: |
+ set -uo pipefail
+
+ decide() {
+ node .github/scripts/ci-changes.cjs "$@" | tee -a "$GITHUB_OUTPUT"
+ exit "${PIPESTATUS[0]}"
+ }
+
+ fail_open() {
+ echo "$* Running every job."
+ decide
+ }
+
+ # Reads the change from git rather than the REST API: every job that
+ # runs this shares the repository's 1,000 requests/hour GITHUB_TOKEN quota.
+ if [[ "$EVENT_NAME" == pull_request ]]; then
+ # A pull request checks out GitHub's merge commit with fetch-depth: 2,
+ # so its first parent is the base branch and the diff is the PR's change.
+ base=HEAD^1
+ mode=()
+ else
+ base=$BEFORE_SHA
+ git fetch --quiet --no-tags --depth=1 --filter=blob:none origin "$base" \
+ || fail_open "Could not fetch ${base}."
+ # main keeps a full run as the backstop for anything the gate misses.
+ mode=(--full)
+ fi
+
+ # --no-renames lists a rename as its old and new path: renaming a file out
+ # of a package changes that package just like editing it. It also keeps
+ # git from fetching file contents to score renames.
+ git diff --name-only --no-renames "$base" HEAD > "$RUNNER_TEMP/changed-paths" \
+ || fail_open "Could not diff against ${base}."
+ decide --paths "$RUNNER_TEMP/changed-paths" "${mode[@]}"
diff --git a/.github/scripts/ci-changes.cjs b/.github/scripts/ci-changes.cjs
new file mode 100644
index 00000000000..1904f3790a4
--- /dev/null
+++ b/.github/scripts/ci-changes.cjs
@@ -0,0 +1,203 @@
+// Decides which CI jobs a change needs. Prints `key=value` lines for
+// $GITHUB_OUTPUT; a job runs unless its key is "false".
+//
+// node ci-changes.cjs --paths <file> gate by the listed paths
+// node ci-changes.cjs --paths <file> --full run every Linux job, gate only the macOS lint
+// node ci-changes.cjs changed paths unknown: run everything
+//
+// Every changed path maps to workspace packages, which then pull in their
+// dependents from package.json. A path this file does not recognize runs
+// everything, so a new root file or directory can only cost minutes.
+const fs = require("node:fs");
+const path = require("node:path");
+
+const root = path.resolve(__dirname, "../..");
+
+// Never read by a build, typecheck, or test. Lint still formats them.
+const INERT = [
+ /^docs\//,
+ /^\.(agents|cursor|vscode|devcontainer|macroscope|repos)\//,
+ /^[^/]+\.md$/,
+ /^LICENSE$/,
+];
+
+// Run everything: the root vite.config.ts loads the first as setup for every
+// package's tests, and the vendored mobile tarballs are installed dependencies.
+const RUNS_EVERYTHING = [
+ /^packages\/shared\/src\/(HostProcess|testing\/longTempDir)\.ts$/,
+ /^apps\/mobile\/deps\//,
+];
+
+// Paths outside a package, or files inside one that other packages read
+// through relative imports rather than a package.json dependency.
+const EXTRA_OWNERS = [
+ // Vite configs and tsconfigs of these apps import scripts/lib directly.
+ [/^scripts\/lib\//, ["@t3tools/desktop", "@t3tools/mobile", "@t3tools/web", "t3"]],
+ // scripts/build-desktop-artifact.ts reads the GNOME extension manifest.
+ [/^apps\/desktop\/gnome-extension\//, ["@t3tools/scripts"]],
+ [/^native\/browser-secret\//, ["@t3tools/desktop"]],
+ [/^native\/libghostty-vt\//, ["@t3tools/web"]],
+];
+const RUST = /^native\/(resource-monitor|kde-snap-shot|hyprland-snap-shot)\//;
+
+// Tests that read another package's files without declaring it. The scripts
+// tests read app manifests, assets, and sources (cursor-sdk-packaging,
+// third-party-licenses, brand-assets, build-desktop-artifact).
+const TEST_ONLY_DEPS = {
+ "@t3tools/provider-pi": ["@t3tools/client-runtime"],
+ "@t3tools/scripts": [
+ "@t3tools/desktop",
+ "@t3tools/mobile",
+ "@t3tools/web",
+ "t3",
+ "@t3tools/provider-cursor",
+ ],
+};
+// Declared dependencies that only feed a build step: the server bundles the
+// built web app (apps/server/vite.config.ts) but never imports it.
+const BUILD_ONLY_DEPS = { t3: ["@t3tools/web"] };
+
+// Sources scripts/mobile-native-static-check.ts lints, plus the tool and rule
+// configuration that decides how it lints them, plus the root package.json
+// that defines the lint:mobile command.
+const MOBILE_NATIVE =
+ /^apps\/mobile\/.*\.(swift|kt|kts)$|^apps\/mobile\/(\.swiftlint\.yml|detekt\.yml|\.editorconfig|Brewfile)$|^scripts\/mobile-native-static-check\.ts$|^package\.json$|^\.github\/workflows\/ci\.yml$|^\.github\/scripts\/ci-changes\.cjs$|^\.github\/actions\/ci-changes\//;
+
+// Jobs that test every package except these, which have jobs of their own.
+const OWN_TEST_JOB = new Set(["t3", "@t3tools/web", "@t3tools/monorepo"]);
+
+function readWorkspace() {
+ const patterns = [];
+ let inPackages = false;
+ for (const line of fs.readFileSync(path.join(root, "pnpm-workspace.yaml"), "utf8").split("\n")) {
+ if (/^\S/.test(line)) inPackages = line.startsWith("packages:");
+ const entry = inPackages && line.match(/^\s+-\s+["']?([^"'\s]+)/);
+ if (entry) patterns.push(entry[1]);
+ }
+
+ const dirs = patterns.flatMap((pattern) => {
+ if (!pattern.endsWith("/*")) return [pattern];
+ const parent = pattern.slice(0, -2);
+ return fs.readdirSync(path.join(root, parent)).map((name) => `${parent}/${name}`);
+ });
+
+ const packages = [];
+ for (const dir of dirs) {
+ const manifestPath = path.join(root, dir, "package.json");
+ if (!fs.existsSync(manifestPath)) continue;
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
+ const deps = {
+ ...manifest.dependencies,
+ ...manifest.devDependencies,
+ ...manifest.peerDependencies,
+ };
+ packages.push({
+ name: manifest.name,
+ dir,
+ hasTest: Boolean(manifest.scripts?.test),
+ deps: Object.keys(deps).filter(
+ (dep) =>
+ String(deps[dep]).startsWith("workspace:") &&
+ !BUILD_ONLY_DEPS[manifest.name]?.includes(dep),
+ ),
+ });
+ }
+ return packages;
+}
+
+// Returns the packages a path touches, [] for an inert path, or null when the
+// path is not understood and everything must run.
+function ownersOf(file, packages) {
+ if (INERT.some((pattern) => pattern.test(file))) return [];
+ // A manifest can change dependencies or versions other packages read.
+ if (path.posix.basename(file) === "package.json") return null;
+ if (RUNS_EVERYTHING.some((pattern) => pattern.test(file))) return null;
+ // scripts/build-desktop-artifact.test.ts reads the crates' sources.
+ if (RUST.test(file)) return ["@t3tools/scripts"];
+
+ const extra = EXTRA_OWNERS.flatMap(([pattern, names]) => (pattern.test(file) ? names : []));
+ const owner = packages
+ .filter((pkg) => file.startsWith(`${pkg.dir}/`))
+ .sort((a, b) => b.dir.length - a.dir.length)[0];
+ if (owner) return [owner.name, ...extra];
+ return extra.length > 0 ? extra : null;
+}
+
+function decide(files, packages, full) {
+ const all = new Set(packages.map((pkg) => pkg.name));
+ let affected = new Set();
+ let everything = full || files === null;
+ let rust = false;
+
+ for (const file of files ?? []) {
+ if (RUST.test(file)) rust = true;
+ const owners = ownersOf(file, packages);
+ if (owners === null) {
+ everything = true;
+ console.error(`Runs everything: ${file}`);
+ } else {
+ for (const owner of owners) affected.add(owner);
+ }
+ }
+
+ // Release smoke reads scripts/ itself, not what the scripts tests read.
+ let scriptsChanged = everything;
+ if (everything) {
+ affected = all;
+ } else {
+ // Add dependents until nothing changes.
+ let grew = true;
+ while (grew) {
+ grew = false;
+ for (const pkg of packages) {
+ if (!affected.has(pkg.name) && pkg.deps.some((dep) => affected.has(dep))) {
+ affected.add(pkg.name);
+ grew = true;
+ }
+ }
+ }
+ scriptsChanged = affected.has("@t3tools/scripts");
+ for (const [name, deps] of Object.entries(TEST_ONLY_DEPS)) {
+ if (deps.some((dep) => affected.has(dep))) affected.add(name);
+ }
+ }
+
+ const tested = packages.filter(
+ (pkg) => pkg.hasTest && !OWN_TEST_JOB.has(pkg.name) && affected.has(pkg.name),
+ );
+ const has = (name) => affected.has(name);
+
+ return {
+ affected: [...affected].sort(),
+ outputs: {
+ typecheck: affected.size > 0,
+ build: has("@t3tools/desktop") || has("t3") || has("@t3tools/web"),
+ test: tested.length > 0,
+ // Empty means every package the Test job covers.
+ test_packages: everything ? "" : tested.map((pkg) => pkg.name).join(" "),
+ test_web: has("@t3tools/web"),
+ test_server: has("t3"),
+ rust: everything || rust,
+ release_smoke: scriptsChanged,
+ mobile_native: files === null || files.some((file) => MOBILE_NATIVE.test(file)),
+ },
+ };
+}
+
+function main() {
+ const args = process.argv.slice(2);
+ const pathsIndex = args.indexOf("--paths");
+ const files =
+ pathsIndex === -1
+ ? null
+ : fs
+ .readFileSync(args[pathsIndex + 1], "utf8")
+ .split("\n")
+ .filter(Boolean);
+ const { affected, outputs } = decide(files, readWorkspace(), args.includes("--full"));
+
+ console.error(`Affected packages: ${affected.join(", ") || "none"}`);
+ for (const [key, value] of Object.entries(outputs)) console.log(`${key}=${value}`);
+}
+
+main();
diff --git a/.github/scripts/thread-transfer-report.cjs b/.github/scripts/thread-transfer-report.cjs
index 264a92b1c8c..a85fec9ee04 100644
--- a/.github/scripts/thread-transfer-report.cjs
+++ b/.github/scripts/thread-transfer-report.cjs
@@ -278,6 +278,13 @@ async function resolve({ github, context, core }) {
const sourceArtifacts = await artifactsForRun(github, owner, repo, source.id);
const sourceArtifact = findResultArtifact(sourceArtifacts);
+ // CI requires the artifact whenever the server tests run, so a passing run
+ // without one skipped them because the PR cannot affect the server.
+ if (!sourceArtifact && source.conclusion === "success") {
+ core.info("CI skipped the server tests for this change; nothing to report.");
+ core.setOutput("publish", "false");
+ return;
+ }
const workflowRuns = await github.paginate(github.rest.actions.listWorkflowRuns, {
owner,
repo,
diff --git a/.github/scripts/thread-transfer-report.test.cjs b/.github/scripts/thread-transfer-report.test.cjs
index 3c8ab2578a5..5b1749fc53f 100644
--- a/.github/scripts/thread-transfer-report.test.cjs
+++ b/.github/scripts/thread-transfer-report.test.cjs
@@ -216,6 +216,48 @@ test("does not guess when a fallback commit belongs to multiple PRs", async () =
assert.equal(fetchedPull, false);
});
+test("does not report a passing run that skipped the server tests", async () => {
+ const outputs = {};
+ const listWorkflowRunArtifacts = () => {};
+ await resolve({
+ github: {
+ paginate: async (method) => {
+ assert.equal(method, listWorkflowRunArtifacts);
+ return [];
+ },
+ rest: {
+ actions: { listWorkflowRunArtifacts },
+ pulls: {
+ get: async () => ({
+ data: { head: { sha: "head-sha" }, base: { sha: "base-sha", ref: "main" } },
+ }),
+ },
+ },
+ },
+ context: {
+ repo: { owner: "pingdotgg", repo: "t3code" },
+ payload: {
+ workflow_run: {
+ id: 2,
+ event: "pull_request",
+ workflow_id: 3,
+ head_sha: "head-sha",
+ conclusion: "success",
+ pull_requests: [{ number: 5350 }],
+ },
+ },
+ },
+ core: {
+ info: () => {},
+ setOutput: (key, value) => {
+ outputs[key] = value;
+ },
+ },
+ });
+
+ assert.equal(outputs.publish, "false");
+});
+
test("does not publish a stale result after the PR head advances", async () => {
let listedComments = false;
const info = [];
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index c0bf0857254..8b38457876b 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -14,9 +14,50 @@ concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
+ # Skips jobs a pull request cannot affect: a web change does not run the
+ # server shards, a server change does not run the mobile tests, and the macOS
+ # lint (~6.7x a Linux minute) runs only for native mobile sources.
+ # .github/scripts/ci-changes.cjs maps changed files to workspace packages and
+ # their dependents. Pushes to main still run every Linux job. Detection fails
+ # open: if the diff cannot be resolved, everything runs.
+ changes:
+ name: Changes
+ runs-on: blacksmith-2vcpu-ubuntu-2404
+ timeout-minutes: 5
+ outputs:
+ typecheck: ${{ steps.detect.outputs.typecheck }}
+ build: ${{ steps.detect.outputs.build }}
+ test: ${{ steps.detect.outputs.test }}
+ test_packages: ${{ steps.detect.outputs.test_packages }}
+ test_web: ${{ steps.detect.outputs.test_web }}
+ test_server: ${{ steps.detect.outputs.test_server }}
+ rust: ${{ steps.detect.outputs.rust }}
+ release_smoke: ${{ steps.detect.outputs.release_smoke }}
+ mobile_native: ${{ steps.detect.outputs.mobile_native }}
+ steps:
+ # Only the package manifests the script reads to build the dependency graph.
+ # Depth 2 brings the base commit the change is diffed against.
+ - name: Checkout
+ uses: actions/checkout@v6
+ with:
+ fetch-depth: 2
+ sparse-checkout: |
+ /pnpm-workspace.yaml
+ /.github/scripts/ci-changes.cjs
+ /.github/actions/ci-changes/
+ /*/package.json
+ /*/*/package.json
+ !/.repos/
+ sparse-checkout-cone-mode: false
+
+ - name: Detect affected jobs
+ id: detect
+ uses: ./.github/actions/ci-changes
+
# Lint, typecheck, and the desktop build each get a runner so they run side by
- # side instead of one after another. The `Check` job at the end of this file
- # passes only when every other job does.
+ # side instead of one after another. Lint always runs: it formats every file,
+ # docs included. The `Check` job at the end of this file passes only when
+ # every other job passes or was skipped by `changes`.
lint:
name: Lint
runs-on: blacksmith-8vcpu-ubuntu-2404
@@ -60,6 +101,8 @@ jobs:
typecheck:
name: Typecheck
+ needs: changes
+ if: ${{ !cancelled() && needs.changes.outputs.typecheck != 'false' }}
runs-on: blacksmith-8vcpu-ubuntu-2404
timeout-minutes: 10
steps:
@@ -86,6 +129,8 @@ jobs:
build:
name: Build
+ needs: changes
+ if: ${{ !cancelled() && needs.changes.outputs.build != 'false' }}
runs-on: blacksmith-8vcpu-ubuntu-2404
timeout-minutes: 10
steps:
@@ -140,6 +185,8 @@ jobs:
# per runner is unchanged.
test:
name: Test
+ needs: changes
+ if: ${{ !cancelled() && needs.changes.outputs.test != 'false' }}
runs-on: blacksmith-8vcpu-ubuntu-2404
timeout-minutes: 10
steps:
@@ -197,13 +244,24 @@ jobs:
cat "$RUNNER_TEMP/apt.log"
exit "$(cat "$RUNNER_TEMP/apt-status")"
+ # `changes` lists the affected packages, or nothing when all of them are.
- name: Test
- run: vp run --parallel --concurrency-limit 4 --filter '!t3' --filter '!@t3tools/monorepo' --filter '!@t3tools/web' test
+ env:
+ TEST_PACKAGES: ${{ needs.changes.outputs.test_packages }}
+ run: |
+ filters=(--filter '!t3' --filter '!@t3tools/monorepo' --filter '!@t3tools/web')
+ if [[ -n "$TEST_PACKAGES" ]]; then
+ filters=()
+ for package in $TEST_PACKAGES; do filters+=(--filter "$package"); done
+ fi
+ vp run --parallel --concurrency-limit 4 "${filters[@]}" test
# The web suite is the largest outside the server. In the shared Test job it
# started last and ran alone for about 40s after everything else finished.
test_web:
name: Test Web
+ needs: changes
+ if: ${{ !cancelled() && needs.changes.outputs.test_web != 'false' }}
runs-on: blacksmith-8vcpu-ubuntu-2404
timeout-minutes: 10
steps:
@@ -231,6 +289,8 @@ jobs:
# isolation that flag buys is preserved exactly. One file at a time keeps
# about 1.5 cores busy, so 4 vCPU runners lose nothing against 8. The shards
# split files by recorded duration (apps/server/src/testUtils/weightedShardSequencer.ts).
+ # The shards are the longest jobs, so they gate themselves instead of waiting
+ # ~15s for `changes`: a shard the change cannot affect stops after checkout.
test_server:
name: Test Server ${{ matrix.shard }}
runs-on: blacksmith-4vcpu-ubuntu-2404
@@ -240,15 +300,22 @@ jobs:
matrix:
shard: [1, 2, 3, 4, 5, 6]
steps:
+ # Depth 2 brings the base commit the change is diffed against.
- name: Checkout
uses: actions/checkout@v6
with:
+ fetch-depth: 2
sparse-checkout: |
/*
!/.repos/
sparse-checkout-cone-mode: false
+ - name: Detect affected jobs
+ id: changes
+ uses: ./.github/actions/ci-changes
+
- name: Setup Vite+
+ if: steps.changes.outputs.test_server != 'false'
uses: voidzero-dev/setup-vp@v1
with:
node-version-file: package.json
@@ -259,9 +326,11 @@ jobs:
# and none of its tests touch the runtime. Only the non-server `test`
# job, which covers @t3tools/desktop, needs the download.
- name: Install Chromium for server browser integration tests
+ if: steps.changes.outputs.test_server != 'false'
run: node apps/server/node_modules/playwright-core/cli.js install --with-deps --only-shell chromium
- name: Test
+ if: steps.changes.outputs.test_server != 'false'
env:
T3CODE_TRANSFER_BUDGET_REPORT_PATH: ${{ runner.temp }}/t3code-transfer-budget.md
T3CODE_TRANSFER_BUDGET_RESULT_PATH: ${{ runner.temp }}/thread-transfer-result.json
@@ -301,7 +370,8 @@ jobs:
transfer-report:
name: Transfer report artifact
- needs: test_server
+ needs: [changes, test_server]
+ if: needs.changes.outputs.test_server != 'false'
# On Blacksmith like every other job here: the GitHub-hosted queue is shared
# with the PR bots and can leave this job waiting until it is abandoned,
# which fails `Check` on an otherwise green run.
@@ -318,6 +388,8 @@ jobs:
# for checks that take under 3s, on the critical path of every PR.
rust:
name: Rust
+ needs: changes
+ if: ${{ !cancelled() && needs.changes.outputs.rust != 'false' }}
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 10
steps:
@@ -346,90 +418,10 @@ jobs:
cargo test --locked --manifest-path "native/$crate/Cargo.toml"
done
- # The static analysis below needs a macOS runner, which bills ~6.7x a Linux
- # minute, so gate it on the native sources it actually lints instead of paying
- # for it on every push. Detection is API-only (no checkout) and fails open: if
- # the diff cannot be resolved, the lint runs.
- mobile_native_changes:
- name: Mobile Native Changes
- runs-on: blacksmith-2vcpu-ubuntu-2404
- timeout-minutes: 5
- permissions:
- contents: read
- pull-requests: read
- outputs:
- changed: ${{ steps.detect.outputs.changed }}
- steps:
- - name: Detect mobile native changes
- id: detect
- env:
- GH_TOKEN: ${{ github.token }}
- PR_NUMBER: ${{ github.event.pull_request.number }}
- BEFORE_SHA: ${{ github.event.before }}
- run: |
- set -uo pipefail
-
- fail_open() {
- echo "$* Running native static analysis."
- echo "changed=true" >> "$GITHUB_OUTPUT"
- exit 0
- }
-
- count_rows() {
- printf '%s\n' "$1" | grep -c . || true
- }
-
- # One row per changed file, holding the new path and, for a rename,
- # the path it replaced: renaming a matched file out of the matched
- # paths removes a lint input just like editing it.
- row='[.filename, (.previous_filename // empty)] | @tsv'
-
- if [[ -n "${PR_NUMBER}" ]]; then
- # The PR files endpoint stops at 3000 files and pagination cannot
- # extend it, so cross-check against the count the PR itself reports.
- expected=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" --jq '.changed_files') \
- || fail_open "Could not read the pull request."
- rows=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/files" --paginate --jq ".[] | ${row}") \
- || fail_open "Could not resolve changed files."
-
- listed=$(count_rows "$rows")
- if [[ "$listed" -lt "$expected" ]]; then
- fail_open "GitHub listed only ${listed} of ${expected} changed files."
- fi
- else
- rows=$(gh api "repos/${GITHUB_REPOSITORY}/compare/${BEFORE_SHA}...${GITHUB_SHA}" --jq ".files[]? | ${row}") \
- || fail_open "Could not resolve changed files."
-
- # The compare endpoint reports at most 300 files and pagination does
- # not extend that list, so a full list may be hiding native changes.
- listed=$(count_rows "$rows")
- if [[ "$listed" -ge 300 ]]; then
- fail_open "GitHub listed ${listed} changed files, the compare endpoint maximum."
- fi
- fi
-
- paths=$(tr '\t' '\n' <<< "$rows")
-
- # Sources scripts/mobile-native-static-check.ts lints, plus the tool
- # and rule configuration that decides how it lints them, plus the
- # root package.json that defines the lint:mobile command.
- pattern='^apps/mobile/.*\.(swift|kt|kts)$|^apps/mobile/(\.swiftlint\.yml|detekt\.yml|\.editorconfig|Brewfile)$|^scripts/mobile-native-static-check\.ts$|^package\.json$|^\.github/workflows/ci\.yml$'
-
- if grep -qE "$pattern" <<< "$paths"; then
- echo "Native sources or lint configuration changed:"
- grep -E "$pattern" <<< "$paths"
- echo "changed=true" >> "$GITHUB_OUTPUT"
- else
- echo "No mobile native sources or lint configuration changed."
- echo "changed=false" >> "$GITHUB_OUTPUT"
- fi
-
mobile_native_static_analysis:
name: Mobile Native Static Analysis
- needs: mobile_native_changes
- # Skip only on an explicit "no": a gate job that failed or errored leaves the
- # output empty, and that must run the lint rather than silently skip it.
- if: ${{ !cancelled() && needs.mobile_native_changes.outputs.changed != 'false' }}
+ needs: changes
+ if: ${{ !cancelled() && needs.changes.outputs.mobile_native != 'false' }}
runs-on: blacksmith-6vcpu-macos-26
timeout-minutes: 10
steps:
@@ -458,6 +450,8 @@ jobs:
release_smoke:
name: Release Smoke
+ needs: changes
+ if: ${{ !cancelled() && needs.changes.outputs.release_smoke != 'false' }}
runs-on: blacksmith-8vcpu-ubuntu-2404
timeout-minutes: 10
steps:
@@ -491,6 +485,7 @@ jobs:
if: ${{ always() }}
needs:
[
+ changes,
lint,
typecheck,
build,
@@ -499,7 +494,6 @@ jobs:
test_server,
transfer-report,
rust,
- mobile_native_changes,
mobile_native_static_analysis,
release_smoke,
]
@@ -511,7 +505,10 @@ jobs:
RESULTS: ${{ toJSON(needs) }}
run: |
echo "$RESULTS" | jq -r 'to_entries[] | "\(.key): \(.value.result)"'
- # Only the macOS lint skips on purpose, when no native mobile code changed.
- echo "$RESULTS" | jq -e 'all(to_entries[];
- .value.result == "success"
- or (.key == "mobile_native_static_analysis" and .value.result == "skipped"))' > /dev/null
+ # A job may skip only when `changes` said it was not needed. Gates are
+ # keyed by job name, except the macOS lint and the transfer report.
+ echo "$RESULTS" | jq -e '.changes.outputs as $gates
+ | {mobile_native_static_analysis: "mobile_native", "transfer-report": "test_server"} as $renamed
+ | all(to_entries[];
+ .value.result == "success"
+ or (.value.result == "skipped" and $gates[$renamed[.key] // .key] == "false"))' > /dev/null