diff --git a/.dockerignore b/.dockerignore index d2905d81..d635f0a0 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,3 @@ # each stage does its own yarn install -node_modules +**/node_modules/ +**/.git diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a7c5614..f70935f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,10 +59,12 @@ jobs: # The .ts scripts depend upon this - run: npm install --global tsx + - name: build use images + run: ./buildUseImages.ts + - name: build test images - run: | - docker info - ./buildTestImages.ts + run: ./buildTestImages.ts + - name: run test images run: ./runTestImages.ts @@ -78,6 +80,9 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main + cache-to: type=inline + - 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..ce103c6a 100755 --- a/buildTestImages.ts +++ b/buildTestImages.ts @@ -2,7 +2,7 @@ import { parseArgs } from 'node:util'; import { execSync } from 'node:child_process'; -import { imageNameForProposalTest, readProposals } from './common'; +import { imageNameForProposal, readProposals } from './common'; import { refreshDockerfile } from './makeDockerfile'; refreshDockerfile(); @@ -25,7 +25,7 @@ for (const proposal of proposals) { if (!dry) { console.log(`\nBuilding test image for proposal ${proposal.proposalName}`); } - const { name, target } = imageNameForProposalTest(proposal); + const { name, target } = imageNameForProposal(proposal, 'test'); // '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} .`; diff --git a/buildUseImages.ts b/buildUseImages.ts new file mode 100755 index 00000000..b5e34008 --- /dev/null +++ b/buildUseImages.ts @@ -0,0 +1,36 @@ +#!/usr/bin/env tsx + +import { parseArgs } from 'node:util'; +import { execSync } from 'node:child_process'; +import { imageNameForProposal, readProposals } from './common'; +import { refreshDockerfile } from './makeDockerfile'; + +refreshDockerfile(); + +const options = { + match: { short: 'm', type: 'string' }, + dry: { type: 'boolean' }, +} as const; +const { values } = parseArgs({ options }); + +const { match, dry } = values; + +const allProposals = readProposals(); + +const proposals = match + ? allProposals.filter(p => p.proposalName.includes(match)) + : allProposals; + +for (const proposal of proposals) { + if (!dry) { + console.log(`\nBuilding use image for proposal ${proposal.proposalName}`); + } + const { name, target } = imageNameForProposal(proposal, 'use'); + // '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} .`; + console.log(cmd); + if (!dry) { + execSync(cmd, { stdio: 'inherit' }); + } +} diff --git a/common.ts b/common.ts index 7bf3e3e4..f74727fc 100644 --- a/common.ts +++ b/common.ts @@ -44,8 +44,11 @@ export function readProposals(): ProposalInfo[] { return proposalPaths.map(readInfo); } -export function imageNameForProposalTest(proposal) { - const target = `test-${proposal.proposalName}`; +export function imageNameForProposal( + proposal: ProposalCommon, + stage: 'use' | 'test', +) { + const target = `${stage}-${proposal.proposalName}`; return { name: `${repository}:${target}`, target, diff --git a/runTestImages.ts b/runTestImages.ts index b9dd11ba..786a7416 100755 --- a/runTestImages.ts +++ b/runTestImages.ts @@ -2,7 +2,7 @@ import { parseArgs } from 'node:util'; import { execSync } from 'node:child_process'; -import { imageNameForProposalTest, readProposals } from './common'; +import { imageNameForProposal, readProposals } from './common'; const options = { match: { short: 'm', type: 'string' }, @@ -19,7 +19,7 @@ const proposals = match for (const proposal of proposals) { console.log(`Running test image for proposal ${proposal.proposalName}`); - const { name } = imageNameForProposalTest(proposal); + const { name } = imageNameForProposal(proposal, 'test'); // 'rm' to remove the container when it exits const cmd = `docker run --rm ${name}`; execSync(cmd, { stdio: 'inherit' }); diff --git a/upgrade-test-scripts/run_eval.sh b/upgrade-test-scripts/run_eval.sh index a30d96a4..e9027f78 100644 --- a/upgrade-test-scripts/run_eval.sh +++ b/upgrade-test-scripts/run_eval.sh @@ -6,8 +6,6 @@ set -e source ./env_setup.sh -export SLOGFILE=slog.slog - PROPOSAL_PATH=$1 startAgd diff --git a/upgrade-test-scripts/run_test.sh b/upgrade-test-scripts/run_test.sh index 116d549a..2df0c46f 100644 --- a/upgrade-test-scripts/run_test.sh +++ b/upgrade-test-scripts/run_test.sh @@ -6,8 +6,6 @@ set -e source ./env_setup.sh -export SLOGFILE=slog.slog - PROPOSAL_PATH=$1 startAgd diff --git a/upgrade-test-scripts/run_use.sh b/upgrade-test-scripts/run_use.sh index c1a19076..11948380 100644 --- a/upgrade-test-scripts/run_use.sh +++ b/upgrade-test-scripts/run_use.sh @@ -23,8 +23,6 @@ fi source ./env_setup.sh -export SLOGFILE=slog.slog - echo "Starting agd in the background." startAgd diff --git a/upgrade-test-scripts/start_agd.sh b/upgrade-test-scripts/start_agd.sh index ecdd2092..5003c233 100644 --- a/upgrade-test-scripts/start_agd.sh +++ b/upgrade-test-scripts/start_agd.sh @@ -6,7 +6,5 @@ grep -qF 'printKeys' /root/.bashrc || echo "printKeys" >>/root/.bashrc source ./env_setup.sh -export SLOGFILE=slog.slog - # don't use startAgd() because that backgrounds agd start --log_level warn "$@" diff --git a/upgrade-test-scripts/start_to_to.sh b/upgrade-test-scripts/start_to_to.sh index a58d64ee..974f617a 100644 --- a/upgrade-test-scripts/start_to_to.sh +++ b/upgrade-test-scripts/start_to_to.sh @@ -6,8 +6,6 @@ grep -qF 'printKeys' /root/.bashrc || echo "printKeys" >>/root/.bashrc source ./env_setup.sh -export SLOGFILE=slog.slog - startAgd if [[ -z "${UPGRADE_TO}" ]]; then