Skip to content

Commit

Permalink
add s3 and http path scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
AyodeAwe committed Aug 21, 2023
1 parent 6030445 commit 9023b29
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 37 deletions.
43 changes: 43 additions & 0 deletions tools/_rapids-path
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
# _rapids-path
# A utility script to generate the URI path.

set -euo pipefail
source rapids-constants

repo_name="${RAPIDS_REPOSITORY##*/}"

s3_directory_id=""
s3_prefix=""

case "${RAPIDS_BUILD_TYPE}" in
pull-request)
# For PRs, we are using the 'trusted jobs on untrusted forks' paradigm
# by copying PRs to branches named pull-request/$prnum
# more info:
# CopyPRs plugin in ops-bot: https://github.com/rapidsai/ops-bot#plugins
# https://circleci.com/blog/triggering-trusted-ci-jobs-on-untrusted-forks/
s3_directory_id="${RAPIDS_REF_NAME##*/}"
s3_prefix="ci"
;;
branch)
s3_directory_id="${RAPIDS_REF_NAME}"
s3_prefix="ci"
;;
nightly)
s3_directory_id="${RAPIDS_NIGHTLY_DATE}"
s3_prefix="nightly"
;;
*)
rapids-echo-stderr "please pass a valid RAPIDS_BUILD_TYPE"
exit 1
;;
esac

short_hash=${RAPIDS_SHA:0:7}

uri_path="${s3_prefix}/${repo_name}/"
if [[ "${RAPIDS_BUILD_TYPE}" != "nightly" ]]; then
uri_path+="${RAPIDS_BUILD_TYPE}/"
fi
uri_path+="${s3_directory_id}/${short_hash}/"
28 changes: 28 additions & 0 deletions tools/rapids-http-path
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
# rapids-http-path
#
# Calls _rapids-path and prepends the https://downloads.rapids.ai/ string
#
# A utility script that examines environment variables provided
# by GitHub Actions to print out a HTTP path where the expected artifact
# should be.
#
# The output format should be one of the following:
#
## For PR builds:
## https://downloads.rapids.ai/ci/<REPO_NAME>/pull-request/<PR_NUMBER>/<SHORT_HASH>/

## For branch builds:
## https://downloads.rapids.ai/ci/<REPO_NAME>/branch/<BRANCH_NAME>/<SHORT_HASH>/

## For nightly builds:
## https://downloads.rapids.ai/nightly/<REPO_NAME>/<DATE>/<SHORT_HASH>/

source _rapids-path
export RAPIDS_SCRIPT_NAME="rapids-http-path"

RAPIDS_DOWNLOADS_DOMAIN="${RAPIDS_DOWNLOADS_DOMAIN:-downloads.rapids.ai}"

http_path="https://${RAPIDS_DOWNLOADS_DOMAIN}/${uri_path}"

echo -n "${http_path}"
44 changes: 7 additions & 37 deletions tools/rapids-s3-path
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/bash
# rapids-s3-path
#
# Calls _rapids-path and prepends the s3://rapids-downloads/ string
#
# A utility script that examines environment variables provided
# by GitHub Actions to print out an S3 path where the expected artifact
# should be.
Expand All @@ -13,45 +17,11 @@

## For nightly builds:
## s3://rapids-downloads/nightly/<REPO_NAME>/<DATE>/<SHORT_HASH>/
set -euo pipefail
source rapids-constants
source _rapids-path
export RAPIDS_SCRIPT_NAME="rapids-s3-path"

repo_name="${RAPIDS_REPOSITORY##*/}"

s3_directory_id=""
s3_prefix=""

case "${RAPIDS_BUILD_TYPE}" in
pull-request)
# For PRs, we are using the 'trusted jobs on untrusted forks' paradigm
# by copying PRs to branches named pull-request/$prnum
# more info:
# CopyPRs plugin in ops-bot: https://github.com/rapidsai/ops-bot#plugins
# https://circleci.com/blog/triggering-trusted-ci-jobs-on-untrusted-forks/
s3_directory_id="${RAPIDS_REF_NAME##*/}"
s3_prefix="ci"
;;
branch)
s3_directory_id="${RAPIDS_REF_NAME}"
s3_prefix="ci"
;;
nightly)
s3_directory_id="${RAPIDS_NIGHTLY_DATE}"
s3_prefix="nightly"
;;
*)
rapids-echo-stderr "please pass a valid RAPIDS_BUILD_TYPE"
exit 1
;;
esac

short_hash=${RAPIDS_SHA:0:7}
RAPIDS_DOWNLOADS_BUCKET="${RAPIDS_DOWNLOADS_BUCKET:-rapids-downloads}"

s3_path="s3://${RAPIDS_DOWNLOADS_BUCKET}/${s3_prefix}/${repo_name}/"
if [[ "${RAPIDS_BUILD_TYPE}" != "nightly" ]]; then
s3_path+="${RAPIDS_BUILD_TYPE}/"
fi
s3_path+="${s3_directory_id}/${short_hash}/"
s3_path="s3://${RAPIDS_DOWNLOADS_BUCKET}/${uri_path}"

echo -n "${s3_path}"

0 comments on commit 9023b29

Please sign in to comment.