-
Notifications
You must be signed in to change notification settings - Fork 207
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
feat: pass tokenless value as branch override #1511
Merged
joseph-sentry
merged 11 commits into
codecov:main
from
joseph-sentry:joseph/fix-tokenless
Aug 29, 2024
Merged
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c56aae1
feat: pass tokenless value as branch override
joseph-sentry 30c7aa0
refactor: change getToken to return nullable output
joseph-sentry 58f4498
fix: quick fix to use Promise resolve in getToken
joseph-sentry 0c23ec5
test: add test for tokenless build commit exec
joseph-sentry f1d218a
test: fix tests
joseph-sentry 66f3555
test: fix tests
joseph-sentry b3582f7
test: fix tests
joseph-sentry 775cafb
test: fix tests
joseph-sentry d7991a5
fix: don't overwrite overrideBranch & add comments decribing getToken
joseph-sentry ad787cf
fix: address feedback
joseph-sentry bc200a8
fix: quick fix to use Promise resolve in getToken
joseph-sentry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,12 +45,12 @@ const isPullRequestFromFork = (): boolean => { | |
return (baseLabel.split(':')[0] !== headLabel.split(':')[0]); | ||
}; | ||
|
||
const getToken = async (): Promise<string> => { | ||
const getToken = async (): Promise<string | null> => { | ||
let token = core.getInput('token'); | ||
if (!token && isPullRequestFromFork()) { | ||
core.info('==> Fork detected, tokenless uploading used'); | ||
process.env['TOKENLESS'] = context.payload.pull_request.head.label; | ||
return Promise.resolve(''); | ||
return null; | ||
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. please write a test for this case |
||
} | ||
let url = core.getInput('url'); | ||
const useOIDC = isTrue(core.getInput('use_oidc')); | ||
|
@@ -60,7 +60,7 @@ const getToken = async (): Promise<string> => { | |
} | ||
try { | ||
token = await core.getIDToken(url); | ||
return token; | ||
return Promise.resolve(token); | ||
} catch (err) { | ||
setFailure( | ||
`Codecov: Failed to get OIDC token with url: ${url}. ${err.message}`, | ||
|
@@ -78,18 +78,21 @@ const buildCommitExec = async (): Promise<{ | |
}> => { | ||
const commitParent = core.getInput('commit_parent'); | ||
const gitService = getGitService(); | ||
const overrideBranch = core.getInput('override_branch'); | ||
let overrideBranch = core.getInput('override_branch'); | ||
const overrideCommit = core.getInput('override_commit'); | ||
const overridePr = core.getInput('override_pr'); | ||
const slug = core.getInput('slug'); | ||
const token = await getToken(); | ||
if (token == null) { | ||
overrideBranch = context.payload.pull_request?.head.label; | ||
matt-codecov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
const failCi = isTrue(core.getInput('fail_ci_if_error')); | ||
const workingDir = core.getInput('working-directory'); | ||
|
||
const commitCommand = 'create-commit'; | ||
const commitExecArgs = []; | ||
|
||
const commitOptions:any = {}; | ||
const commitOptions: any = {}; | ||
commitOptions.env = Object.assign(process.env, { | ||
GITHUB_ACTION: process.env.GITHUB_ACTION, | ||
GITHUB_RUN_ID: process.env.GITHUB_RUN_ID, | ||
|
@@ -178,7 +181,7 @@ const buildReportExec = async (): Promise<{ | |
const reportCommand = 'create-report'; | ||
const reportExecArgs = []; | ||
|
||
const reportOptions:any = {}; | ||
const reportOptions: any = {}; | ||
reportOptions.env = Object.assign(process.env, { | ||
GITHUB_ACTION: process.env.GITHUB_ACTION, | ||
GITHUB_RUN_ID: process.env.GITHUB_RUN_ID, | ||
|
@@ -268,7 +271,7 @@ const buildUploadExec = async (): Promise<{ | |
|
||
const uploadExecArgs = []; | ||
const uploadCommand = 'do-upload'; | ||
const uploadOptions:any = {}; | ||
const uploadOptions: any = {}; | ||
uploadOptions.env = Object.assign(process.env, { | ||
GITHUB_ACTION: process.env.GITHUB_ACTION, | ||
GITHUB_RUN_ID: process.env.GITHUB_RUN_ID, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think a comment on what to expect from
null
is needed here. Also, you are returning a Promise to null here but further down you are returningnull
as is