@invarn/cibuild 2.2.6 → 2.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,37 @@
1
+ export interface PackageFile {
2
+ /** POSIX, package-relative path. Part of the digest so a rename is a change. */
3
+ path: string;
4
+ /** File contents. */
5
+ bytes: Buffer;
6
+ }
7
+ /**
8
+ * Compute the input digest for one render package: its source files plus the
9
+ * reference image the screen is judged against. Files are folded in sorted by
10
+ * path so iteration order can't affect the result; each is folded in as its git
11
+ * blob id (see the module header) so the digest is reproducible from a Git Trees
12
+ * listing with no blob content. The path is length-prefixed and the blob id is
13
+ * fixed-width, so boundaries are unambiguous.
14
+ */
15
+ export declare function sourceDigest(packageFiles: PackageFile[], referenceBytes: Buffer | null): string;
16
+ /**
17
+ * True when a render package is self-contained — no Gradle script reaches
18
+ * outside the package root. Render packages are hermetic by construction; this
19
+ * guard fails a non-hermetic package OUT of the cacheable set (its digest is not
20
+ * emitted / not trusted for skip) so a change in an external module it depends
21
+ * on can never replay a stale verdict. Pure: a function of the package files
22
+ * only, so a dispatch-time caller can apply the identical check.
23
+ */
24
+ export declare function isHermeticPackage(packageFiles: PackageFile[]): boolean;
25
+ /**
26
+ * Runtime twin of {@link sourceDigest}, spliced into the self-contained render
27
+ * script that runs on the macOS runner (which cannot import this module). It
28
+ * walks the built package directory, reads the paired reference, and computes
29
+ * the identical digest — a parity test pins it to `sourceDigest` so the twin
30
+ * cannot drift.
31
+ *
32
+ * Exposes `computeSourceDigest(projectRoot, referencePath)`. Build outputs and
33
+ * VCS/tooling dirs are excluded so they never perturb the content key. Reads
34
+ * are best-effort: an unreadable reference folds in as "absent", never throws.
35
+ */
36
+ export declare const RENDER_SCRIPT_SOURCE_DIGEST_STAGE: string;
37
+ //# sourceMappingURL=fidelity-input-digest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fidelity-input-digest.d.ts","sourceRoot":"","sources":["../../../src/yaml/fidelity-input-digest.ts"],"names":[],"mappings":"AAiCA,MAAM,WAAW,WAAW;IAC1B,gFAAgF;IAChF,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB;IACrB,KAAK,EAAE,MAAM,CAAC;CACf;AAuBD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,YAAY,EAAE,WAAW,EAAE,EAC3B,cAAc,EAAE,MAAM,GAAG,IAAI,GAC5B,MAAM,CAoBR;AAwBD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,WAAW,EAAE,GAAG,OAAO,CAOtE;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iCAAiC,EAAE,MAiF/C,CAAC"}
@@ -0,0 +1,208 @@
1
+ /**
2
+ * Deterministic per-package input digest.
3
+ *
4
+ * A content key over a render package's inputs — the committed wrapper source
5
+ * files plus the paired reference image — so a consumer can tell when a render
6
+ * would be byte-identical to one already produced and skip re-rendering. Pure:
7
+ * a function of the input bytes only, never of absolute paths, timestamps, or
8
+ * commit ids, so the same inputs yield the same digest on any machine or
9
+ * branch.
10
+ *
11
+ * Scope: package-local inputs. Render packages are self-contained by
12
+ * construction — a parameterless wrapper that reproduces one screen from
13
+ * hardcoded fixtures, shipped with every dependency version pinned inline and
14
+ * its own assets vendored — so the package IS its own dependency closure and a
15
+ * package-local content key already invalidates on anything that can shift the
16
+ * render. (A package that escapes its own root — an `includeBuild`, an external
17
+ * `project(":…")` dependency, or a shared version catalog — would break that
18
+ * property; such a package is not safely cacheable and is caught by a separate
19
+ * hermeticity guard rather than folded into this digest.)
20
+ *
21
+ * Digest basis: each file is folded in as its **git blob id**
22
+ * (`sha1("blob " + byteLength + "\0" + content)`) rather than its raw bytes.
23
+ * That is the exact id the GitHub Git Trees API returns for a committed file, so
24
+ * a caller holding only a tree listing — a webhook dispatch with no checkout —
25
+ * can reproduce this digest from `(path, blobSha)` pairs WITHOUT fetching any
26
+ * blob content. The framing is: sha256 over, for each file sorted by path,
27
+ * `len(path) ‖ path ‖ blobSha(content)`, then the reference folded last as
28
+ * `blobSha(reference)` (or a presence-distinct `len(0xffffffff)` marker when
29
+ * there is no reference). `blobSha` is a fixed 20 bytes, so file boundaries stay
30
+ * unambiguous with only the path length-prefixed.
31
+ */
32
+ import { createHash } from 'crypto';
33
+ /** 4-byte big-endian length prefix, so concatenated fields can't alias
34
+ * (`["ab","c"]` must not hash equal to `["a","bc"]`). */
35
+ function len(n) {
36
+ const b = Buffer.allocUnsafe(4);
37
+ b.writeUInt32BE(n >>> 0, 0);
38
+ return b;
39
+ }
40
+ /**
41
+ * Git blob object id for a file's content: `sha1("blob " + len + "\0" + bytes)`.
42
+ * The identical id the GitHub Git Trees API returns for the committed blob, so a
43
+ * dispatch-time caller can read it from a tree listing instead of hashing bytes
44
+ * it never fetched. Returned as 20 raw bytes (folded straight into the digest).
45
+ */
46
+ function gitBlobSha(bytes) {
47
+ const h = createHash('sha1');
48
+ h.update(`blob ${bytes.length}\0`);
49
+ h.update(bytes);
50
+ return h.digest();
51
+ }
52
+ /**
53
+ * Compute the input digest for one render package: its source files plus the
54
+ * reference image the screen is judged against. Files are folded in sorted by
55
+ * path so iteration order can't affect the result; each is folded in as its git
56
+ * blob id (see the module header) so the digest is reproducible from a Git Trees
57
+ * listing with no blob content. The path is length-prefixed and the blob id is
58
+ * fixed-width, so boundaries are unambiguous.
59
+ */
60
+ export function sourceDigest(packageFiles, referenceBytes) {
61
+ const sorted = [...packageFiles].sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
62
+ const h = createHash('sha256');
63
+ for (const file of sorted) {
64
+ const pathBytes = Buffer.from(file.path, 'utf8');
65
+ h.update(len(pathBytes.length));
66
+ h.update(pathBytes);
67
+ h.update(gitBlobSha(file.bytes));
68
+ }
69
+ // Reference is folded in as its blob id, with a presence-distinct marker so
70
+ // "no reference" differs from "empty reference".
71
+ if (referenceBytes === null) {
72
+ h.update(len(0xffffffff));
73
+ }
74
+ else {
75
+ h.update(gitBlobSha(referenceBytes));
76
+ }
77
+ return h.digest('hex');
78
+ }
79
+ /**
80
+ * A Gradle build script — the only files that can reach outside the package
81
+ * root (source files and assets can mention `..` in prose without affecting the
82
+ * build graph).
83
+ */
84
+ function isGradleScript(path) {
85
+ return path.endsWith('.gradle') || path.endsWith('.gradle.kts');
86
+ }
87
+ /**
88
+ * Tokens by which a Gradle script reaches outside its own package root and so
89
+ * breaks the "package is its own dependency closure" invariant this digest
90
+ * relies on:
91
+ * - `includeBuild` — a composite/included build (another whole build).
92
+ * - `projectDir` — a module relocated to a directory outside the layout.
93
+ * - `../` — any parent-path reference (external file, script, or
94
+ * version catalog).
95
+ * Biased toward over-detection: a false positive only forces a re-render (safe),
96
+ * whereas a miss would let a shared external change replay a stale verdict.
97
+ */
98
+ const GRADLE_ESCAPE = /includeBuild|projectDir|\.\.\//;
99
+ /**
100
+ * True when a render package is self-contained — no Gradle script reaches
101
+ * outside the package root. Render packages are hermetic by construction; this
102
+ * guard fails a non-hermetic package OUT of the cacheable set (its digest is not
103
+ * emitted / not trusted for skip) so a change in an external module it depends
104
+ * on can never replay a stale verdict. Pure: a function of the package files
105
+ * only, so a dispatch-time caller can apply the identical check.
106
+ */
107
+ export function isHermeticPackage(packageFiles) {
108
+ for (const file of packageFiles) {
109
+ if (isGradleScript(file.path) && GRADLE_ESCAPE.test(file.bytes.toString('utf8'))) {
110
+ return false;
111
+ }
112
+ }
113
+ return true;
114
+ }
115
+ /**
116
+ * Runtime twin of {@link sourceDigest}, spliced into the self-contained render
117
+ * script that runs on the macOS runner (which cannot import this module). It
118
+ * walks the built package directory, reads the paired reference, and computes
119
+ * the identical digest — a parity test pins it to `sourceDigest` so the twin
120
+ * cannot drift.
121
+ *
122
+ * Exposes `computeSourceDigest(projectRoot, referencePath)`. Build outputs and
123
+ * VCS/tooling dirs are excluded so they never perturb the content key. Reads
124
+ * are best-effort: an unreadable reference folds in as "absent", never throws.
125
+ */
126
+ export const RENDER_SCRIPT_SOURCE_DIGEST_STAGE = String.raw `
127
+ // ---- source-digest stage: deterministic package input content key ----
128
+ function __fidLen(n) {
129
+ var b = Buffer.allocUnsafe(4);
130
+ b.writeUInt32BE(n >>> 0, 0);
131
+ return b;
132
+ }
133
+ var __FID_SKIP_DIRS = { build: 1, '.gradle': 1, '.git': 1, '.idea': 1, 'node_modules': 1, DerivedData: 1 };
134
+ function __fidCollectPackageFiles(root) {
135
+ var fs = require('fs');
136
+ var path = require('path');
137
+ var out = [];
138
+ function walk(dir, rel) {
139
+ var names;
140
+ try { names = fs.readdirSync(dir); } catch (e) { return; }
141
+ names.sort();
142
+ for (var i = 0; i < names.length; i++) {
143
+ var name = names[i];
144
+ var full = path.join(dir, name);
145
+ var relPath = rel ? rel + '/' + name : name;
146
+ var st;
147
+ try { st = fs.statSync(full); } catch (e) { continue; }
148
+ if (st.isDirectory()) {
149
+ if (__FID_SKIP_DIRS[name]) continue;
150
+ walk(full, relPath);
151
+ } else if (st.isFile()) {
152
+ out.push({ path: relPath, bytes: fs.readFileSync(full) });
153
+ }
154
+ }
155
+ }
156
+ walk(root, '');
157
+ return out;
158
+ }
159
+ function __fidBlobSha(bytes) {
160
+ var crypto = require('crypto');
161
+ var h = crypto.createHash('sha1');
162
+ h.update('blob ' + bytes.length + '\0');
163
+ h.update(bytes);
164
+ return h.digest();
165
+ }
166
+ function __fidSourceDigest(files, referenceBytes) {
167
+ var crypto = require('crypto');
168
+ var sorted = files.slice().sort(function (a, b) {
169
+ return a.path < b.path ? -1 : a.path > b.path ? 1 : 0;
170
+ });
171
+ var h = crypto.createHash('sha256');
172
+ for (var i = 0; i < sorted.length; i++) {
173
+ var pathBytes = Buffer.from(sorted[i].path, 'utf8');
174
+ h.update(__fidLen(pathBytes.length));
175
+ h.update(pathBytes);
176
+ h.update(__fidBlobSha(sorted[i].bytes));
177
+ }
178
+ if (referenceBytes === null || referenceBytes === undefined) {
179
+ h.update(__fidLen(0xffffffff));
180
+ } else {
181
+ h.update(__fidBlobSha(referenceBytes));
182
+ }
183
+ return h.digest('hex');
184
+ }
185
+ function computeSourceDigest(projectRoot, referencePath) {
186
+ var fs = require('fs');
187
+ var files = __fidCollectPackageFiles(projectRoot);
188
+ var ref = null;
189
+ try { if (referencePath) ref = fs.readFileSync(referencePath); } catch (e) { ref = null; }
190
+ return __fidSourceDigest(files, ref);
191
+ }
192
+ // Twin of isHermeticPackage: a package is cacheable only when no Gradle script
193
+ // reaches outside its own root (includeBuild / projectDir / a parent path).
194
+ var __FID_GRADLE_ESCAPE = /includeBuild|projectDir|\.\.\//;
195
+ function __fidIsGradleScript(p) {
196
+ return p.slice(-7) === '.gradle' || p.slice(-11) === '.gradle.kts';
197
+ }
198
+ function __fidIsHermetic(files) {
199
+ for (var i = 0; i < files.length; i++) {
200
+ if (__fidIsGradleScript(files[i].path) &&
201
+ __FID_GRADLE_ESCAPE.test(files[i].bytes.toString('utf8'))) {
202
+ return false;
203
+ }
204
+ }
205
+ return true;
206
+ }
207
+ `;
208
+ //# sourceMappingURL=fidelity-input-digest.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=fidelity-input-digest.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fidelity-input-digest.test.d.ts","sourceRoot":"","sources":["../../../src/yaml/fidelity-input-digest.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Unit tests for the deterministic per-package input digest.
3
+ *
4
+ * The digest is the content key the dashboard matches on to decide whether a
5
+ * render would be identical to one it already has — so it must be a pure
6
+ * function of the package's input bytes (wrapper source + reference), stable
7
+ * across machines/branches, and never derived from paths-as-location, mtimes,
8
+ * or commit ids.
9
+ */
10
+ import { describe, test, expect } from '@jest/globals';
11
+ import { createHash } from 'crypto';
12
+ import { createRequire } from 'module';
13
+ import { sourceDigest, isHermeticPackage, RENDER_SCRIPT_SOURCE_DIGEST_STAGE, } from './fidelity-input-digest.js';
14
+ function f(path, content) {
15
+ return { path, bytes: Buffer.from(content, 'utf8') };
16
+ }
17
+ /** Git blob object id: sha1('blob <len>\0<content>') — the SAME id the GitHub
18
+ * Git Trees API returns for a committed file. The digest is defined over these
19
+ * ids so a caller with only a tree listing (no blob content) can reproduce it. */
20
+ function gitBlobSha(bytes) {
21
+ const h = createHash('sha1');
22
+ h.update(`blob ${bytes.length}\0`);
23
+ h.update(bytes);
24
+ return h.digest('hex');
25
+ }
26
+ /** 4-byte big-endian length prefix — mirrors the module-private `len`. */
27
+ function len(n) {
28
+ const b = Buffer.allocUnsafe(4);
29
+ b.writeUInt32BE(n >>> 0, 0);
30
+ return b;
31
+ }
32
+ /** Extract the runner-side twin from the spliced stage source so a parity test
33
+ * can pin it to the pure function. `require` is injected because the stage
34
+ * runs in the runner's CJS scope, not this ESM test module. */
35
+ const require = createRequire(import.meta.url);
36
+ const twin = new Function('require', RENDER_SCRIPT_SOURCE_DIGEST_STAGE +
37
+ '\nreturn { __fidSourceDigest: __fidSourceDigest, __fidIsHermetic: __fidIsHermetic };')(require);
38
+ describe('sourceDigest', () => {
39
+ test('is deterministic: identical inputs produce the same 64-hex digest', () => {
40
+ const files = [f('Proof.kt', 'fun Proof() {}'), f('build.gradle.kts', 'plugins {}')];
41
+ const ref = Buffer.from('reference-image-bytes');
42
+ const first = sourceDigest(files, ref);
43
+ expect(first).toMatch(/^[0-9a-f]{64}$/);
44
+ expect(sourceDigest(files, ref)).toBe(first);
45
+ });
46
+ test('changes when any package file byte changes', () => {
47
+ const ref = Buffer.from('ref');
48
+ const before = sourceDigest([f('Proof.kt', 'fun Proof() {}')], ref);
49
+ const after = sourceDigest([f('Proof.kt', 'fun Proof() { Box() }')], ref);
50
+ expect(after).not.toBe(before);
51
+ });
52
+ test('changes when only the reference image changes', () => {
53
+ const files = [f('Proof.kt', 'fun Proof() {}')];
54
+ const withA = sourceDigest(files, Buffer.from('reference-A'));
55
+ const withB = sourceDigest(files, Buffer.from('reference-B'));
56
+ expect(withB).not.toBe(withA);
57
+ });
58
+ test('is independent of file iteration order', () => {
59
+ const ref = Buffer.from('ref');
60
+ const a = f('a.kt', 'A');
61
+ const b = f('b.kt', 'B');
62
+ expect(sourceDigest([a, b], ref)).toBe(sourceDigest([b, a], ref));
63
+ });
64
+ test('is unambiguous across file boundaries (path/content cannot alias)', () => {
65
+ const ref = Buffer.from('ref');
66
+ // Same concatenated bytes, different split: must not collide.
67
+ const split = sourceDigest([f('ab', 'x'), f('', 'y')], ref);
68
+ const joined = sourceDigest([f('a', 'bxy')], ref);
69
+ expect(split).not.toBe(joined);
70
+ });
71
+ test('is reconstructible from git blob shas alone (dashboard tree-API parity)', () => {
72
+ // The dashboard computes this SAME digest at webhook time from a Git Trees
73
+ // API listing — which carries each committed file's blob sha but NOT its
74
+ // content. Pin the exact framing so that reconstruction (path + blob sha,
75
+ // no bytes) reproduces the digest byte-for-byte.
76
+ const files = [f('b.kt', 'B'), f('a.kt', 'A')];
77
+ const ref = Buffer.from('reference-image-bytes');
78
+ const sorted = [...files].sort((x, y) => (x.path < y.path ? -1 : x.path > y.path ? 1 : 0));
79
+ const h = createHash('sha256');
80
+ for (const file of sorted) {
81
+ const p = Buffer.from(file.path, 'utf8');
82
+ h.update(len(p.length));
83
+ h.update(p);
84
+ h.update(Buffer.from(gitBlobSha(file.bytes), 'hex'));
85
+ }
86
+ h.update(Buffer.from(gitBlobSha(ref), 'hex'));
87
+ expect(sourceDigest(files, ref)).toBe(h.digest('hex'));
88
+ });
89
+ test('matches the cross-consumer golden vector (pins the wire format)', () => {
90
+ // A fixed known-answer vector shared verbatim with the dashboard's
91
+ // dispatch-time digest, so the two implementations cannot drift apart
92
+ // silently. If this changes, the dashboard golden must change in lockstep.
93
+ const files = [f('a.kt', 'A'), f('proof/build.gradle.kts', 'plugins {}')];
94
+ expect(sourceDigest(files, Buffer.from('ref-bytes'))).toBe('7fc57f481eb011299d34824e0a506345d15e96946e345beac882f26adab47374');
95
+ expect(sourceDigest(files, null)).toBe('2596ecea7f591c23f9397707a92b008dabedbd1fd4acc0efb2440849e97ddd3c');
96
+ });
97
+ test('folds a null reference in with a presence-distinct marker (not a blob sha)', () => {
98
+ const files = [f('a.kt', 'A')];
99
+ const sorted = files;
100
+ const h = createHash('sha256');
101
+ for (const file of sorted) {
102
+ const p = Buffer.from(file.path, 'utf8');
103
+ h.update(len(p.length));
104
+ h.update(p);
105
+ h.update(Buffer.from(gitBlobSha(file.bytes), 'hex'));
106
+ }
107
+ h.update(len(0xffffffff));
108
+ expect(sourceDigest(files, null)).toBe(h.digest('hex'));
109
+ });
110
+ });
111
+ describe('isHermeticPackage', () => {
112
+ const hermetic = [
113
+ f('settings.gradle.kts', 'rootProject.name = "p"\ninclude(":proof")\n'),
114
+ f('build.gradle.kts', 'plugins { id("com.android.library") version "8.13.2" }'),
115
+ f('proof/build.gradle.kts', 'dependencies { implementation("androidx.compose.ui:ui") }'),
116
+ f('proof/src/main/kotlin/Proof.kt', 'fun Proof() {}'),
117
+ ];
118
+ test('accepts a self-contained package with everything pinned inline', () => {
119
+ expect(isHermeticPackage(hermetic)).toBe(true);
120
+ });
121
+ test('rejects a composite build (includeBuild reaches another build)', () => {
122
+ const files = [...hermetic, f('settings.gradle.kts', 'includeBuild("../design-system")')];
123
+ expect(isHermeticPackage(files)).toBe(false);
124
+ });
125
+ test('rejects a module relocated outside the root via projectDir', () => {
126
+ const files = [
127
+ f('settings.gradle.kts', 'include(":ds")\nproject(":ds").projectDir = file("../ds")'),
128
+ ];
129
+ expect(isHermeticPackage(files)).toBe(false);
130
+ });
131
+ test('rejects a parent-path escape (external file / version catalog)', () => {
132
+ const files = [
133
+ f('settings.gradle.kts', 'versionCatalogs { create("libs") { from(files("../gradle/libs.versions.toml")) } }'),
134
+ ];
135
+ expect(isHermeticPackage(files)).toBe(false);
136
+ });
137
+ test('ignores escape tokens outside Gradle scripts (only build scripts can escape)', () => {
138
+ // A source file or asset mentioning "../" is not a build-graph escape.
139
+ const files = [
140
+ f('settings.gradle.kts', 'include(":proof")'),
141
+ f('proof/src/main/kotlin/Doc.kt', '// see ../design-system for the original'),
142
+ ];
143
+ expect(isHermeticPackage(files)).toBe(true);
144
+ });
145
+ });
146
+ describe('runtime twin parity', () => {
147
+ const files = [f('Proof.kt', 'fun Proof() { Box() }'), f('build.gradle.kts', 'plugins {}')];
148
+ test('the spliced runner-side digest matches the pure sourceDigest (with reference)', () => {
149
+ const ref = Buffer.from('reference-image-bytes');
150
+ expect(twin.__fidSourceDigest(files, ref)).toBe(sourceDigest(files, ref));
151
+ });
152
+ test('the spliced runner-side digest matches the pure sourceDigest (no reference)', () => {
153
+ expect(twin.__fidSourceDigest(files, null)).toBe(sourceDigest(files, null));
154
+ });
155
+ test('the spliced runner-side hermeticity check matches isHermeticPackage', () => {
156
+ const hermetic = [
157
+ f('settings.gradle.kts', 'include(":proof")'),
158
+ f('proof/src/main/kotlin/Doc.kt', '// mentions ../elsewhere harmlessly'),
159
+ ];
160
+ const escaping = [f('settings.gradle', 'includeBuild("../other")')];
161
+ expect(twin.__fidIsHermetic(hermetic)).toBe(isHermeticPackage(hermetic));
162
+ expect(twin.__fidIsHermetic(escaping)).toBe(isHermeticPackage(escaping));
163
+ expect(twin.__fidIsHermetic(hermetic)).toBe(true);
164
+ expect(twin.__fidIsHermetic(escaping)).toBe(false);
165
+ });
166
+ });
167
+ //# sourceMappingURL=fidelity-input-digest.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/yaml/steps/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAyCH;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAs5C7C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/yaml/steps/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA4CH;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAq7C7C"}
@@ -24,8 +24,8 @@ import { BitriseSlackStepExecutor } from './bitrise-slack.js';
24
24
  import { BitriseApkInfoStepExecutor } from './bitrise-apk-info.js';
