From 78fc322e3ba552f8c2cad537488522ee49ec0e87 Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Tue, 20 Jun 2023 11:26:29 -0600 Subject: [PATCH 1/2] ci: properly handle subdependencies for Endo branch override --- .github/actions/restore-node/action.yml | 15 ++++++++-- scripts/get-packed-versions.sh | 39 +++++++++++++++++++++++++ scripts/resolve-versions.sh | 19 ++++++++++++ 3 files changed, 70 insertions(+), 3 deletions(-) create mode 100755 scripts/get-packed-versions.sh create mode 100755 scripts/resolve-versions.sh diff --git a/.github/actions/restore-node/action.yml b/.github/actions/restore-node/action.yml index ec924e9c908..62754f63f93 100644 --- a/.github/actions/restore-node/action.yml +++ b/.github/actions/restore-node/action.yml @@ -14,6 +14,11 @@ inputs: required: false default: '0' +outputs: + endo-branch: + description: 'The branch of Endo used (NOPE if no override)' + value: ${{ steps.endo-branch.outputs.result }} + runs: using: composite steps: @@ -98,14 +103,18 @@ runs: sudo apt-get update sudo apt-get install libbsd-dev fi - yarn install # Replace the Endo packages with the ones built from the checked-out branch. if test -e ~/endo; then - scripts/replace-packages.sh ~/endo - rm -rf ~/endo + scripts/get-packed-versions.sh ~/endo | scripts/resolve-versions.sh fi + yarn install mkdir -p node_modules/.cache/agoric date > node_modules/.cache/agoric/yarn-installed + if test -e ~/endo; then + # Remove traces of the redirected `yarn install`. + git restore package.json yarn.lock + rm -rf ~/endo + fi shell: bash if: steps.built.outputs.cache-hit != 'true' - name: yarn build diff --git a/scripts/get-packed-versions.sh b/scripts/get-packed-versions.sh new file mode 100755 index 00000000000..b1a173c5f5f --- /dev/null +++ b/scripts/get-packed-versions.sh @@ -0,0 +1,39 @@ +#! /bin/bash +# Usage: get-packed-versions.sh +# +# This script creates package tarballs in the specified workspace directory and +# writes out information for resolve-versions.sh to update a destination +# workspace to use them. This is useful for testing changes to dependencies of +# the destination repository. +set -xueo pipefail + +WORKDIR=${1:-.} +cd -- "$WORKDIR" 1>&2 + +# Install and build the source directory. +yarn install 1>&2 +yarn build 1>&2 +yarn --silent workspaces info | jq -r '.[].location' | while read -r dir; do + # Skip private packages. + echo "dir=$dir" 1>&2 + test "$(jq .private < "$dir/package.json")" != true || continue + + ################## + pushd "$dir" 1>&2 + + # Gather the metadata. + name=$(jq -r .name < package.json) + version=$(jq -r .version < package.json) + stem=$(echo "$name" | sed -e 's!^@!!; s!/!-!g;') + file="$(pwd)/${stem}-v${version}.tgz" + + # Create the tarball. + yarn pack 1>&2 + + # Write out the version entry. + jq -s --arg name "$name" --arg file "$file" \ + '{ key: $name, value: ("file:" + $file) }' < /dev/null + + popd 1>&2 + ################## +done | jq -s from_entries diff --git a/scripts/resolve-versions.sh b/scripts/resolve-versions.sh new file mode 100755 index 00000000000..c654f3891c8 --- /dev/null +++ b/scripts/resolve-versions.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -ueo pipefail + +# Accepts a dependency version map on stdin and updates the current +# package.json's resolutions section to use the packages and versions from +# the map. +# This is useful for temporary bulk updates over all packages. + +DIR=$(dirname -- "${BASH_SOURCE[0]}") + +cd -- "$DIR/.." + +override=$(jq 'to_entries | map({ key: ("**/" + .key), value: .value }) | from_entries') + +PACKAGEJSONHASH=$( + jq --arg override "$override" '.resolutions *= ($override | fromjson)' package.json | + git hash-object -w --stdin +) +git cat-file blob "$PACKAGEJSONHASH" > package.json From da12531dbe6d3250040f87d70ffadac23ec8af20 Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Tue, 20 Jun 2023 11:28:33 -0600 Subject: [PATCH 2/2] ci(SwingSet): only test golden snapshot hashes with pinned Endo --- .github/workflows/test-all-packages.yml | 8 ++++++++ packages/SwingSet/test/test-xsnap-store.js | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/.github/workflows/test-all-packages.yml b/.github/workflows/test-all-packages.yml index cbc6182f323..26a9d5c4cc1 100644 --- a/.github/workflows/test-all-packages.yml +++ b/.github/workflows/test-all-packages.yml @@ -464,6 +464,8 @@ jobs: - uses: ./.github/actions/restore-node with: node-version: ${{ steps.vars.outputs.node-version }} + id: restore-node + - run: echo "ENDO_BRANCH=${{ steps.restore-node.outputs.endo-branch }}" >> $GITHUB_ENV # END-TEST-BOILERPLATE - name: yarn test (SwingSet) if: (success() || failure()) @@ -504,6 +506,8 @@ jobs: - uses: ./.github/actions/restore-node with: node-version: ${{ steps.vars.outputs.node-version }} + id: restore-node + - run: echo "ENDO_BRANCH=${{ steps.restore-node.outputs.endo-branch }}" >> $GITHUB_ENV # END-TEST-BOILERPLATE - name: yarn test (SwingSet) if: (success() || failure()) @@ -553,6 +557,8 @@ jobs: - uses: ./.github/actions/restore-node with: node-version: ${{ steps.vars.outputs.node-version }} + id: restore-node + - run: echo "ENDO_BRANCH=${{ steps.restore-node.outputs.endo-branch }}" >> $GITHUB_ENV # END-TEST-BOILERPLATE - name: yarn test (SwingSet) if: (success() || failure()) @@ -592,6 +598,8 @@ jobs: - uses: ./.github/actions/restore-node with: node-version: ${{ steps.vars.outputs.node-version }} + id: restore-node + - run: echo "ENDO_BRANCH=${{ steps.restore-node.outputs.endo-branch }}" >> $GITHUB_ENV # END-TEST-BOILERPLATE - name: yarn test (SwingSet) diff --git a/packages/SwingSet/test/test-xsnap-store.js b/packages/SwingSet/test/test-xsnap-store.js index 83b5f51f2ee..3c015ab89d4 100644 --- a/packages/SwingSet/test/test-xsnap-store.js +++ b/packages/SwingSet/test/test-xsnap-store.js @@ -1,3 +1,4 @@ +/* global globalThis */ import '@endo/init/debug.js'; import { spawn } from 'child_process'; @@ -130,6 +131,13 @@ test('create SES worker, save, restore, resume', async t => { * They are also sensitive to the XS code itself. */ test('XS + SES snapshots are long-term deterministic', async t => { + const ENDO_BRANCH = globalThis.process?.env?.ENDO_BRANCH; + if (ENDO_BRANCH && ENDO_BRANCH !== 'NOPE') { + t.log(`Skipping test on ENDO_BRANCH=${ENDO_BRANCH}`); + t.pass(); + return; + } + const db = sqlite3(':memory:'); const store = makeSnapStore(db, () => {}, makeMockSnapStoreIO());