From d1cd6fec7320ef66fcf31769a2f8a0d6a1b14850 Mon Sep 17 00:00:00 2001 From: aalu1418 <50029043+aalu1418@users.noreply.github.com> Date: Mon, 5 Aug 2024 12:58:43 -0600 Subject: [PATCH] fix: compare hashes without paths --- .github/workflows/e2e_custom_cl.yml | 27 ++++++++++++++++++++++---- .github/workflows/upstream-tracker.yml | 20 +++++++++---------- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/.github/workflows/e2e_custom_cl.yml b/.github/workflows/e2e_custom_cl.yml index 52d93442f..36e9b8d1f 100644 --- a/.github/workflows/e2e_custom_cl.yml +++ b/.github/workflows/e2e_custom_cl.yml @@ -103,7 +103,15 @@ jobs: with: name: artifacts path: ./temp/artifacts + - name: hash current artifacts + id: current + run: | + cd ./temp/artifacts # need to be in directory for hashes to compare without path differences + # shellcheck disable=SC2035 + echo "hash=$(sha1sum * | sha1sum)" >> "$GITHUB_OUTPUT" + - name: build contracts + id: previous run: | # TODO: make dynamic container # docker run -d -v "$(pwd)":/repo --name build-container projectserum/build:v0.25.0 tail -f /dev/null @@ -120,13 +128,24 @@ jobs: docker stop build-container docker rm build-container + # copy + save hash + cp ${{ env.CONTRACT_ARTIFACTS_PATH }}/* ./temp/artifacts/previous + cd ./temp/artifacts/previous # need to be in directory for hashes to compare without path differences + # shellcheck disable=SC2035 + echo "hash=$(sha1sum * | sha1sum)" >> "$GITHUB_OUTPUT" + + - name: compare hashes + id: check run: | - echo "current: $(sha1sum ./temp/artifacts/* | sha1sum)" # get hash of current artifacts - mkdir -p temp/artifacts/previous - cp ${{ env.CONTRACT_ARTIFACTS_PATH }}/* temp/artifacts/previous - echo "previous: $(sha1sum ${{ env.CONTRACT_ARTIFACTS_PATH }}/* | sha1sum)" # get hash of previous artifacts + echo "previous: ${{ steps.previous.outputs.hash }}" + echo "current: ${{ steps.current.outputs.hash }}" + + if [ "${{ steps.previous.outputs.hash }}" != "${{ steps.current.outputs.hash }}" ]; then + echo "continue=true" >> "$GITHUB_OUTPUT" + fi - uses: actions/upload-artifact@v4 + if: steps.check.outputs.continue with: name: artifacts path: ./temp/artifacts/ # combine artifacts diff --git a/.github/workflows/upstream-tracker.yml b/.github/workflows/upstream-tracker.yml index 806dd5568..8debc3bba 100644 --- a/.github/workflows/upstream-tracker.yml +++ b/.github/workflows/upstream-tracker.yml @@ -31,18 +31,18 @@ jobs: WIKI="${WIKI//$'\n'/\\n}" # preserve new line printf -v WIKI "%q " "$WIKI" # escape chars that may cause issues - echo "open<> $GITHUB_OUTPUT - echo "$OPEN" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT + echo "open<> "$GITHUB_OUTPUT" + echo "$OPEN" >> "$GITHUB_OUTPUT" + echo "EOF" >> "$GITHUB_OUTPUT" - echo "closed<> $GITHUB_OUTPUT - echo "$CLOSED" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT + echo "closed<> "$GITHUB_OUTPUT" + echo "$CLOSED" >> "$GITHUB_OUTPUT" + echo "EOF" >> "$GITHUB_OUTPUT" - echo "wiki<> $GITHUB_OUTPUT - echo "$WIKI" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - echo "wikirange=$WIKIRANGE" >> $GITHUB_OUTPUT + echo "wiki<> "$GITHUB_OUTPUT" + echo "$WIKI" >> "$GITHUB_OUTPUT" + echo "EOF" >> "$GITHUB_OUTPUT" + echo "wikirange=$WIKIRANGE" >> "$GITHUB_OUTPUT" - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 if: steps.updates.outputs.open || steps.updates.outputs.closed || steps.updates.outputs.wiki - name: Open Issue