Skip to content

Commit

Permalink
add PR comment id to uploaded metadata
Browse files Browse the repository at this point in the history
- passes PR comment id to script used for uploading tarball and metadata file to
  S3 bucket
- script extended to use additional argument and to add the PR comment id to the
  uploaded metadata file
  • Loading branch information
truib committed Feb 14, 2024
1 parent 75893a4 commit fb9e4d9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
22 changes: 18 additions & 4 deletions scripts/eessi-upload-to-staging
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function create_metadata_file
_url=$2
_repository=$3
_pull_request=$4
_pull_request_comment_id=$5

_tmpfile=$(mktemp)

Expand All @@ -56,10 +57,11 @@ function create_metadata_file
--arg url "${_url}" \
--arg repo "${_repository}" \
--arg pr "${_pull_request}" \
--arg pr_comment_id "${_pull_request_comment_id}" \
'{
uploader: {username: $un, ip: $ip, hostname: $hn},
payload: {filename: $fn, size: $sz, ctime: $ct, sha256sum: $sha256, url: $url},
link2pr: {repo: $repo, pr: $pr},
link2pr: {repo: $repo, pr: $pr, pr_comment_id: $pr_commend_id},
}' > "${_tmpfile}"

echo "${_tmpfile}"
Expand All @@ -70,6 +72,10 @@ function display_help
echo "Usage: $0 [OPTIONS] <filenames>" >&2
echo " -e | --endpoint-url URL - endpoint url (needed for non AWS S3)" >&2
echo " -h | --help - display this usage information" >&2
echo " -i | --pr-comment-id - identifier of a PR comment; may be" >&2
echo " used to efficiently determine the PR" >&2
echo " comment to be updated during the" >&2
echo " ingestion procedure" >&2
echo " -n | --bucket-name BUCKET - bucket name (same as BUCKET above)" >&2
echo " -p | --pull-request NUMBER - a pull request NUMBER; used to" >&2
echo " link the upload to a PR" >&2
Expand Down Expand Up @@ -97,8 +103,11 @@ bucket_name="eessi-staging"

# provided via options in the bot's config file app.cfg
endpoint_url=
pull_request=
repository=

# provided via command line arguments
pr_comment_id="none"
pull_request="none"
repository="EESSI/software-layer"

while [[ $# -gt 0 ]]; do
case $1 in
Expand All @@ -110,6 +119,10 @@ while [[ $# -gt 0 ]]; do
display_help
exit 0
;;
-i|--pr-comment-id)
pr_comment_id="$2"
shift 2
;;
-n|--bucket-name)
bucket_name="$2"
shift 2
Expand Down Expand Up @@ -161,7 +174,8 @@ for file in "$*"; do
echo "Creating metadata file"
url="${bucket_base}/${aws_path}/${aws_file}"
metadata_file=$(create_metadata_file "${file}" "${url}" \
"${repository}" "${pull_request}")
"${repository}" "${pull_request}" \
"${pr_comment_id}")
echo "metadata:"
cat ${metadata_file}

Expand Down
1 change: 1 addition & 0 deletions tasks/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ def upload_tarball(job_dir, build_target, timestamp, repo_name, pr_number, pr_co
cmd_args.extend(['--endpoint-url', endpoint_url])
cmd_args.extend(['--repository', repo_name])
cmd_args.extend(['--pull-request', str(pr_number)])
cmd_args.extend(['--pr-comment-id', str(pr_comment_id)])
cmd_args.append(abs_path)
upload_cmd = ' '.join(cmd_args)

Expand Down

0 comments on commit fb9e4d9

Please sign in to comment.