From ba410465dc7282ddbeb20f0d546cd56879fb469f Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Mon, 6 Nov 2023 06:59:26 -0800 Subject: [PATCH] ci: use GitHub Actions Cache --- .github/workflows/ci.yml | 12 +++++++++--- buildTestImages.ts | 7 +++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e7da657f..9c74aa29 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,10 +58,12 @@ jobs: # The .ts scripts depend upon this - run: yarn global add tsx + - name: Export vars of Actions Runtime for caching + uses: crazy-max/ghaction-github-runtime@v3 + - name: build test images - run: | - docker info - ./buildTestImages.ts + run: ./buildTestImages.ts --buildArgs="--cache-from type=gha --cache-to type=gha,mode=max" + - name: run test images run: ./runTestImages.ts @@ -77,6 +79,10 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + # use GitHub Actions Cache https://github.com/moby/buildkit#github-actions-cache-experimental + cache-from: type=gha + cache-to: type=gha,mode=max + - name: notify on failure if: failure() && github.event_name != 'pull_request' uses: ./.github/actions/notify-status diff --git a/buildTestImages.ts b/buildTestImages.ts index 873e48c7..8c8ded68 100755 --- a/buildTestImages.ts +++ b/buildTestImages.ts @@ -8,12 +8,13 @@ import { refreshDockerfile } from './makeDockerfile'; refreshDockerfile(); const options = { + buildArgs: { type: 'string' }, match: { short: 'm', type: 'string' }, dry: { type: 'boolean' }, } as const; const { values } = parseArgs({ options }); -const { match, dry } = values; +const { buildArgs, match, dry } = values; const allProposals = readProposals(); @@ -26,9 +27,7 @@ for (const proposal of proposals) { console.log(`\nBuilding test image for proposal ${proposal.proposalName}`); } const { name, target } = imageNameForProposalTest(proposal); - // 'load' to ensure the images are output to the Docker client. Seems to be necessary - // for the CI docker/build-push-action to re-use the cached stages. - const cmd = `docker buildx build --load --tag ${name} --target ${target} .`; + const cmd = `docker buildx build ${buildArgs} --tag ${name} --target ${target} .`; console.log(cmd); if (!dry) { execSync(cmd, { stdio: 'inherit' });