-
Notifications
You must be signed in to change notification settings - Fork 44
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: accept tokenless value from branch instead of env var #475
Conversation
❌ Failed Test Results:Completed 693 tests with View the full list of failed tests
|
4 similar comments
❌ Failed Test Results:Completed 693 tests with View the full list of failed tests
|
❌ Failed Test Results:Completed 693 tests with View the full list of failed tests
|
❌ Failed Test Results:Completed 693 tests with View the full list of failed tests
|
❌ Failed Test Results:Completed 693 tests with View the full list of failed tests
|
❌ 5 Tests Failed:
View the top 3 failed tests by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
❌ Failed Test Results:Completed 693 tests with View the full list of failed tests
|
4 similar comments
❌ Failed Test Results:Completed 693 tests with View the full list of failed tests
|
❌ Failed Test Results:Completed 693 tests with View the full list of failed tests
|
❌ Failed Test Results:Completed 693 tests with View the full list of failed tests
|
❌ Failed Test Results:Completed 693 tests with View the full list of failed tests
|
b0dd421
to
691e159
Compare
❌ Failed Test Results:Completed 694 tests with View the full list of failed tests
|
4 similar comments
❌ Failed Test Results:Completed 694 tests with View the full list of failed tests
|
❌ Failed Test Results:Completed 694 tests with View the full list of failed tests
|
❌ Failed Test Results:Completed 694 tests with View the full list of failed tests
|
❌ Failed Test Results:Completed 694 tests with View the full list of failed tests
|
tokenless = os.environ.get("TOKENLESS") | ||
if tokenless: | ||
if not token and branch and ":" in branch: | ||
headers = None # type: ignore | ||
branch = tokenless # type: ignore | ||
logger.info("The PR is happening in a forked repo. Using tokenless upload.") | ||
else: | ||
headers = get_token_header_or_fail(token) |
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.
strictly speaking, we no longer need any of this logic anymore. we just send whatever we have for the token and the branch, and the API will return a 401 if it's not allowed
the logs may still be helpful, so maybe change to:
if not token:
if branch and ":" in branch:
logger.info("Creating a commit on an unprotected branch")
else:
logger.warning("Token is missing, but branch is missing or protected")
headers = get_token_header(token)
❌ Failed Test Results:Completed 696 tests with View the full list of failed tests
|
4 similar comments
❌ Failed Test Results:Completed 696 tests with View the full list of failed tests
|
❌ Failed Test Results:Completed 696 tests with View the full list of failed tests
|
❌ Failed Test Results:Completed 696 tests with View the full list of failed tests
|
❌ Failed Test Results:Completed 696 tests with View the full list of failed tests
|
❌ Failed Test Results:Completed 696 tests with View the full list of failed tests
|
1 similar comment
❌ Failed Test Results:Completed 696 tests with View the full list of failed tests
|
❌ Failed Test Results:Completed 696 tests with View the full list of failed tests
|
4250717
to
24daf24
Compare
❌ Failed Test Results:Completed 696 tests with View the full list of failed tests
|
2 similar comments
❌ Failed Test Results:Completed 696 tests with View the full list of failed tests
|
❌ Failed Test Results:Completed 696 tests with View the full list of failed tests
|
❌ Failed Test Results:Completed 698 tests with View the full list of failed tests
|
❌ Failed Test Results:Completed 698 tests with View the full list of failed tests
|
❌ Failed Test Results:Completed 698 tests with View the full list of failed tests
|
❌ Failed Test Results:Completed 698 tests with View the full list of failed tests
|
2 similar comments
❌ Failed Test Results:Completed 698 tests with View the full list of failed tests
|
❌ Failed Test Results:Completed 698 tests with View the full list of failed tests
|
✅ All tests successful. No failed tests were found. 📣 Thoughts on this report? Let Codecov know! | Powered by Codecov |
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.
sorry for the whiplash :(
logger.info("The PR is happening in a forked repo. Using tokenless upload.") | ||
else: | ||
headers = get_token_header(token) | ||
headers = get_token_header(token) |
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.
apparently the GHA pulls the latest codecovcli
by default, so users who are still on older versions of the action which use $TOKENLESS
will find themselves suddenly broken if we release this version that stops reading from it
so i guess we should still read from the env var, and i think logs would be valuable if they get printed to the user so they can see hints that maybe their branch name is not what they expected
# Old versions of the GHA use this env var instead of the regular branch
# argument to provide an unprotected branch name
if tokenless := os.environ.get("TOKENLESS"):
branch = tokenless
if branch and ":" in branch:
logger.info(f"Creating a commit for an unprotected branch: {branch}")
elif token is None:
logger.warning(f"Branch `{branch}` is protected but no token was provided\nFor information on Codecov upload tokens, see https://docs.codecov.com/docs/codecov-tokens")
else:
logger.info("Using token to create a commit for protected branch `{branch}`")
headers = get_token_header(token)
0c472db
to
d62c9d8
Compare
# Old versions of the GHA use this env var instead of the regular branch | ||
# argument to provide an unprotected branch name | ||
if tokenless := os.environ.get("TOKENLESS"): | ||
branch = tokenless |
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.
branch = os.environ.get("TOKENLESS", None) could have worked too
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.
that would clobber whatever was already in branch
. we want that value, unless there is a value in $TOKENLESS
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.
@matt-codecov ahhh that's a good point
depends on: codecov/codecov-action#1511
fixes: codecov/engineering-team#2065