update handling of GitHub auth for local, interactive use - #172
Conversation
| exit 1 | ||
| fi | ||
|
|
||
| source rapids-prompt-local-github-auth |
There was a problem hiding this comment.
Yes! I came to this conclusion too: #171 (comment)
There was a problem hiding this comment.
Yeah! Everywhere that we invoke gh in a tool that might be used interactively, this should be called.
The if gh auth status makes it idempotent (ensures you aren't put through the interactive login workflow multiple times).
| export RAPIDS_SCRIPT_NAME="rapids-download-from-github" | ||
|
|
||
| if [ -z "$1" ]; then | ||
| if [ -z "${1:-}" ]; then |
There was a problem hiding this comment.
The use of set -u a few lines up means that if you fail to pass any arguments to this script, it never gets through this if and emits the informative error message. Defaulting back to null if ${1} is undefined fixes that.
rapids-download-from-github
# tools/rapids-download-from-github: line 9: $1: unbound variableThere was a problem hiding this comment.
I observed this too and didn’t realize it was a bug. 🥲
There was a problem hiding this comment.
Ha yup! Same thing as conda-forge/arrow-cpp-feedstock#1696, it's easy to trip over stuff like this with set -u.
| export RAPIDS_SCRIPT_NAME="rapids-download-conda-from-github" | ||
|
|
||
| source rapids-prompt-local-repo-config | ||
| source rapids-prompt-local-github-auth |
There was a problem hiding this comment.
Removing this because this script doesn't directly call the gh CLI. These rapids-prompt-local-github-auth calls should only be placed in scripts that directly need GitHub auth, to minimize unnecessary calls.
Found those like this:
git grep 'gh '|
Ok this one's ready for review whenever you have time @bdice |
| export RAPIDS_SCRIPT_NAME="rapids-download-from-github" | ||
|
|
||
| if [ -z "$1" ]; then | ||
| if [ -z "${1:-}" ]; then |
There was a problem hiding this comment.
I observed this too and didn’t realize it was a bug. 🥲
Closes #171
Contributes to https://github.com/rapidsai/build-infra/issues/237
Replaces #168
Some of the scripts in this project use the GitHub CLI. Those require authentication with GitHub.
In CI jobs, that authentication is provided by setting environment variable
GH_TOKEN. When using the scripts interactively (e.g., when reproducing CI), it'd be helpful to prompt for an interactive login flow if the local environment isn't already authenticated.This does that, via that following:
rapids-prompt-local-github-auth, prompts for interactive authentication if not currently auth'd with GitHub (determined viagh auth status)rapids-prompt-local-github-authin every script that uses the GitHub CLI and which might be called interactively (so excludesrapids-upload-to-anaconda-github, for example)Notes for Reviewers
How I tested this
Logged out of GitHub locally.
Tried to download some
rmmconda packages.Got an interactive prompt to login:
Followed that flow, then was logged in and saw packages download successfully.
Ran that same
rapids-download-from-githubcommand again, saw the downloads work and NOT re-prompt for auth.Logged out again, then set the
GH_TOKENenvironment variable to a GitHub "classic" token (docs) that only had thereposcope.Confirming that it only had the
reposcope:Running the same
rapids-download-from-githubcommand as above worked, without re-prompting for auth.Also tested this in an
rmmPR: