From 72f54521f565b395926908811ae60e68f6448b92 Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Sun, 2 Jan 2022 23:08:54 -0600 Subject: [PATCH] fix(agoric-cli): implement `start --rebuild` and use it --- .github/workflows/integration.yml | 3 ++- packages/agoric-cli/src/helpers.js | 2 ++ packages/agoric-cli/src/main.js | 1 + packages/agoric-cli/src/start.js | 24 ++++++++++++++------ packages/agoric-cli/tools/getting-started.js | 8 ++++++- 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index f122f9f6083..c0ab3e57d25 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -87,11 +87,12 @@ jobs: # Use the locally-installed dist-tag. echo 'AGORIC_INSTALL_OPTIONS=["blah"]' >> $GITHUB_ENV + echo 'AGORIC_START_OPTIONS=["--rebuild"]' >> $GITHUB_ENV echo 'AGORIC_CMD=["agoric"]' >> $GITHUB_ENV - name: run agoric-cli integration-test working-directory: ./packages/agoric-cli - run: PATH="$HOME/bin:$PATH" yarn integration-test + run: yarn integration-test env: AGORIC_INIT_OPTIONS: '["--dapp-branch=${{steps.get-branch.outputs.result}}"]' # Try to avoid hitting a pessimal Actions output rate-limitation. diff --git a/packages/agoric-cli/src/helpers.js b/packages/agoric-cli/src/helpers.js index 7ddaf1c3f51..3e281cb9697 100644 --- a/packages/agoric-cli/src/helpers.js +++ b/packages/agoric-cli/src/helpers.js @@ -9,8 +9,10 @@ export const getSDKBinaries = ({ } = {}) => { const myUrl = import.meta.url; const cosmosBuild = ['make', '-C', `${goPfx}/cosmos`, 'all']; + const xsnap = new URL(`${jsPfx}/xsnap`, myUrl).pathname; return { agSolo: new URL(`${jsPfx}/solo/src/entrypoint.js`, myUrl).pathname, + agSoloBuild: ['yarn', '--cwd', xsnap, `build:from-env`], cosmosChain: new URL(`${jsPfx}/cosmic-swingset/bin/ag-chain-cosmos`, myUrl) .pathname, cosmosChainBuild: cosmosBuild, diff --git a/packages/agoric-cli/src/main.js b/packages/agoric-cli/src/main.js index 74a1886479c..9dca81b920b 100644 --- a/packages/agoric-cli/src/main.js +++ b/packages/agoric-cli/src/main.js @@ -197,6 +197,7 @@ const main = async (progname, rawArgs, powers) => { .option('--reset', 'clear all VM state before starting') .option('--no-restart', 'do not actually start the VM') .option('--pull', 'for Docker-based VM, pull the image before running') + .option('--rebuild', 'rebuild VM dependencies before running') .option( '--delay [seconds]', 'delay for simulated chain to process messages', diff --git a/packages/agoric-cli/src/start.js b/packages/agoric-cli/src/start.js index 81798731a84..665b8f2d112 100644 --- a/packages/agoric-cli/src/start.js +++ b/packages/agoric-cli/src/start.js @@ -137,10 +137,11 @@ export default async function startMain(progname, rawArgs, powers, opts) { }; let agSolo; + let agSoloBuild; if (opts.dockerTag) { agSolo = `ag-solo`; } else { - ({ agSolo } = getBinaries()); + ({ agSolo, agSoloBuild } = getBinaries()); } async function startFakeChain(profileName, _startArgs, popts) { @@ -162,6 +163,15 @@ export default async function startMain(progname, rawArgs, powers, opts) { } } + if (opts.pull || opts.rebuild) { + if (!opts.dockerTag && agSoloBuild) { + const exitStatus = await pspawn(agSoloBuild[0], agSoloBuild.slice(1)); + if (exitStatus) { + return exitStatus; + } + } + } + const fakeGCI = 'sim-chain'; if (!(await exists(agServer))) { log(chalk.yellow(`initializing ${profileName}`)); @@ -209,15 +219,15 @@ export default async function startMain(progname, rawArgs, powers, opts) { if (popts.pull || popts.rebuild) { if (popts.dockerTag) { const exitStatus = await pspawn('docker', ['pull', SDK_IMAGE]); - if (exitStatus) { + if (exitStatus !== 0) { return exitStatus; } - } else if (cosmosChainBuild) { + } else { const exitStatus = await pspawn( cosmosChainBuild[0], cosmosChainBuild.slice(1), ); - if (exitStatus) { + if (exitStatus !== 0) { return exitStatus; } } @@ -401,15 +411,15 @@ export default async function startMain(progname, rawArgs, powers, opts) { if (popts.pull || popts.rebuild) { if (popts.dockerTag) { const exitStatus = await pspawn('docker', ['pull', SDK_IMAGE]); - if (exitStatus) { + if (exitStatus !== 0) { return exitStatus; } - } else if (cosmosClientBuild) { + } else { const exitStatus = await pspawn( cosmosClientBuild[0], cosmosClientBuild.slice(1), ); - if (exitStatus) { + if (exitStatus !== 0) { return exitStatus; } } diff --git a/packages/agoric-cli/tools/getting-started.js b/packages/agoric-cli/tools/getting-started.js index fbe14727495..f912da0fb0d 100644 --- a/packages/agoric-cli/tools/getting-started.js +++ b/packages/agoric-cli/tools/getting-started.js @@ -30,6 +30,7 @@ export const gettingStartedWorkflowTest = async (t, options = {}) => { const { init: initOptions = [], install: installOptions = [], + start: startOptions = [], testUnsafePlugins = false, } = options; // FIXME: Do a search for an unused port or allow specification. @@ -122,8 +123,13 @@ export const gettingStartedWorkflowTest = async (t, options = {}) => { // agoric start --reset const startResult = makePromiseKit(); + if (process.env.AGORIC_START_OPTIONS) { + const opts = JSON.parse(process.env.AGORIC_START_OPTIONS); + startOptions.push(...opts); + } + // TODO: Allow this to work even if the port is already used. - const startP = myMain(['start', '--reset']); + const startP = myMain(['start', '--reset', ...startOptions]); finalizers.push(() => pkill(startP.childProcess, 'SIGINT')); let stdoutStr = '';