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(android): require version bumps in pull requests (#8044)

Peter Chinman784f05bfdfd5
diff --git a/.github/workflows/web-app-check-main.yml b/.github/workflows/web-app-check-main.yml
index e5aaa0d7bd..3c4ca73d13 100644
--- a/.github/workflows/web-app-check-main.yml
+++ b/.github/workflows/web-app-check-main.yml
@@ -55,6 +55,27 @@ jobs:
- 'packages/sdk/**'
- 'apps/docs/**'
- '.github/actions/setup-reqs-web/**'
+ android-version:
+ name: Android Version Code
+ runs-on: namespace-profile-linux-tiny-no-cache
+ permissions:
+ contents: read
+ steps:
+ - name: Checkout PR merge commit
+ uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
+ - name: Setup Bun
+ uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6
+ with:
+ bun-version: '1.3.13'
+ - name: Require an Android version bump for native changes
+ run: |
+ set -euo pipefail
+ git fetch -q --depth=1 origin "$BASE_SHA"
+ bun scripts/android-version-check.mjs "$BASE_SHA"
+ shell: bash
+ env:
+ BASE_SHA: ${{ github.event.pull_request.base.sha }}
+ working-directory: apps/web
typescript:
needs:
- path-check
@@ -594,6 +615,7 @@ jobs:
status-check:
needs:
- path-check
+ - android-version
- typescript
- generated-code
- biome-check
@@ -608,6 +630,7 @@ jobs:
- name: Check job results
run: |
echo "path-check: ${{ needs.path-check.result }}"
+ echo "android-version: ${{ needs.android-version.result }}"
echo "typescript: ${{ needs.typescript.result }}"
echo "generated-code: ${{ needs.generated-code.result }}"
echo "biome-check: ${{ needs.biome-check.result }}"
@@ -618,7 +641,8 @@ jobs:
# Fail if any job failed (skipped and success are both OK). The iOS
# gate is the merge gate, so a cancelled gate is not OK either.
- if [[ "${{ needs.path-check.result }}" == "failure" ]] || \
+ if [[ "${{ needs.android-version.result }}" != "success" ]] || \
+ [[ "${{ needs.path-check.result }}" == "failure" ]] || \
[[ "${{ needs.typescript.result }}" == "failure" ]] || \
[[ "${{ needs.generated-code.result }}" == "failure" ]] || \
[[ "${{ needs.biome-check.result }}" == "failure" ]] || \
diff --git a/apps/web/scripts/android-native.mjs b/apps/web/scripts/android-native.mjs
new file mode 100644
index 0000000000..76fbfecc49
--- /dev/null
+++ b/apps/web/scripts/android-native.mjs
@@ -0,0 +1,95 @@
+// What "the Android native code" is, shared by the PR-time version check
+// (android-version-check.mjs) and the release-time build decision
+// (android-release-needed.mjs) so the two can never disagree: a PR that
+// passes the gate must not fail the release for the same question.
+//
+// It is every tracked file under apps/web/tauri except what never reaches
+// the Android binary — iOS, macOS, Linux, Windows and desktop-only paths by
+// naming convention (a path component or extension naming the platform, the
+// generated Xcode project under gen/apple, the desktop updater manifest,
+// editor config) — plus one thing outside that tree: the version of the
+// client cache wasm package. The app compiles the cache crates natively, and
+// the team bumps that version when a cache change must ship, so the bump
+// counts as a native change while other edits under crates/client do not.
+// The iOS gate (tooling/xtask/.../scripts/ios_native_tree.sh) is the mirror
+// image, excluding Android-only paths instead.
+
+import { execFileSync } from 'node:child_process';
+
+export const tauriPath = 'apps/web/tauri';
+export const cacheWasmManifest = 'crates/client/cache-wasm/Cargo.toml';
+export const androidExclude =
+ /(^|\/)(ios|macos|linux|windows|apple|desktop)([_./-]|$)|\.(ios|macos|linux|windows)\.|^desktop-release\.json$|^\.helix\//;
+
+/// A `git` runner bound to a working directory.
+export function gitIn(cwd) {
+ return (args, input) =>
+ execFileSync('git', args, {
+ cwd,
+ encoding: 'utf8',
+ input,
+ maxBuffer: 64 * 1024 * 1024,
+ stdio: [input === undefined ? 'ignore' : 'pipe', 'pipe', 'pipe'],
+ }).trim();
+}
+
+/// The `version` of the client cache wasm package at a commit ("none" before
+/// the package existed).
+export function cacheWasmVersion(git, commit) {
+ try {
+ return (
+ git(['show', `${commit}:${cacheWasmManifest}`]).match(
+ /^version\s*=\s*"([^"]*)"/m
+ )?.[1] ?? 'none'
+ );
+ } catch {
+ return 'none';
+ }
+}
+
+/// The Android-relevant part of the Tauri tree at a commit: `git ls-tree -r`
+/// lines (mode, type, blob, path relative to apps/web/tauri) minus the
+/// excluded paths. Hashable and diffable.
+export function androidTreeListing(git, commit) {
+ return git(['ls-tree', '-r', '--full-tree', `${commit}:${tauriPath}`])
+ .split('\n')
+ .filter((line) => line && !androidExclude.test(line.split('\t')[1]));
+}
+
+/// One hash for "the Android native code" at a commit: the listing above
+/// plus the cache wasm version. Equal hashes mean no native change.
+export function androidNativeHash(git, commit) {
+ const content = [
+ ...androidTreeListing(git, commit),
+ `cache-wasm-version ${cacheWasmVersion(git, commit)}`,
+ ].join('\n');
+ return git(['hash-object', '--stdin'], `${content}\n`);
+}
+
+/// Why two commits differ, for messages: which of the two signals moved.
+export function androidChangeReasons(git, from, to) {
+ const reasons = [];
+ if (
+ androidTreeListing(git, from).join('\n') !==
+ androidTreeListing(git, to).join('\n')
+ )
+ reasons.push(`Android-relevant files under ${tauriPath}/ changed`);
+ const before = cacheWasmVersion(git, from);
+ const after = cacheWasmVersion(git, to);
+ if (before !== after)
+ reasons.push(
+ `the client cache wasm version moved (${before} → ${after})`
+ );
+ return reasons;
+}
+
+/// The Android versionCode committed at a commit, validated.
+export function androidVersionCode(git, commit) {
+ const config = JSON.parse(
+ git(['show', `${commit}:${tauriPath}/src-tauri/tauri.android.conf.json`])
+ );
+ const code = config.bundle?.android?.versionCode;
+ if (!Number.isInteger(code) || code < 1 || code > 2_100_000_000)
+ throw new Error(`Invalid Android versionCode at ${commit}`);
+ return code;
+}
diff --git a/apps/web/scripts/android-release-needed.mjs b/apps/web/scripts/android-release-needed.mjs
index 38e084abe7..7fe549b8be 100644
--- a/apps/web/scripts/android-release-needed.mjs
+++ b/apps/web/scripts/android-release-needed.mjs
@@ -1,35 +1,20 @@
-import { execFileSync } from 'node:child_process';
import { appendFile } from 'node:fs/promises';
+import { execFileSync } from 'node:child_process';
import { resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
+import {
+ androidChangeReasons,
+ androidNativeHash,
+ androidVersionCode,
+ gitIn,
+ tauriPath,
+} from './android-native.mjs';
-const tauriPath = 'apps/web/tauri';
-// The app compiles the client cache crates natively; the team bumps this
-// package's version when a cache change must ship, so a bump counts as a
-// native change (other edits under crates/client do not).
-const cacheWasmManifest = 'crates/client/cache-wasm/Cargo.toml';
const releaseTag = /^v20\d{2}\.\d{1,2}\.\d{1,2}(?:\.\d{1,2})?$/;
export function androidReleaseDecision({ releases, cwd = process.cwd() }) {
- const git = (...args) =>
- execFileSync('git', args, {
- cwd,
- encoding: 'utf8',
- maxBuffer: 64 * 1024 * 1024,
- }).trim();
- const head = git('rev-parse', '--verify', 'HEAD^{commit}');
- const tree = git('rev-parse', '--verify', `${head}:${tauriPath}`);
- const cacheWasmVersion = (commit) => {
- try {
- return (
- git('show', `${commit}:${cacheWasmManifest}`).match(
- /^version\s*=\s*"([^"]*)"/m
- )?.[1] ?? 'none'
- );
- } catch {
- return 'none'; // the package did not exist at this commit
- }
- };
+ const git = gitIn(cwd);
+ const head = git(['rev-parse', '--verify', 'HEAD^{commit}']);
const candidates = new Map();
for (const release of releases) {
const tag = release.tag_name;
@@ -47,13 +32,13 @@ export function androidReleaseDecision({ releases, cwd = process.cwd() }) {
)
continue;
// Missing tags/history must fail, rather than silently reuse a version code.
- const commit = git('rev-parse', '--verify', `refs/tags/${tag}^{commit}`);
+ const commit = git(['rev-parse', '--verify', `refs/tags/${tag}^{commit}`]);
candidates.set(commit, tag);
}
// API release ordering can differ from commit order. Only consider ancestors
// of this release, and prefer the closest one in topological history order.
- const baseline = git('rev-list', '--topo-order', head)
+ const baseline = git(['rev-list', '--topo-order', head])
.split('\n')
.find((commit) => candidates.has(commit));
if (!baseline) {
@@ -64,35 +49,14 @@ export function androidReleaseDecision({ releases, cwd = process.cwd() }) {
};
}
const tag = candidates.get(baseline);
- const tauriChanged =
- tree !== git('rev-parse', '--verify', `${baseline}:${tauriPath}`);
- const cacheBumped = cacheWasmVersion(head) !== cacheWasmVersion(baseline);
- if (!tauriChanged && !cacheBumped) {
+ if (androidNativeHash(git, head) === androidNativeHash(git, baseline)) {
return {
build: false,
- summary: `Skip Android: ${tauriPath}/ and the client cache wasm version are unchanged since ${tag}. App updates use the bundle updater.`,
+ summary: `Skip Android: the Android native code (${tauriPath}/ and the client cache wasm version) is unchanged since ${tag}. App updates use the bundle updater.`,
};
}
- // The version code bump itself lives under the Tauri directory, so name
- // the cache bump too when that is what the release is really for.
- const reason = [
- tauriChanged && `${tauriPath}/ changed since ${tag}`,
- cacheBumped &&
- `the client cache wasm version moved since ${tag} (${cacheWasmVersion(baseline)} → ${cacheWasmVersion(head)})`,
- ]
- .filter(Boolean)
- .join(' and ');
-
- const versionCode = (commit) => {
- const config = JSON.parse(
- git('show', `${commit}:${tauriPath}/src-tauri/tauri.android.conf.json`)
- );
- const code = config.bundle?.android?.versionCode;
- if (!Number.isInteger(code) || code < 1 || code > 2_100_000_000)
- throw new Error(`Invalid Android versionCode at ${commit}`);
- return code;
- };
- if (versionCode(head) <= versionCode(baseline)) {
+ const reason = `${androidChangeReasons(git, baseline, head).join(' and ')} since ${tag}`;
+ if (androidVersionCode(git, head) <= androidVersionCode(git, baseline)) {
throw new Error(
`Native code changed (${reason}), but Android versionCode did not increase. Run just android-bump in apps/web and commit before tagging.`
);
diff --git a/apps/web/scripts/android-release-needed.test.ts b/apps/web/scripts/android-release-needed.test.ts
index 6a559cac02..b389d29648 100644
--- a/apps/web/scripts/android-release-needed.test.ts
+++ b/apps/web/scripts/android-release-needed.test.ts
@@ -4,6 +4,7 @@ import { tmpdir } from 'node:os';
import { dirname, join } from 'node:path';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { androidReleaseDecision } from './android-release-needed.mjs';
+import { checkAndroidVersion } from './android-version-check.mjs';
const nativeConfig = 'apps/web/tauri/src-tauri/tauri.android.conf.json';
let cwd: string;
@@ -62,6 +63,146 @@ beforeEach(() => {
afterEach(() => rmSync(cwd, { recursive: true, force: true }));
+describe('PR Android version enforcement', () => {
+ it('passes frontend-only and backend-only changes without a bump', () => {
+ const base = git('rev-parse', 'HEAD');
+ write('apps/web/src/index.tsx', '// frontend');
+ write('services/example/src/lib.rs', '// backend');
+ commit();
+ expect(checkAndroidVersion({ cwd, base })).toContain('No Android native changes');
+ });
+
+ it.each(['modify', 'add', 'delete', 'rename'])(
+ 'rejects a native %s without a bump',
+ (change) => {
+ const base = git('rev-parse', 'HEAD');
+ const path = 'apps/web/tauri/src-tauri/src/lib.rs';
+ if (change === 'modify') write(path, '// changed');
+ if (change === 'add') write('apps/web/tauri/src-tauri/new-file', 'new');
+ if (change === 'delete') rmSync(join(cwd, path));
+ if (change === 'rename') git('mv', path, `${path}.renamed`);
+ commit();
+ expect(() => checkAndroidVersion({ cwd, base })).toThrow(
+ /just android-bump/
+ );
+ }
+ );
+
+ it('accepts native changes with a higher version code', () => {
+ const base = git('rev-parse', 'HEAD');
+ write('apps/web/tauri/src-tauri/src/lib.rs', '// changed');
+ version(2);
+ commit();
+ expect(checkAndroidVersion({ cwd, base })).toContain('from 1 to 2');
+ });
+
+ it.each([0, 1.5, 2_100_000_001])(
+ 'rejects invalid version code %s',
+ (code) => {
+ const base = git('rev-parse', 'HEAD');
+ version(code);
+ commit();
+ expect(() => checkAndroidVersion({ cwd, base })).toThrow(
+ /Invalid Android versionCode/
+ );
+ }
+ );
+
+ it('rejects a version downgrade', () => {
+ version(3);
+ commit();
+ const base = git('rev-parse', 'HEAD');
+ version(2);
+ commit();
+ expect(() => checkAndroidVersion({ cwd, base })).toThrow(/must exceed/);
+ });
+
+ it('rejects two PRs trying to use the same version code', () => {
+ git('checkout', '-b', 'pr');
+ version(2);
+ write('apps/web/tauri/first-native-change', 'PR change');
+ commit();
+ git('checkout', 'main');
+ version(2);
+ write('apps/web/tauri/second-native-change', 'Already merged');
+ commit();
+ const base = git('rev-parse', 'HEAD');
+ git('merge', '--no-ff', 'pr', '-m', 'PR merge result');
+ expect(() => checkAndroidVersion({ cwd, base })).toThrow(
+ /base branch \(2\)/
+ );
+ });
+
+ it('does not attribute newer base-branch native changes to a frontend-only PR', () => {
+ git('checkout', '-b', 'pr');
+ write('apps/web/src/index.tsx', '// frontend');
+ commit();
+ git('checkout', 'main');
+ version(2);
+ commit();
+ const base = git('rev-parse', 'HEAD');
+ git('merge', '--no-ff', 'pr', '-m', 'PR merge result');
+ expect(checkAndroidVersion({ cwd, base })).toContain('No Android native changes');
+ });
+
+ it.each([
+ 'apps/web/tauri/src-tauri/gen/apple/project.yml',
+ 'apps/web/tauri/src-tauri/Info.ios.plist',
+ 'apps/web/tauri/callkit_plugin/ios/Sources/CallKitPlugin.swift',
+ 'apps/web/tauri/src-tauri/icons/macos/Macro.icon/icon.json',
+ 'apps/web/tauri/src-tauri/tauri.macos.conf.json',
+ 'apps/web/tauri/src-tauri/src/linux_notification.rs',
+ 'apps/web/tauri/desktop-release.json',
+ ])('ignores the iOS/desktop-only path %s', (path) => {
+ const base = git('rev-parse', 'HEAD');
+ write(path, 'changed');
+ commit();
+ expect(checkAndroidVersion({ cwd, base })).toContain(
+ 'No Android native changes'
+ );
+ });
+
+ it('requires a bump when the client cache wasm version moves', () => {
+ write(
+ 'crates/client/cache-wasm/Cargo.toml',
+ '[package]\nname = "cache-wasm"\nversion = "0.6.1"\n'
+ );
+ commit();
+ const base = git('rev-parse', 'HEAD');
+ write(
+ 'crates/client/cache-wasm/Cargo.toml',
+ '[package]\nname = "cache-wasm"\nversion = "0.6.2"\n'
+ );
+ write('crates/client/cache-core/src/lib.rs', '// cache change');
+ commit();
+ expect(() => checkAndroidVersion({ cwd, base })).toThrow(
+ /cache wasm version moved \(0\.6\.1 → 0\.6\.2\).*just android-bump/
+ );
+ version(2);
+ commit();
+ expect(checkAndroidVersion({ cwd, base })).toContain('from 1 to 2');
+ });
+
+ it('does not require a bump for client cache edits without a version bump', () => {
+ write(
+ 'crates/client/cache-wasm/Cargo.toml',
+ '[package]\nname = "cache-wasm"\nversion = "0.6.1"\n'
+ );
+ commit();
+ const base = git('rev-parse', 'HEAD');
+ write('crates/client/cache-core/src/lib.rs', '// cache change');
+ write('crates/client/cache-wasm/Cargo.toml', '[package]\nname = "cache-wasm"\nversion = "0.6.1"\n[dependencies]\nx = "1"\n');
+ commit();
+ expect(checkAndroidVersion({ cwd, base })).toContain(
+ 'No Android native changes'
+ );
+ });
+
+ it('fails closed if the base commit is unavailable', () => {
+ expect(() => checkAndroidVersion({ cwd, base: 'missing-base' })).toThrow();
+ });
+});
+
describe('native release detection', () => {
it('builds the first AAB when no complete ancestor bundle exists', () => {
expect(androidReleaseDecision({ cwd, releases: [] }).build).toBe(true);
@@ -125,7 +266,7 @@ describe('native release detection', () => {
expect(androidReleaseDecision({ cwd, releases: [baseline] })).toEqual({
build: true,
summary: expect.stringContaining(
- 'the client cache wasm version moved since v2026.10.1 (0.6.1 → 0.6.2)'
+ 'the client cache wasm version moved (0.6.1 → 0.6.2) since v2026.10.1'
),
});
});
diff --git a/apps/web/scripts/android-version-check.mjs b/apps/web/scripts/android-version-check.mjs
new file mode 100644
index 0000000000..1aaeeaacbc
--- /dev/null
+++ b/apps/web/scripts/android-version-check.mjs
@@ -0,0 +1,61 @@
+// PR-time gate: a PR whose merge result changes the Android native code (as
+// defined in android-native.mjs) must bump the Android versionCode above the
+// base branch. The release workflow applies the same definition when it
+// decides whether a production release needs a new App Bundle; catching a
+// missing bump here keeps it from failing there, after the deploy.
+import { resolve } from 'node:path';
+import { pathToFileURL } from 'node:url';
+import {
+ androidChangeReasons,
+ androidNativeHash,
+ androidVersionCode,
+ gitIn,
+} from './android-native.mjs';
+
+export function checkAndroidVersion({
+ base,
+ head = 'HEAD',
+ cwd = process.cwd(),
+}) {
+ if (!base) throw new Error('Provide the PR base commit');
+ const git = gitIn(cwd);
+ const baseCommit = git([
+ 'rev-parse',
+ '--verify',
+ '--end-of-options',
+ `${base}^{commit}`,
+ ]);
+ const headCommit = git([
+ 'rev-parse',
+ '--verify',
+ '--end-of-options',
+ `${head}^{commit}`,
+ ]);
+ if (androidNativeHash(git, baseCommit) === androidNativeHash(git, headCommit))
+ return 'No Android native changes; no Android version bump needed.';
+
+ const reason = androidChangeReasons(git, baseCommit, headCommit).join(
+ ' and '
+ );
+ const previous = androidVersionCode(git, baseCommit);
+ const next = androidVersionCode(git, headCommit);
+ if (next <= previous)
+ throw new Error(
+ `${reason}, but Android versionCode (${next}) must exceed the base branch (${previous}). Run just android-bump in apps/web and commit the result before merging.`
+ );
+ return `${reason}; Android versionCode increased from ${previous} to ${next}.`;
+}
+
+if (
+ process.argv[1] &&
+ import.meta.url === pathToFileURL(resolve(process.argv[1])).href
+) {
+ try {
+ console.log(checkAndroidVersion({ base: process.argv[2] }));
+ } catch (error) {
+ console.error(
+ error instanceof Error ? error.message : 'Android version check failed'
+ );
+ process.exitCode = 1;
+ }
+}
diff --git a/docs/development/android.md b/docs/development/android.md
index f42bc05605..6e175ec8df 100644
--- a/docs/development/android.md
+++ b/docs/development/android.md
@@ -185,8 +185,19 @@ just android-bump
Commit the changed config before tagging the release. This increments only
`versionCode`; edit `version` separately when changing the marketing version.
-CI rejects native changes whose code is not greater than the last published AAB
-baseline. No version bump is needed for frontend-only bundle updates.
+The PR's **Android Version Code** check compares its merged result with the base
+branch and requires a higher code when the Android native code changed: any
+file under `apps/web/tauri/` except iOS-, macOS-, Linux- and desktop-only
+paths by naming convention (`ios/` directories, `gen/apple/`, `*.ios.*` and
+`*.macos.*` config, `macos_*`/`linux_*` sources, the macOS icon set,
+`desktop-release.json`, `.helix/`), or a bump of the client cache wasm
+version. It feeds the required **Web App Status Check**, so a missing bump
+blocks merging. If another PR has already used your proposed code, update
+your branch and bump again. The release workflow applies the same definition
+(both read `apps/web/scripts/android-native.mjs`) and rejects native changes
+whose code is not greater than the last published AAB baseline, so a PR that
+passes the check cannot fail the release for the same reason. No version
+bump is needed for frontend-only, backend-only, or iOS/desktop-only changes.
Builds never increment the counter implicitly, so retries of the same release
retain its identity. Never distribute different releases with the same code or
reuse a code already uploaded to Google Play. Keep the signing key for upgrades.
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 c036b6782c..3da8e4addf 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,7 +2,8 @@
//! Generated into `web-app-check-main.yml`.
use gh_workflow::{
- Concurrency, Event, Expression, Job, PullRequest, PullRequestType, Run, Step, Use, Workflow,
+ Concurrency, Event, Expression, Job, Level, Permissions, PullRequest, PullRequestType, Run,
+ Step, Use, Workflow,
};
use crate::workflows::{
@@ -48,6 +49,7 @@ pub fn web_app_check_main() -> Workflow {
.cancel_in_progress(true),
)
.add_job("path-check", path_check())
+ .add_job("android-version", android_version())
.add_job("typescript", typescript())
.add_job("generated-code", generated_code())
.add_job("biome-check", biome_check())
@@ -58,6 +60,37 @@ pub fn web_app_check_main() -> Workflow {
.add_job("status-check", status_check())
}
+/// Always run so the required collector can distinguish a successful native
+/// check from a cancelled or skipped one, including frontend/backend-only PRs.
+fn android_version() -> Job {
+ Job::default()
+ .name("Android Version Code")
+ .runs_on(runners::Runner::TinyNoCache.to_string())
+ .permissions(Permissions::default().contents(Level::Read))
+ // Shallow: only the merge result and the base commit are needed.
+ .add_step(checkout("Checkout PR merge commit", false))
+ .add_step(
+ Step::new("Setup Bun")
+ .uses(
+ "oven-sh",
+ "setup-bun",
+ "0c5077e51419868618aeaa5fe8019c62421857d6",
+ ) // v2.2.0
+ .add_with(("bun-version", "1.3.13")),
+ )
+ .add_step(
+ Step::new("Require an Android version bump for native changes")
+ .run(indoc::indoc! {r#"
+ set -euo pipefail
+ git fetch -q --depth=1 origin "$BASE_SHA"
+ bun scripts/android-version-check.mjs "$BASE_SHA"
+ "#})
+ .shell("bash")
+ .working_directory(xtask_paths::repo_dir!("apps/web"))
+ .add_env(("BASE_SHA", "${{ github.event.pull_request.base.sha }}")),
+ )
+}
+
fn path_check() -> Job {
Job::default()
.runs_on(runners::Runner::TinyNoCache.to_string())
@@ -206,6 +239,7 @@ fn status_check() -> Job {
.cond(Expression::new("always()"))
.needs(vec![
"path-check".to_string(),
+ "android-version".to_string(),
"typescript".to_string(),
"generated-code".to_string(),
"biome-check".to_string(),
@@ -438,6 +472,7 @@ fn run_build() -> Step<Run> {
fn check_job_results() -> Step<Run> {
Step::new("Check job results").run(indoc::indoc! {r#"
echo "path-check: ${{ needs.path-check.result }}"
+ echo "android-version: ${{ needs.android-version.result }}"
echo "typescript: ${{ needs.typescript.result }}"
echo "generated-code: ${{ needs.generated-code.result }}"
echo "biome-check: ${{ needs.biome-check.result }}"
@@ -448,7 +483,8 @@ fn check_job_results() -> Step<Run> {
# Fail if any job failed (skipped and success are both OK). The iOS
# gate is the merge gate, so a cancelled gate is not OK either.
- if [[ "${{ needs.path-check.result }}" == "failure" ]] || \
+ if [[ "${{ needs.android-version.result }}" != "success" ]] || \
+ [[ "${{ needs.path-check.result }}" == "failure" ]] || \
[[ "${{ needs.typescript.result }}" == "failure" ]] || \
[[ "${{ needs.generated-code.result }}" == "failure" ]] || \
[[ "${{ needs.biome-check.result }}" == "failure" ]] || \
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/test.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/test.rs
index b4843bff8b..146d975bf6 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/test.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/test.rs
@@ -1,5 +1,28 @@
use super::*;
+#[test]
+fn android_version_is_an_unconditional_required_merge_check() {
+ let yaml = web_app_check_main().to_string().expect("workflow yaml");
+ let android = job(&yaml, "android-version", "typescript");
+ assert!(
+ !android.contains("if:"),
+ "native enforcement must always run"
+ );
+ assert!(
+ !android.contains("fetch-depth"),
+ "shallow checkout; the base commit is fetched by the step: {android}"
+ );
+ assert!(android.contains("github.event.pull_request.base.sha"));
+ assert!(android.contains("git fetch -q --depth=1 origin \"$BASE_SHA\""));
+ assert!(android.contains("bun scripts/android-version-check.mjs"));
+ let status = yaml
+ .split("\n status-check:\n")
+ .nth(1)
+ .expect("status job");
+ assert!(status.contains("- android-version"));
+ assert!(status.contains("needs.android-version.result }}\" != \"success\""));
+}
+
fn filters(yaml: &str) -> (&str, &str) {
let filters = yaml
.split("filters: |")