Repository navigation
Make Github Run ID selection stricter, update docs #170
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,22 @@ | ||
| #!/bin/bash | ||
| # A utility script that examines environment variables provided | ||
| # by GitHub Actions to print out a Github Workflow Run ID where the expected artifact | ||
| # should be. | ||
| # Determines the GitHub Actions run ID to use in operations with the GitHub API. | ||
| # | ||
| # When environment variable GITHUB_RUN_ID is defined, just returns that value. | ||
| # GITHUB_RUN_ID is set automatically on GitHub Actions. | ||
| # ref: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables | ||
| # | ||
| # Otherwise, tries to determine a run ID based on other context in the environment. | ||
| # Most of that is provided by 'rapids-prompt-local-repo-config', see that | ||
| # script's docs for details. | ||
| # | ||
| # Where multiple run IDs match the supplied configuration, the most-recently-created one | ||
| # is chosen. | ||
| # | ||
| # Additional environment variables recognized by 'rapids-github-run-id': | ||
| # | ||
| # * RAPIDS_BUILD_WORKFLOW_NAME = Filename for the workflow that the run corresponds to. | ||
| # Defaults to 'pr.yaml' for RAPIDS_BUILD_TYPE="pull-request" and 'build.yaml' otherwise). | ||
| # | ||
| set -euo pipefail | ||
| export RAPIDS_SCRIPT_NAME="rapids-github-run-id" | ||
|
|
||
|
|
@@ -13,8 +28,8 @@ case "${RAPIDS_BUILD_TYPE}" in | |
| --branch "${RAPIDS_REF_NAME}" \ | ||
| --commit "${RAPIDS_SHA}" \ | ||
| --workflow "${RAPIDS_BUILD_WORKFLOW_NAME:-pr.yaml}" \ | ||
| --json databaseId \ | ||
| --jq '.[0] | .databaseId')} | ||
| --json 'createdAt,databaseId' \ | ||
| --jq 'sort_by(.createdAt) | reverse | .[0] | .databaseId')} | ||
| ;; | ||
| branch) | ||
| run_id=${GITHUB_RUN_ID:-$(rapids-retry --quiet gh run list \ | ||
|
|
@@ -23,22 +38,30 @@ case "${RAPIDS_BUILD_TYPE}" in | |
| --commit "${RAPIDS_SHA}" \ | ||
| --workflow "${RAPIDS_BUILD_WORKFLOW_NAME:-build.yaml}" \ | ||
| --event "push" \ | ||
| --json databaseId \ | ||
| --jq '.[0] | .databaseId')} | ||
| --json 'createdAt,databaseId' \ | ||
| --jq 'sort_by(.createdAt) | reverse | .[0] | .databaseId')} | ||
| ;; | ||
| nightly) | ||
| # Notice that for nightly runs, this script intentionally does not return GITHUB_RUN_ID. | ||
| # | ||
| # In RAPIDS CI, projects often have 2 separate workflows for nightlies: | ||
| # | ||
| # * build.yaml = builds and uploads packages | ||
| # * test.yaml = installs nightly packages and runs tests | ||
| # | ||
| # From GitHub's perspective, those are different "runs", with different IDs. | ||
| # GitHub Actions organizes artifacts by run ID. | ||
| run_id=$(rapids-retry --quiet gh run list \ | ||
| --repo "${RAPIDS_REPOSITORY}" \ | ||
| --branch "${RAPIDS_REF_NAME}" \ | ||
| --commit "${RAPIDS_SHA}" \ | ||
| --workflow "${RAPIDS_BUILD_WORKFLOW_NAME:-build.yaml}" \ | ||
| --event "workflow_dispatch" \ | ||
| --created "${RAPIDS_NIGHTLY_DATE}" \ | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Proposing here that we remove From the docs in Using this flag creates an awkward association between the time when a workflow is scheduled and the nightly date it is "for". Imagine this sequence:
I think in that case, the test run would fail to download artifacts here: Because Is this likely? I don't know. On the most recent run, it took about 3 hours from when
Situations where we could encounter this problem:
I cannot think of any situation where "get the artifacts from the latest
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good writeup -- I agree.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for reading through it! |
||
| --json databaseId \ | ||
| --jq '.[0] | .databaseId') | ||
| --json 'createdAt,databaseId' \ | ||
| --jq 'sort_by(.createdAt) | reverse | .[0] | .databaseId') | ||
| ;; | ||
| *) | ||
| rapids-echo-stderr "please pass a valid RAPIDS_BUILD_TYPE" | ||
| rapids-echo-stderr "RAPIDS_BUILD_TYPE must be one of [branch, nightly, pull-request]" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| #!/bin/bash | ||
| # | ||
| # A utility script that prompts user to authenticate with GitHub in | ||
| # local environments | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See "How I tested this" in the PR description.
In short,
gh run listdoes not make any strong guarantees about sorting, so just saying "choose the first element in the returned list" is not safe.docs on
gh run list: https://cli.github.com/manual/gh_run_list