Skip to content

Commit

Permalink
Merge pull request #8250 from Agoric/mfig-ci-npx
Browse files Browse the repository at this point in the history
ci(getting-started): run (but ignore) checks with `npm` and `npx`
  • Loading branch information
mergify[bot] authored Aug 29, 2023
2 parents 20cbc3a + dd2873d commit 3ce0599
Show file tree
Hide file tree
Showing 11 changed files with 207 additions and 57 deletions.
61 changes: 7 additions & 54 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ jobs:
strategy:
fail-fast: false
matrix:
cli: [link-cli, local-npm]
# Mark a failure of `local-npm` as a successful result
# TODO: remove when `local-npm` job is fixed
continue-on-error: ${{ matrix.cli == 'local-npm' }}
cli: [link-cli/yarn, registry/yarn, registry/npm, registry/npx]
timeout-minutes: 40
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -95,60 +92,16 @@ jobs:
- run: yarn install --frozen-lockfile
- run: yarn build

- name: Link Agoric CLI from SDK
if: ${{ matrix.cli == 'link-cli' }}
run: |
yarn link-cli "$HOME/bin/agoric"
echo "AGORIC_CMD=[\"$HOME/bin/agoric\"]" >> $GITHUB_ENV
- name: Start local NPM registry
if: ${{ matrix.cli == 'local-npm' }}
if: ${{ startsWith(matrix.cli, 'registry') }}
run: |
tmp_registry_log=`mktemp`
dist_tag=agblah
nohup npx verdaccio@^5.4.0 &>$tmp_registry_log &
# Wait for `verdaccio` to boot
grep -q 'http address' <(tail -f $tmp_registry_log)
# Set registry to local registry
npm set registry http://localhost:4873
yarn config set registry http://localhost:4873
# Login so we can publish packages
npx npm-cli-login@^1.0.0 -u user -p password -e [email protected] \
-r http://localhost:4873 --quotes
npm whoami
# Publish the packages to our local service.
# without concurrency until https://github.com/Agoric/agoric-sdk/issues/8091
yarn lerna publish --concurrency 1 --conventional-prerelease --canary --exact \
--dist-tag=$dist_tag --preid=dev-$(git rev-parse --short=7 HEAD) \
--no-push --no-verify-access --yes
# Git dirty check.
if [[ -n "$(git status --porcelain)" ]]; then
echo "Git status is dirty, aborting."
git status
exit 1
fi
# Install the Agoric CLI on this machine's $PATH.
yarn global add agoric@$dist_tag </dev/null
# Use the locally-installed dist-tag.
echo "AGORIC_INSTALL_OPTIONS=[\"$dist_tag\"]" >> $GITHUB_ENV
echo 'AGORIC_START_OPTIONS=["--rebuild"]' >> $GITHUB_ENV
echo 'AGORIC_CMD=["agoric"]' >> $GITHUB_ENV
scripts/registry.sh bg-publish ${{ matrix.cli }}
- name: run agoric-cli integration-test
working-directory: ./packages/agoric-cli
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.
SOLO_MAX_DEBUG_LENGTH: '1024'
run: scripts/registry.sh test ${{ matrix.cli }} ${{steps.get-branch.outputs.result}}
# TODO(mfig): remove this `continue` line when the next Endo release
# (after 2023-08-23) is incorporated in Agoric SDK.
continue-on-error: ${{ startsWith(matrix.cli, 'registry/np') }}

