Skip to content

Commit

Permalink
ci: separate test-proposals
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Jan 18, 2024
1 parent 8b1e336 commit d31559a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 17 deletions.
28 changes: 20 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ jobs:
fi
echo "platforms=$platforms" >> $GITHUB_OUTPUT
# see https://docs.docker.com/build/ci/github-actions/test-before-push/
test-proposals:
use-proposals:
needs: [platforms]
# UNTIL https://github.com/Agoric/agoric-3-proposals/issues/2
timeout-minutes: 120
Expand Down Expand Up @@ -127,11 +126,6 @@ jobs:
# If we pushed from PRs, each one would overwrite (e.g. use-upgrade-8)
# push: ${{ github.event_name != 'pull_request' }}

# TODO run tests in another (non-matrixed) job once "use" images are available in another worker
- name: run proposal tests
if: ${{ matrix.platform == env.X86_PLATFORM }}
run: node_modules/.bin/synthetic-chain test

# XXX this should be instant for the local platform because all the stages
# were already built in the steps above but it's re-building the last
# stage. This is deemed good enough for now. see
Expand All @@ -147,10 +141,28 @@ jobs:
tags: ${{ steps.docker-tags.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# see https://docs.docker.com/build/ci/github-actions/test-before-push/
test-proposals:
needs: use-proposals
# only test in default platform
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

# The .ts scripts depend upon this
- run: tsx --version || npm install --global tsx
# Enable corepack for packageManager config
- run: corepack enable || sudo corepack enable
- run: yarn install

- name: run proposal tests
run: node_modules/.bin/synthetic-chain test

# Merge the default image from each platform into one multi-arch image,
# then publish that multiarch image.
docker-publish-multiarch:
needs: [test-proposals, platforms]
needs: [use-proposals, platforms]
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down
19 changes: 12 additions & 7 deletions packages/synthetic-chain/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,19 @@ test [--debug] - build the "test" images and run them
doctor - diagnostics and quick fixes
`;

const prepareDockerBuild = () => {
writeBakefileProposals(allProposals);
writeDockerfile(allProposals, buildConfig.fromTag);
// files the Docker builds depend on
buildProposalSubmissions(proposals);
/**
* Put into places files that building depends upon.
*/
const prepareDockerBuild = (buildSubmissions?: boolean) => {
execSync(
// XXX very brittle
'cp -r node_modules/@agoric/synthetic-chain/upgrade-test-scripts .',
);
writeDockerfile(allProposals, buildConfig.fromTag);
writeBakefileProposals(allProposals);
if (buildSubmissions) {
buildProposalSubmissions(proposals);
}
};

switch (cmd) {
Expand All @@ -69,8 +73,9 @@ switch (cmd) {
break;
}
case 'test':
// always rebuild all test images. Keeps it simple and these are fast
// as long as the "use" stages are cached because they don't execute anything themselves.
prepareDockerBuild();
// Always rebuild all test images to keep it simple. With the "use" stages
// cached, these are fast as long because the layers don't execute anything.
bakeImages('test', values.dry);
if (values.debug) {
debugTestImage(matchOneProposal(proposals, match!));
Expand Down
2 changes: 1 addition & 1 deletion packages/synthetic-chain/src/cli/build.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { execSync } from 'node:child_process';
import fs from 'node:fs';
import path from 'node:path';
import { ProposalInfo, imageNameForProposal } from './proposals.js';
import { ProposalInfo } from './proposals.js';

export type AgoricSyntheticChainConfig = {
/**
Expand Down
7 changes: 6 additions & 1 deletion packages/synthetic-chain/src/cli/dockerfileGen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
type ProposalInfo,
type SoftwareUpgradeProposal,
encodeUpgradeInfo,
imageNameForProposal,
} from './proposals.js';

/**
Expand Down Expand Up @@ -150,9 +151,13 @@ RUN ./run_use.sh ${proposalIdentifier}:${proposalName}
* Needs to be an image to have access to the SwingSet db. run it with `docker run --rm` to not make the container ephemeral.
*/
TEST({ proposalName, proposalIdentifier }: ProposalInfo) {
// Assumes the 'use' image is built and tagged.
// This isn't necessary for a multi-stage build, but it allows CI
// to split the "test" image building into a separate runner.
const useImage = imageNameForProposal({ proposalName }, 'use').name;
return `
# TEST ${proposalName}
FROM use-${proposalName} as test-${proposalName}
FROM ${useImage} as test-${proposalName}
WORKDIR /usr/src/upgrade-test-scripts
Expand Down

0 comments on commit d31559a

Please sign in to comment.