25
25
  import { GooglePlayDeployStepExecutor } from './google-play-deploy.js';
26
26
  import { AppStoreDeployStepExecutor } from './app-store-deploy.js';
27
- import { UiFidelityRenderStepExecutor, DEFAULT_RENDER_SIZE, DEFAULT_SCALE, DEFAULT_PACKAGE_SOURCE, } from './ui-fidelity-render.js';
28
- import { UiFidelityRenderAndroidStepExecutor, DEFAULT_GRADLE_TASK, } from './ui-fidelity-render-android.js';
27
+ import { UiFidelityRenderStepExecutor, DEFAULT_RENDER_SIZE, DEFAULT_SCALE, DEFAULT_PACKAGE_SOURCE, DEFAULT_REFERENCE_SOURCE, } from './ui-fidelity-render.js';
28
+ import { UiFidelityRenderAndroidStepExecutor, DEFAULT_GRADLE_TASK, DEFAULT_PACKAGE_SOURCE as DEFAULT_ANDROID_PACKAGE_SOURCE, DEFAULT_REFERENCE_SOURCE as DEFAULT_ANDROID_REFERENCE_SOURCE, } from './ui-fidelity-render-android.js';
29
29
  /**
30
30
  * Initializes the step registry with all available steps
31
31
  * This function should be called once at application startup
@@ -771,6 +771,13 @@ export function initializeStepRegistry() {
771
771
  required: false,
772
772
  default: DEFAULT_PACKAGE_SOURCE,
773
773
  },
774
+ reference_source: {
775
+ description: "Where each screen's reference image comes from: 'inputs' (default — a " +
776
+ "basename in the run-inputs directory) or 'repo' (a repo-relative path to " +
777
+ 'a committed reference, resolved against the checkout)',
778
+ required: false,
779
+ default: DEFAULT_REFERENCE_SOURCE,
780
+ },
774
781
  package_path: {
775
782
  description: "Path to the user's SwiftPM package containing the screens. " +
776
783
  "Required when package_source is 'repo' (the default); ignored with 'inputs'",
@@ -804,6 +811,26 @@ export function initializeStepRegistry() {
804
811
  'via Roborazzi + Robolectric on the JVM (no device, no emulator)',
805
812
  platform: 'android',
806
813
  inputs: {
814
+ package_source: {
815
+ description: "Where the Gradle render project comes from: 'inputs' (default — " +
816
+ "package.tar.gz shipped in the run-inputs directory) or 'repo' " +
817
+ '(package_path in the checkout, rendered directly without an upload)',
818
+ required: false,
819
+ default: DEFAULT_ANDROID_PACKAGE_SOURCE,
820
+ },
821
+ reference_source: {
822
+ description: "Where each screen's reference image comes from: 'inputs' (default — a " +
823
+ "basename in the run-inputs directory) or 'repo' (a repo-relative path to " +
824
+ 'a committed reference, resolved against the checkout)',
825
+ required: false,
826
+ default: DEFAULT_ANDROID_REFERENCE_SOURCE,
827
+ },
828
+ package_path: {
829
+ description: 'Repo-relative path to the committed Gradle render project. Required ' +
830
+ "when package_source is 'repo'; ignored with 'inputs'",
831
+ required: false,
832
+ inputType: 'path',
833
+ },
807
834
  scale: {
808
835
  description: 'Display scale factor used when reporting logical points; must match the ' +
809
836
  'density qualifier the render test pins (xhdpi = 2)',
@@ -70,6 +70,23 @@ export interface UiFidelityRenderAndroidInputs {
70
70
  * it in whichever subproject declares it.
71
71
  */
72
72
  export declare const DEFAULT_GRADLE_TASK = "recordRoborazziDebug";
73
+ /** Valid values for the package_source input. */
74
+ export declare const PACKAGE_SOURCES: readonly ["repo", "inputs"];
75
+ export type PackageSource = (typeof PACKAGE_SOURCES)[number];
76
+ /**
77
+ * Default package source: the Gradle project ships as package.tar.gz in the
78
+ * run-inputs directory (the agent-upload path). "repo" instead renders the
79
+ * committed project at package_path, for a triggered (agent-less) run.
80
+ */
81
+ export declare const DEFAULT_PACKAGE_SOURCE: PackageSource;
82
+ /** Valid values for the reference_source input. */
83
+ export declare const REFERENCE_SOURCES: readonly ["repo", "inputs"];
84
+ export type ReferenceSource = (typeof REFERENCE_SOURCES)[number];
85
+ /**
86
+ * Default reference source: references arrive as run inputs (a plain basename
87
+ * under `.ci/inputs`), matching the agent-upload path.
88
+ */
89
+ export declare const DEFAULT_REFERENCE_SOURCE: ReferenceSource;
73
90
  /** Basename of the shipped Gradle-project archive inside the run-inputs dir. */
74
91
  export declare const PACKAGE_ARCHIVE_BASENAME = "package.tar.gz";
75
92
  /** Renderer identifier recorded in protocol-result.json. */
@@ -84,10 +101,31 @@ export declare function isValidGradleTask(task: string): boolean;
84
101
  export interface AndroidRenderScriptConfig {
85
102
  scale: number;
86
103
  gradleTask: string;
104
+ /**
105
+ * Only present (and only ever "repo") when package_source was explicitly set
106
+ * to "repo". When absent, the project ships as package.tar.gz and is
107
+ * extracted/validated exactly as the default, byte-identical script.
108
+ */
109
+ packageSource?: PackageSource;
110
+ /**
111
+ * Repo-relative path to the committed Gradle project. Present (and required)
112
+ * only with packageSource "repo"; ignored otherwise.
113
+ */
114
+ packagePath?: string;
115
+ /**
116
+ * Only present (and only ever "repo") when reference_source was explicitly set
117
+ * to "repo". When absent, references are read from `.ci/inputs/<basename>` and
118
+ * the generated reference-sourcing code is byte-identical to the default.
119
+ */
120
+ referenceSource?: ReferenceSource;
87
121
  }
88
122
  /**
89
123
  * Generates the self-contained runtime node script for the step. Pure function
90
124
  * of its config — exported so tests can execute the script directly.
125
+ *
126
+ * When config.referenceSource is absent the reference block is byte-identical
127
+ * to the default (JSON.stringify drops the undefined key, and the unpatched
128
+ * runtime is used).
91
129
  */
92
130
  export declare function generateAndroidRenderScript(config: AndroidRenderScriptConfig): string;
93
131
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ui-fidelity-render-android.d.ts","sourceRoot":"","sources":["../../../../src/yaml/steps/ui-fidelity-render-android.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAKpE,sDAAsD;AACtD,MAAM,WAAW,6BAA6B;IAC5C;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO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