mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 22:11:12 +00:00
ci: publish the portable build cache only for selected consumers (#14307)
This commit is contained in:
1 parent
98beb5424a
commit
2b818e0dbf
3 files changed
+66
-34
No files matched your search
+20
-16
@@ -60,6 +60,23 @@ jobs:
|
||||
test_shadow_id: ${{ steps.shadow-upload.outputs.artifact-id }}
|
||||
qualification_run_id: ${{ steps.qualification.outputs.run_id }}
|
||||
code: ${{ steps.plan.outputs.code }}
|
||||
build_cache: >-
|
||||
${{ steps.plan.outputs.runtime == 'true' ||
|
||||
steps.plan.outputs.apple == 'true' ||
|
||||
steps.plan.outputs.browser == 'true' ||
|
||||
steps.plan.outputs.binary_layout == 'true' ||
|
||||
steps.plan.outputs.evm == 'true' ||
|
||||
steps.plan.outputs.apk_signature == 'true' ||
|
||||
steps.plan.outputs.javascript_recovery == 'true' ||
|
||||
steps.plan.outputs.recorded_crash == 'true' ||
|
||||
steps.plan.outputs.web_network == 'true' ||
|
||||
steps.plan.outputs.web_runtime == 'true' ||
|
||||
steps.plan.outputs.web_source_map == 'true' ||
|
||||
steps.plan.outputs.agentenv == 'true' ||
|
||||
steps.plan.outputs.packet_capture == 'true' ||
|
||||
steps.plan.outputs.signal_recording == 'true' ||
|
||||
steps.plan.outputs.go_binary == 'true' ||
|
||||
steps.plan.outputs.ghidra_bridge == 'true' }}
|
||||
reverse_tools: ${{ steps.plan.outputs.reverse_tools }}
|
||||
python: ${{ steps.plan.outputs.python }}
|
||||
packet_capture: ${{ steps.plan.outputs.packet_capture }}
|
||||
@@ -458,22 +475,7 @@ jobs:
|
||||
needs: changes
|
||||
# Reusable provider workflows consume this run's portable build artifact,
|
||||
# even when a workflow-only edit selects the lane without portable tests.
|
||||
if: >-
|
||||
needs.changes.outputs.code == 'true' ||
|
||||
needs.changes.outputs.browser == 'true' ||
|
||||
needs.changes.outputs.binary_layout == 'true' ||
|
||||
needs.changes.outputs.evm == 'true' ||
|
||||
needs.changes.outputs.apk_signature == 'true' ||
|
||||
needs.changes.outputs.javascript_recovery == 'true' ||
|
||||
needs.changes.outputs.recorded_crash == 'true' ||
|
||||
needs.changes.outputs.web_network == 'true' ||
|
||||
needs.changes.outputs.web_runtime == 'true' ||
|
||||
needs.changes.outputs.web_source_map == 'true' ||
|
||||
needs.changes.outputs.agentenv == 'true' ||
|
||||
needs.changes.outputs.packet_capture == 'true' ||
|
||||
needs.changes.outputs.signal_recording == 'true' ||
|
||||
needs.changes.outputs.go_binary == 'true' ||
|
||||
needs.changes.outputs.ghidra_bridge == 'true'
|
||||
if: needs.changes.outputs.code == 'true' || needs.changes.outputs.build_cache == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
permissions:
|
||||
@@ -532,11 +534,13 @@ jobs:
|
||||
# Native package jobs still run their build and prepack checks; Turbo
|
||||
# restores matching outputs or rebuilds when their inputs differ.
|
||||
- name: Stage current portable build task cache
|
||||
if: needs.changes.outputs.build_cache == 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
# A new Turbo dry run can evict the entries this build just used.
|
||||
node scripts/ci/portable-build-cache.mjs snapshot .cache/ci-build-plan.json
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: needs.changes.outputs.build_cache == 'true'
|
||||
with:
|
||||
name: rea-build-cache
|
||||
overwrite: true
|
||||
|
||||
@@ -1399,9 +1399,10 @@ rebuilds misses. A restore prefix with the same platform and toolchain permits
|
||||
partial task reuse when one generator's inputs change; Turbo still invalidates
|
||||
that generator's entry. Native outputs are not stored in this cache.
|
||||
|
||||
POSIX native package jobs, documentation checks, Go binary verification, and the
|
||||
Apple artifact lane reuse the same workflow's portable Turbo cache
|
||||
(`rea-build-cache`) for compiled JavaScript, skills, and catalogs. Windows jobs
|
||||
The build job stages and uploads `rea-build-cache` when a selected POSIX native
|
||||
package, Apple artifact, or reusable provider job consumes it. Portable test
|
||||
shards download `rea-test-runtime`. Documentation checks restore the
|
||||
cross-run Turbo cache. Windows jobs
|
||||
(`windows-curated` and Windows `package-e2e`) compile with `typescript` rather
|
||||
than Linux's accelerated `tsrs` checker, so they restore and publish a separate
|
||||
Windows `.turbo/cache/` family (`rea-windows-build-v1-Windows-X64-*`, pruned to
|
||||
|
||||
@@ -613,10 +613,12 @@ it("binds provider build reuse to the current run while keeping standalone dispa
|
||||
expect(buildSteps[stage]?.run).toContain(
|
||||
"node scripts/ci/portable-build-cache.mjs snapshot .cache/ci-build-plan.json",
|
||||
);
|
||||
expect(buildSteps[stage]?.if).toBeUndefined();
|
||||
expect(buildSteps[stage]?.if).toBe(
|
||||
"needs.changes.outputs.build_cache == 'true'",
|
||||
);
|
||||
expect(buildSteps[stage]?.shell).toBe("bash");
|
||||
expect(buildSteps[stage]?.["continue-on-error"]).not.toBe(true);
|
||||
expect(buildSteps[upload]?.if).toBeUndefined();
|
||||
expect(buildSteps[upload]?.if).toBe(buildSteps[stage]?.if);
|
||||
expect(buildSteps[upload]?.with).toMatchObject({
|
||||
path: ".cache/ci-build-cache/",
|
||||
"if-no-files-found": "error",
|
||||
@@ -637,19 +639,44 @@ it("binds provider build reuse to the current run while keeping standalone dispa
|
||||
"go_binary",
|
||||
"ghidra_bridge",
|
||||
];
|
||||
const buildTerms = z
|
||||
.string()
|
||||
.parse(jobs.build?.if)
|
||||
.split("||")
|
||||
.map((term) => term.trim());
|
||||
// Provider workflow edits select their lane without code=true. The build
|
||||
// producer must still run, without selecting the portable test shards.
|
||||
expect(new Set(buildTerms)).toEqual(
|
||||
new Set(
|
||||
["code", ...consumers].map(
|
||||
(scope) => `needs.changes.outputs.${scope} == 'true'`,
|
||||
),
|
||||
),
|
||||
const { build_cache: cacheOutput } = z
|
||||
.object({ build_cache: z.string() })
|
||||
.parse(jobs.changes?.outputs);
|
||||
const downloadStep = z.object({
|
||||
uses: z.string().optional(),
|
||||
with: z.object({ name: z.string().optional() }).optional(),
|
||||
});
|
||||
const cacheConsumers = z
|
||||
.array(
|
||||
z.object({
|
||||
if: z.string().optional(),
|
||||
with: z
|
||||
.object({ build_cache_artifact: z.string().optional() })
|
||||
.optional(),
|
||||
steps: z.array(downloadStep).optional(),
|
||||
}),
|
||||
)
|
||||
.parse(Object.values(jobs))
|
||||
.filter(
|
||||
(job) =>
|
||||
job.with?.build_cache_artifact === "rea-build-cache" ||
|
||||
job.steps?.some(
|
||||
(step) =>
|
||||
step.uses?.startsWith("actions/download-artifact@") &&
|
||||
step.with?.name === "rea-build-cache",
|
||||
),
|
||||
);
|
||||
const cacheConditions = cacheConsumers.map((job) =>
|
||||
z.string().parse(job.if).replace("needs.changes.", "steps.plan."),
|
||||
);
|
||||
expect(cacheOutput.startsWith("${{ ") && cacheOutput.endsWith(" }}")).toBe(
|
||||
true,
|
||||
);
|
||||
expect(new Set(cacheOutput.slice(4, -3).split(/\s*\|\|\s*/u))).toEqual(
|
||||
new Set(cacheConditions),
|
||||
);
|
||||
expect(jobs.build?.if).toBe(
|
||||
"needs.changes.outputs.code == 'true' || needs.changes.outputs.build_cache == 'true'",
|
||||
);
|
||||
for (const name of ["test-shard", "test-shard-broad"])
|
||||
expect(jobs[name]?.if).toBe(
|
||||
|
||||
Reference in new issue
Block a user