Skip to content

Commit

Permalink
fix(agoric-cli): implement start --rebuild and use it
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Jan 5, 2022
1 parent 1a004af commit 72f5452
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions packages/agoric-cli/src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions packages/agoric-cli/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
24 changes: 17 additions & 7 deletions packages/agoric-cli/src/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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}`));
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down
8 changes: 7 additions & 1 deletion packages/agoric-cli/tools/getting-started.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 = '';
Expand Down

0 comments on commit 72f5452

Please sign in to comment.