-
Notifications
You must be signed in to change notification settings - Fork 13
Fix faulty error output on empty cache #30
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
Fix faulty error output on empty cache #30
Conversation
Ok, this works a little more gracefully and I was actually able to test it. Instead of relying on exit codes, we can just explicitly set a step output and not throw any errors. If we can validate everything, then skip authenticating, else continue to authenticate. |
Do we have a date on when this can be merge? It's been more than 5 months and we are still waiting for this fix/feature to be integrated in the master branch please @pwtyler @namespacebrian |
I'm trying this PR in pantheon-systems/push-to-pantheon#38 and it seems to resolve the "exit 1" problem, but as I look for evidence of caching across jobs, it seems like it is not actually caching across jobs. Here is output from a 2nd serial job: |
# Check for restored user (string) or allow command to fail gracefully. | ||
TERMINUS_USER=$(terminus auth:whoami || true) | ||
|
||
# Check TERMINUS_USER for string. | ||
if [ -z "$TERMINUS_USER" ]; then | ||
echo "No valid session found. " | ||
exit 1 | ||
exit 0 | ||
fi |
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.
# Check for restored user (string) or allow command to fail gracefully.
TERMINUS_USER=""
if ! TERMINUS_USER=$(terminus auth:whoami); then
echo "terminus auth:whoami failed: ${TERMINUS_USER}"
echo "No valid session found."
exit 0
fi
# Also assert TERMINUS_USER is a string.
if [ -z "$TERMINUS_USER" ]; then
echo "No valid session found. "
exit 0
fi
the or true
inside the subshell smells to me, although I can't actually rationalize to myself why it's not fine. Setting TERMINUS_USER before does prevent the assignment from masking the exit code.
|
||
# Verify that the encrypted session file was restored from cache. | ||
test -s ${{ steps.configure-cache.outputs.path }} | ||
if [ ! -s "${{ steps.configure-cache.outputs.path }}" ]; then |
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.
if [ ! -s "${{ steps.configure-cache.outputs.path }}" ]; then | |
if [[ ! -s "${{ steps.configure-cache.outputs.path }}" ]]; then |
we're in bash, use bash.
|| true
is not a good solution because it will assign the variable to true
To be fully confident, I would want to have a workflow that used this and hit the rate limit without adding the caching stuff around it, and then didn't it the rate limit once that scaffolding was added. If we could get a customer who uses the caching to avoid the rate limit to test this, that'd be enough, but I'm not sure we have a eager guinea pig. We could create 2 workflows on this repo, one that doesn't use the caching and one that does.. |
When there's no existing cache, we skip the step with an
exit 1
, but that also produces an error output for the step. Instead, this will exit gracefully (exit 0
) by skipping the step and continuing to the next step to authenticate.fixes #29