Skip to content

Commit

Permalink
Merge pull request #9128 from Agoric/mfig-unflake-deployment-test
Browse files Browse the repository at this point in the history
build(agd): more careful `stamp.sum` handling
  • Loading branch information
mergify[bot] authored Mar 22, 2024
2 parents 0025f91 + 8cea60c commit ec7c6fc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
10 changes: 5 additions & 5 deletions .github/actions/restore-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ runs:
function diffsha1() {
stamp=$1
shift
find ${1+"$@"} -exec sha1sum {} \; | sort +1 > "$stamp.new" || true
if test ! -s "$stamp.new"; then
find ${1+"$@"} -exec sha1sum {} \; | sort +1 > "$stamp.files" || true
if test ! -s "$stamp.files"; then
echo "No new dependencies found for $stamp" 1>&2
return 0
fi
diff -u "$stamp" "$stamp.new" || return 1
diff -u "$stamp" "$stamp.files" || return 1
return 0
}
Expand All @@ -171,9 +171,9 @@ runs:
mkdir -p "$STAMPS"
sum="$STAMPS/yarn-installed.sum"
diffsha1 "$sum" "${files[@]}" || {
mv "$sum.new" "$sum"
mv "$sum.files" "$sum"
}
rm -f "$sum.new"
rm -f "$sum.files"
if test -e ~/endo; then
# Stage the redirected `yarn install` consequences.
Expand Down
33 changes: 20 additions & 13 deletions bin/agd
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,29 @@ for cmd in sha1sum shasum sha1sum; do
command -v $DIGEST_CMD &>/dev/null && break
done

# diffsha1 stamp_name find_args...
# executes find(1) with the given arguments and saves the resulting file list,
# then runs $DIGEST_CMD on the file list, saves the digest to file stamp_name.files,
# and compares to the saved digest in the file stamp_name.
# Returns success (0) if it cannot write to the temporary files, if the find results are empty,
# or if the computed digest is the same as the saved digest.
# Returns failure (1) if the computed digest is different.
function diffsha1() {
stamp=$1
shift
if ! (true > "$stamp.new") 2>/dev/null; then
# echo "Cannot write to $stamp.new" 1>&2
find ${1+"$@"} > "$stamp.files.$$"
if test ! -s "$stamp.files.$$"; then
# echo "No new dependencies found for $stamp" 1>&2
rm -f "$stamp.files.$$"
return 0
fi
find ${1+"$@"} > "$stamp.new.files"
if test ! -s "$stamp.new.files"; then
# echo "No new dependencies found for $stamp" 1>&2
rm -f "$stamp.new.files"
xargs $DIGEST_CMD <"$stamp.files.$$" | sort +1 > "$stamp.files" || true
rm -f "$stamp.files.$$"
if test ! -s "$stamp.files"; then
rm -f "$stamp.files"
return 0
fi
xargs $DIGEST_CMD <"$stamp.new.files" | sort +1 > "$stamp.new" || true
rm -f "$stamp.new.files"
diff -u "$stamp" "$stamp.new" || return 1
diff -u "$stamp" "$stamp.files" || return 1
return 0
}

Expand Down Expand Up @@ -170,8 +177,8 @@ ${NO_BUILD:-false} || (
fi
)
}
test -f "$sum" || mv -f "$sum.new" "$sum"
rm -f "$sum.new"
test -f "$sum" || mv -f "$sum.files" "$sum"
rm -f "$sum.files"

if $need_nodejs; then
lazy_yarn() {
Expand All @@ -197,9 +204,9 @@ ${NO_BUILD:-false} || (
diffsha1 "$sum" "${files[@]}" || { echo "$sum has changed"; $do_not_build; } || {
rm -f "$sum" "$STAMPS/yarn-built"
lazy_yarn install
mv "$sum.new" "$sum"
mv "$sum.files" "$sum"
}
rm -f "$sum.new"
rm -f "$sum.files"

stamp=$STAMPS/yarn-built
test -e "$stamp" || {
Expand Down

0 comments on commit ec7c6fc

Please sign in to comment.