Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect sha calculation for caching #43

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# viash-actions v6.6.1

## Bug fixes

* `project/sync-and-cache`: Fix incorrect sha calculation for caching (PR #43).

# viash-actions v6.6.0

## New functionality
Expand Down
36 changes: 19 additions & 17 deletions project/sync-and-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,32 +85,34 @@ runs:
exit 0
fi

function hash_s3() {
function s3_ls() {
local s3_path="$1"
AWS_EC2_METADATA_DISABLED=true \
aws s3 ls \
"$s3_path" \
--recursive \
--no-sign-request | \
md5sum | \
awk '{ print $1 }'
--no-sign-request
}

hashes=()
ls_content=$(
echo "${{ steps.test_resources.outputs.test_resources }}" | \
while read -r line; do
type=$(echo "$line" | yq e '.type')
path=$(echo "$line" | yq e '.path')
dest=$(echo "$line" | yq e '.dest')

echo "${{ steps.test_resources.outputs.test_resources }}" | \
while read -r line; do
type=$(echo "$line" | yq e '.type')
path=$(echo "$line" | yq e '.path')
dest=$(echo "$line" | yq e '.dest')
if [ "$type" == "s3" ]; then
hash=$(hash_s3 "$path")
fi
echo "dest: $dest, hash: $hash"
hashes+=( "dest: $dest, hash: $hash" )
done
echo "# type: $type, path: $path, dest: $dest"
echo ""

if [ "$type" == "s3" ]; then
s3_ls "$path"
fi

echo ""
done
)

hash=$(echo "${hashes[@]}" | md5sum | awk '{ print $1 }')
hash=$(echo "${ls_content}" | md5sum | awk '{ print $1 }')

echo "cache_key=${{ inputs.cache_key_prefix }}$hash" >> $GITHUB_OUTPUT

Expand Down