- name: notify on failure
if: >
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/sdk-package-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default [
"@agoric/cosmic-swingset",
"@agoric/cosmos",
"@agoric/deploy-script-support",
"@agoric/deployment",
"@agoric/ertp",
"@agoric/eslint-config",
"@agoric/governance",
Expand All @@ -27,7 +28,6 @@ export default [
"@agoric/solo",
"@agoric/sparse-ints",
"@agoric/spawner",
"@agoric/ssh-node",
"@agoric/stat-logger",
"@agoric/store",
"@agoric/swing-store",
Expand Down
Empty file added packages/boot/CHANGELOG.md
Empty file.
Empty file added packages/builders/CHANGELOG.md
Empty file.
11 changes: 11 additions & 0 deletions packages/builders/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": [
"./tsconfig.json",
"../../tsconfig-build-options.json"
],
"exclude": [
"scripts",
"test",
"**/exports.js",
]
}
2 changes: 1 addition & 1 deletion packages/deployment/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@agoric/ssh-node",
"name": "@agoric/deployment",
"version": "3.0.0",
"description": "Set up Agoric public chain nodes",
"type": "module",
Expand Down
1 change: 0 additions & 1 deletion packages/inter-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
"import-meta-resolve": "^2.2.1"
},
"files": [
"bundles",
"scripts",
"src/",
"exported.js",
Expand Down
Empty file added packages/network/CHANGELOG.md
Empty file.
Empty file added packages/vm-config/CHANGELOG.md
Empty file.
33 changes: 33 additions & 0 deletions patches/@lerna+version+5.6.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
diff --git a/node_modules/@lerna/version/lib/git-add.js b/node_modules/@lerna/version/lib/git-add.js
index d24f8ca..9b9b38d 100644
--- a/node_modules/@lerna/version/lib/git-add.js
+++ b/node_modules/@lerna/version/lib/git-add.js
@@ -24,12 +24,12 @@ function resolvePrettier() {
return resolvedPrettier;
}

-function maybeFormatFile(filePath) {
+async function maybeFormatFile(filePath) {
const prettier = resolvePrettier();
if (!prettier) {
return;
}
- const config = resolvedPrettier.resolveConfig.sync(filePath);
+ const config = await resolvedPrettier.resolveConfig(filePath);
try {
const input = fs.readFileSync(filePath, "utf8");
fs.writeFileSync(filePath, resolvedPrettier.format(input, { ...config, filepath: filePath }), "utf8");
@@ -44,11 +44,11 @@ function maybeFormatFile(filePath) {
* @param {{ granularPathspec: boolean; }} gitOpts
* @param {import("@lerna/child-process").ExecOpts} execOpts
*/
-function gitAdd(changedFiles, gitOpts, execOpts) {
+async function gitAdd(changedFiles, gitOpts, execOpts) {
let files = [];
for (const file of changedFiles) {
const filePath = slash(path.relative(execOpts.cwd, path.resolve(execOpts.cwd, file)));
- maybeFormatFile(filePath);
+ await maybeFormatFile(filePath);
if (gitOpts.granularPathspec) {
files.push(filePath);
}
154 changes: 154 additions & 0 deletions scripts/registry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
#! /bin/bash

thisdir=$(cd -- "$(dirname "$0")" >/dev/null && pwd)

set -ueo pipefail

# Report, export, and write an environment variable into "$GITHUB_ENV" if set.
persistVar() {
echo "$1=$2"
eval "export $1=\$2"
test -z "${GITHUB_ENV-}" || {
echo "$1=$2" >> "$GITHUB_ENV"
}
}

runRegistry() {
# shellcheck disable=SC2155
export HOME="$(mktemp -d -t registry-home.XXXXX)"
export PATH="$thisdir:$PATH"

# Kill `verdaccio` when the script exits
trap 'kill $(cat "$HOME/verdaccio.pid")' EXIT

(
cd "$HOME"
echo "Starting Verdaccio in background..."
: > verdaccio.log
nohup npx verdaccio@^5.4.0 &>verdaccio.log &
echo $! > verdaccio.pid

# Wait for `verdaccio` to boot
grep -q 'http address' <(tail -f verdaccio.log)

# Set registry to local registry
npm set registry http://localhost:4873
yarn config set registry http://localhost:4873

# Login so we can publish packages
npx npm-cli-login@^1.0.0 -u user -p password -e [email protected] \
-r http://localhost:4873 --quotes

npm whoami
) 1>&2
}

publish() {
export DISTTAG=agblah
case $1 in
manual*)
flags=--no-git-tag-version
;;
*)
flags=--canary
;;
esac

# Publish the packages to our local service.
# without concurrency until https://github.com/Agoric/agoric-sdk/issues/8091
yarn lerna publish --concurrency 1 --conventional-prerelease $flags --exact \
--dist-tag="$DISTTAG" --preid=dev"-$(git rev-parse --short=7 HEAD)" \
--no-push --no-verify-access --yes

# Use the locally-installed dist-tag.
persistVar REGISTRY_HOME "$HOME"
persistVar REGISTRY_DISTTAG "$DISTTAG"
}

integrationTest() {
# Install the Agoric CLI on this machine's $PATH.
case $1 in
link-cli | link-cli/*)
yarn link-cli "$HOME/bin/agoric"
persistVar AGORIC_CMD "[\"$HOME/bin/agoric\"]"
;;
*/npm)
npm install -g "agoric@$DISTTAG"
persistVar AGORIC_CMD '["agoric"]'
;;
*/npx)
# Install on demand.
persistVar AGORIC_CMD "[\"npx\",\"agoric@$DISTTAG\"]"
;;
*)
yarn global add "agoric@$DISTTAG"
persistVar AGORIC_CMD '["agoric"]'
;;
esac

test -z "${DISTTAG-}" || {
persistVar AGORIC_INSTALL_OPTIONS "[\"$DISTTAG\"]"
}
persistVar AGORIC_START_OPTIONS '["--rebuild"]'
persistVar AGORIC_INIT_OPTIONS "[\"--dapp-branch=$2\"]"

(
cd "$thisdir/../packages/agoric-cli"

# Try to avoid hitting a pessimal Actions output rate-limitation.
SOLO_MAX_DEBUG_LENGTH=1024 \
yarn integration-test
)
}

export CI=true
case ${1-} in
ci)
runRegistry
publish "${2-manual}"
integrationTest "${2-manual}" "${3-main}"
;;

bg)
runRegistry
echo "Publish packages using '$0 publish'"
trap - EXIT
echo "HOME=$HOME"
echo "pid=$(cat "$HOME/verdaccio.pid")"
;;

bg-publish)
runRegistry
trap - EXIT
publish "${2-registry}"

# Git dirty check.
if [[ -n "$(git status --porcelain)" ]]; then
echo "Git status is dirty, aborting."
git status
exit 1
fi
;;

publish)
publish "${2-manual}"
echo "Run getting-started integration test with '$0 test'"
;;

test)
test -z "${REGISTRY_HOME-}" || export HOME="$REGISTRY_HOME"
test -z "${REGISTRY_DISTTAG-}" || export DISTTAG="$REGISTRY_DISTTAG"
integrationTest "${2-manual}" "${3-main}"
;;

*)
runRegistry
echo "Publish packages using '$0 publish'"
# Kill `verdaccio` and remove HOME when the command shell exits
trap 'kill "$(cat "$HOME/verdaccio.pid")"; rm -rf "$HOME"' EXIT
if test $# -eq 0; then
set -- bash
fi
"$@"
;;
esac

0 comments on commit 3ce0599

Please sign in to comment.