@@ -146,6 +146,35 @@ describe("ci workflow guards", () => {
|
146 | 146 | expect(buildArtifactSteps.some((step) => step.run === "pnpm ui:build")).toBe(false); |
147 | 147 | }); |
148 | 148 | |
| 149 | +it("restores the dist build cache before building and saves only cache misses", () => { |
| 150 | +const workflow = readCiWorkflow(); |
| 151 | +const buildArtifactSteps = workflow.jobs["build-artifacts"].steps; |
| 152 | +const stepNames = buildArtifactSteps.map((step) => step.name); |
| 153 | +const restoreStep = buildArtifactSteps.find((step) => step.name === "Restore dist build cache"); |
| 154 | +const buildDistStep = buildArtifactSteps.find((step) => step.name === "Build dist"); |
| 155 | +const saveStep = buildArtifactSteps.find((step) => step.name === "Save dist build cache"); |
| 156 | + |
| 157 | +expect(stepNames.indexOf("Restore dist build cache")).toBeLessThan( |
| 158 | +stepNames.indexOf("Build dist"), |
| 159 | +); |
| 160 | +expect(stepNames.indexOf("Build dist")).toBeLessThan( |
| 161 | +stepNames.indexOf("Pack built runtime artifacts"), |
| 162 | +); |
| 163 | +expect(stepNames.indexOf("Run built artifact checks")).toBeLessThan( |
| 164 | +stepNames.indexOf("Save dist build cache"), |
| 165 | +); |
| 166 | +expect(restoreStep.uses).toBe("actions/cache/restore@v5"); |
| 167 | +expect(buildDistStep.if).toBe("steps.dist_build_cache.outputs.cache-hit != 'true'"); |
| 168 | +expect(saveStep.uses).toBe("actions/cache/save@v5"); |
| 169 | +expect(saveStep.if).toBe("steps.dist_build_cache.outputs.cache-hit != 'true'"); |
| 170 | +expect(saveStep.with.key).toBe("${{ steps.dist_build_cache.outputs.cache-primary-key }}"); |
| 171 | +expect(restoreStep.with.path).toContain("dist/"); |
| 172 | +expect(restoreStep.with.path).toContain("dist-runtime/"); |
| 173 | +expect(restoreStep.with.path).toContain("extensions/*/src/host/**/.bundle.hash"); |
| 174 | +expect(restoreStep.with.path).toContain("extensions/*/src/host/**/*.bundle.js"); |
| 175 | +expect(buildArtifactSteps.map((step) => step.name)).not.toContain("Cache dist build"); |
| 176 | +}); |
| 177 | + |
149 | 178 | it("gives quiet Node test shards enough no-output runway", () => { |
150 | 179 | const workflow = readCiWorkflow(); |
151 | 180 | const nodeTestJob = workflow.jobs["checks-node-core-test-nondist-shard"]; |
|