Skip to content

Commit

Permalink
fixup! build(agd): rely on checksums, not timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Feb 6, 2024
1 parent a3e8e29 commit b58f3bb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
29 changes: 18 additions & 11 deletions .github/actions/restore-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,28 @@ runs:
if test -e ~/endo; then
scripts/get-packed-versions.sh ~/endo | scripts/resolve-versions.sh
fi
cp package.json package.json.orig
yarn install
if cmp -s package.json.orig package.json; then
# We need to generate 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.
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 generate 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
rm package.json.orig
function findsha1() {
find ${1+"$@"} -print0 | xargs -0 sha1sum | sort +1 || true
function diffsha1() {
stamp=$1
shift
find ${1+"$@"} -exec sha1sum {} \; | sort +1 > "$stamp.new" || true
if test ! -s "$stamp.new" -a ! -e "$stamp"; then
echo "No dependencies found for $stamp" 1>&2
return 0
fi
diff -u "$stamp" "$stamp.new" || return 1
return 0
}
# Find the current list of package.jsons.
Expand All @@ -154,7 +161,7 @@ runs:
sed -ne '/"location":/{ s/.*": "//; s!",.*!/package.json!; p; }')
mkdir -p node_modules/.cache/agoric
findsha1 "${files[@]}" > node_modules/.cache/agoric/yarn-installed.sum
diffsha1 node_modules/.cache/agoric/yarn-installed.sum "${files[@]}"
if test -e ~/endo; then
# Stage the redirected `yarn install` consequences.
Expand Down
24 changes: 15 additions & 9 deletions bin/agd
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,16 @@ function fatal() {
exit 1
}

function findsha1() {
find ${1+"$@"} -print0 | xargs -0 sha1sum | sort +1 || true
function diffsha1() {
stamp=$1
shift
find ${1+"$@"} -exec sha1sum {} \; | sort +1 > "$stamp.new" || true
if test ! -s "$stamp.new" -a ! -e "$stamp"; then
echo "No dependencies found for $stamp" 1>&2
return 0
fi
diff -u "$stamp" "$stamp.new" || return 1
return 0
}

GVM_URL=${GVM_URL-https://github.com/devnw/gvm/releases/download/latest/gvm}
Expand All @@ -34,7 +42,9 @@ thisdir=$(cd "$(dirname -- "$real0")" >/dev/null && pwd -P)
# shellcheck disable=SC1091
source "$thisdir/../repoconfig.sh"

NO_BUILD=${NO_BUILD-false}
if test "${1-''}" = build; then
NO_BUILD=false
BUILD_ONLY=true
# Enable shell debugging.
set -x
Expand Down Expand Up @@ -124,9 +134,7 @@ fi
done < <(lazy_yarn -s workspaces info |
sed -ne '/"location":/{ s/.*": "//; s!",.*!/package.json!; p; }')

findsha1 "${files[@]}" > "$sum.new" || true
diff -u "$sum" "$sum.new" || {
echo "$sum has changed"
diffsha1 "$sum" "${files[@]}" || { echo "$sum has changed"; $NO_BUILD; } || {
rm -f "$sum" "$STAMPS/yarn-built"
lazy_yarn install
mv "$sum.new" "$sum"
Expand All @@ -142,12 +150,10 @@ fi
fi

sum=$STAMPS/golang-built.sum
findsha1 "$GOLANG_DIR" \( \
diffsha1 "$sum" "$GOLANG_DIR" \( \
! -name '*_test.go' -name '*.go' \
-o -name '*.cc' \
-o -name 'go.*' \) > "$sum.new" || true
diff -u "$sum" "$sum.new" || {
echo "$GOLANG_DIR $sum has changed"
-o -name 'go.*' \) || { echo "$GOLANG_DIR $sum has changed"; $NO_BUILD; } || {
rm -f "$sum"
(
# Run this build in another subshell in case we had to modify the path.
Expand Down
2 changes: 1 addition & 1 deletion scripts/smoketest-binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

binaries=( "agd version" "agoric -V" "ag-chain-cosmos version" )
for binary in "${binaries[@]}"; do
echo "Checking $binary a"
echo "Checking $binary"
$binary
ec=$?
if [[ $ec -ne 0 ]]; then
Expand Down

0 comments on commit b58f3bb

Please sign in to comment.