From ab663fe928d8e80d74ca2d84df54bcc88ae6a189 Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Mon, 15 Apr 2024 14:20:03 -0600 Subject: [PATCH] ci(restore-node): preserve `package.json` when replacing packages --- .github/actions/restore-node/action.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/actions/restore-node/action.yml b/.github/actions/restore-node/action.yml index de2c7d4fe78..9cb37d4e3d1 100644 --- a/.github/actions/restore-node/action.yml +++ b/.github/actions/restore-node/action.yml @@ -131,21 +131,23 @@ runs: sudo apt-get update sudo apt-get install libbsd-dev fi + + # Preserve the original package.json to restore it after Endo replacements. + cp -a package.json package.json.orig + # Replace the Endo packages with the ones built from the checked-out branch. if test -e ~/endo; then scripts/get-packed-versions.sh ~/endo | scripts/resolve-versions.sh fi yarn install - if ! cmp -s <(git cat-file blob HEAD:package.json) package.json; then - # In the event that the package.json has been modified by Endo - # replacements, we need to have a yarn-installed.sum that matches - # the unmodified package.json. As long as we don't explicitly `yarn - # install` anywhere other than in this action and in the bin/agd - # script, we should be able to reuse even Endo-overridden built caches - # successfully. - git checkout HEAD -- package.json - fi + # In the event that the package.json has been modified by Endo + # replacements, we need to have a yarn-installed timestamp that + # corresponds to the unmodified package.json. As long as we don't + # explicitly `yarn install` anywhere other than in this action and in + # the bin/agd script, we should be able to reuse even Endo-overridden + # built caches successfully. + mv package.json.orig package.json if test -e ~/endo; then # Stage the redirected `yarn install` consequences.