Skip to content

Commit

Permalink
Merge pull request #720 from heroku/platform-tooling-output-touchups
Browse files Browse the repository at this point in the history
Platform tooling output touchups
  • Loading branch information
dzuelke committed May 30, 2024
2 parents ff65a58 + 38c49c5 commit 90f2713
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/platform-remove.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
- name: Expand list of manifests to remove
run: |
echo '## Manifests input for removal' >> "$GITHUB_STEP_SUMMARY"
set -f
echo ${{inputs.manifests}} | xargs -n 1 echo - >> "$GITHUB_STEP_SUMMARY"
set -f # no expansion of globs to file names, we want to pass * straight on for S3 wildcard matching (but still expand curly braces)
printf -- '- `%s`\n' ${{inputs.manifests}} >> "$GITHUB_STEP_SUMMARY"
- name: Restore cached Docker image
id: restore-docker
uses: actions/cache/restore@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/platform-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
echo '## Stacks to sync' >> "$GITHUB_STEP_SUMMARY"
set -o pipefail
stacks=(${{ inputs.stack-heroku-20 == true && 'heroku-20' || ''}} ${{ inputs.stack-heroku-22 == true && 'heroku-22' || ''}})
printf "%s\n" "${stacks[@]}" | xargs -n1 echo - >> "$GITHUB_STEP_SUMMARY"
printf -- "- %s\n" "${stacks[@]}" >> "$GITHUB_STEP_SUMMARY"
echo -n "matrix=" >> "$GITHUB_OUTPUT"
printf "%s\n" "${stacks[@]}" | jq -jcRn '[inputs|select(length>0)]' >> "$GITHUB_OUTPUT"
docker-build:
Expand Down
9 changes: 3 additions & 6 deletions support/build/_util/remove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,10 @@ pushd "$manifests_tmp" > /dev/null

echo "Fetching manifests, excluding given removals... " >&2
s5cmd "${S5CMD_OPTIONS[@]}" cp ${S3_REGION:+--source-region "$S3_REGION"} "${excludes[@]}" "s3://${S3_BUCKET}/${S3_PREFIX}*.composer.json" "$manifests_tmp" || { echo -e "\nFailed to fetch manifests! See message above for errors." >&2; exit 1; }
echo "...done, now performing a sync of the differences.
" >&2

# we now simply treat this as a sync of packages between two folders, passing sync.sh the local and the remote
echo -e "\nNow performing a sync of the differences:\n" >&2

# we now simply treat this as a sync of packages between two folders, passing sync.sh the local dir as source and the remote as destination
# the "source" repository will have our matched manifests removed

"${here}/sync.sh" -s "$manifests_tmp" "$S3_BUCKET" "$S3_PREFIX" "$S3_REGION" "$S3_BUCKET" "$S3_PREFIX" "$S3_REGION"

echo "Removal complete.
" >&2
25 changes: 11 additions & 14 deletions support/build/_util/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -249,27 +249,27 @@ if [[ $localdst ]] || (( !${#run_manifests_cp[@]} && !${#run_manifests_rm[@]} ))
exit
fi

cat >&2 <<-EOF
WARNING: POTENTIALLY DESTRUCTIVE ACTION!
EOF

(cd "$dst_tmp"; shopt -s nullglob; manifests=( *.composer.json ); (( ${#manifests[@]} < 1 )) ) && {
wipe=true
prompt="Are you sure you want to remove all packages from destination?"
cat >&2 <<-EOF
THE REMOVALS ABOVE WILL DELETE THIS REPOSITORY IN ITS ENTIRETY!
THIS REPOSITORY'S packages.json WOULD BE EMPTY, SO IT WILL BE REMOVED AS WELL!
THE RESULTING EMPTY packages.json WILL BE REMOVED AS WELL!
EOF
} || {
wipe=false
prompt="Are you sure you want to sync to destination & re-generate packages.json?"
}

cat >&2 <<-EOF
WARNING: POTENTIALLY DESTRUCTIVE ACTION!
EOF

read -p "${prompt} [yN] " proceed

[[ ! $proceed =~ [yY](es)* ]] && exit
[[ ! $proceed =~ [yY](es)* ]] && { echo -e "Sync aborted.\n" >&2; exit; }

echo "" >&2

Expand Down Expand Up @@ -297,19 +297,16 @@ fi
if $wipe; then
echo "Removing packages.json..." >&2
AWS_REGION=$dst_region s5cmd "${S5CMD_OPTIONS[@]}" rm "s3://${dst_bucket}/${dst_prefix}packages.json" || { echo -e "\nFailed to remove repository! See message above for errors." >&2; exit 1; }
echo "" >&2
else
echo -n "Generating and uploading packages.json... " >&2
out=$(cd "$dst_tmp"; S3_BUCKET=$dst_bucket S3_PREFIX=$dst_prefix S3_REGION=$dst_region "$here/mkrepo.sh" --upload *.composer.json 2>&1) || { echo -e "failed! Error:\n$out\n\nIn case of transient errors, the repository must be re-generated manually." >&2; exit 1; }
echo "done!
" >&2
echo "Generating and uploading packages.json..." >&2
out=$(cd "$dst_tmp"; S3_BUCKET=$dst_bucket S3_PREFIX=$dst_prefix S3_REGION=$dst_region "$here/mkrepo.sh" --upload *.composer.json 2>&1) || { echo -e "\nFailed to generate/upload repository! Error:\n$out\n\nIn case of transient errors, the repository must be re-generated manually." >&2; exit 1; }
fi
echo "" >&2

if (( ${#run_dists_rm[@]} )); then
echo "Removing ${#run_dists_rm[@]} dists from destination..." >&2
printf -- "%s\n" "${run_dists_rm[@]}" | s5cmd "${S5CMD_OPTIONS[@]}" run || { echo -e "\nOne or more operation(s) failed. In case of transient errors, failed removals must be performed manually." >&2; exit 1; }
echo "" >&2
fi

echo "Sync complete.
" >&2
echo -e "Sync complete.\n" >&2

0 comments on commit 90f2713

Please sign in to comment.