Skip to content

Commit

Permalink
refactor: imageNameForProposal
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Nov 27, 2023
1 parent 4ec09d6 commit c87d32d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
4 changes: 2 additions & 2 deletions buildTestImages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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} .`;
Expand Down
15 changes: 5 additions & 10 deletions common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,11 @@ export function lastPassedProposal(proposals: ProposalInfo[]): ProposalInfo {
return last;
}

export function imageNameForProposalEval(proposal) {
const target = `eval-${proposal.proposalName}`;
return {
name: `${repository}:${target}`,
target,
};
}

export function imageNameForProposalTest(proposal) {
const target = `test-${proposal.proposalName}`;
export function imageNameForProposal(
proposal: ProposalCommon,
stage: 'test' | 'eval',
) {
const target = `${stage}-${proposal.proposalName}`;
return {
name: `${repository}:${target}`,
target,
Expand Down
4 changes: 2 additions & 2 deletions debugEvalImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
import { execSync } from 'node:child_process';
import { parseArgs } from 'node:util';
import { imageNameForProposalEval, readOneProposal } from './common';
import { imageNameForProposal, readOneProposal } from './common';

const options = {
match: { short: 'm', type: 'string' },
Expand All @@ -28,7 +28,7 @@ console.log(
);
console.log('And within that shell:');
console.log(' cd /usr/src/proposals/"$PROPOSAL_PATH/" && ./eval.sh');
const { name } = imageNameForProposalEval(proposal);
const { name } = imageNameForProposal(proposal, 'eval');
// start the chain
const cmd = `docker run --mount type=bind,src=.,dst=/usr/src/a3p -it --entrypoint bash ${name}`;
execSync(cmd, { stdio: 'inherit' });
4 changes: 2 additions & 2 deletions debugTestImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
import { execSync } from 'node:child_process';
import { parseArgs } from 'node:util';
import { imageNameForProposalTest, readOneProposal } from './common';
import { imageNameForProposal, readOneProposal } from './common';

const options = {
match: { short: 'm', type: 'string' },
Expand All @@ -31,7 +31,7 @@ To get the latest code from your checkout of the repo:
`,
);

const { name } = imageNameForProposalTest(proposal);
const { name } = imageNameForProposal(proposal, 'test');
// start the chain
const cmd = `docker run --mount type=bind,src=.,dst=/usr/src/a3p -it --entrypoint /usr/src/upgrade-test-scripts/start_agd.sh ${name}`;
execSync(cmd, { stdio: 'inherit' });
4 changes: 2 additions & 2 deletions runTestImages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand All @@ -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' });
Expand Down

0 comments on commit c87d32d

Please sign in to comment.