Skip to content

Prevent testcov running on public forks #4837

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

Merged
merged 2 commits into from
Jun 9, 2025
Merged

Conversation

inancgumus
Copy link
Contributor

@inancgumus inancgumus commented Jun 6, 2025

What?

  • Pass a blank CODECOV_TOKEN for public forks.
  • Prevent testcov running on public forks.

Why?

We can't retrieve secrets for public forks (example). Otherwise, we see:

Run grafana/shared-workflows/actions/get-vault-secrets@get-vault-secrets/v1.2.1 Run ${GITHUB_ACTION_PATH}/translate-secrets.bash
Secrets that will be queried from Vault:
ci/data/repo/grafana/k6/CODECOV_TOKEN CODECOV_TOKEN | CODECOV_TOKEN;

Run actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea Error: Error message: Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable
    at OidcClient.<anonymous> (/home/runner/work/_actions/actions/github-script/60a0d83039c74a4aee543508d2ffcb1c3799cdea/dist/index.js:585:23)
    at Generator.next (<anonymous>)
    at /home/runner/work/_actions/actions/github-script/60a0d83039c74a4aee543508d2ffcb1c3799cdea/dist/index.js:522:71
    at new Promise (<anonymous>)
    at __webpack_modules__.8041.__awaiter (/home/runner/work/_actions/actions/github-script/60a0d83039c74a4aee543508d2ffcb1c3799cdea/dist/index.js:518:12)
    at OidcClient.getIDToken (/home/runner/work/_actions/actions/github-script/60a0d83039c74a4aee543508d2ffcb1c3799cdea/dist/index.js:571:16)
    at Object.<anonymous> (/home/runner/work/_actions/actions/github-script/60a0d83039c74a4aee543508d2ffcb1c3799cdea/dist/index.js:421:46)
    at Generator.next (<anonymous>)
    at /home/runner/work/_actions/actions/github-script/60a0d83039c74a4aee543508d2ffcb1c3799cdea/dist/index.js:133:71
    at new Promise (<anonymous>)
Error: Unhandled error: Error: Error message: Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable

Checklist

  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests for my changes.
  • I have run linter and tests locally (make check) and all pass.

Checklist: Documentation (only for k6 maintainers and if relevant)

Please do not merge this PR until the following items are filled out.

  • I have added the correct milestone and labels to the PR.
  • I have updated the release notes: link

Related PR(s)/Issue(s)

Updates grafana/k6-cloud#3525

@inancgumus inancgumus added this to the v1.1.0 milestone Jun 6, 2025
@inancgumus inancgumus self-assigned this Jun 6, 2025
@inancgumus inancgumus requested a review from a team as a code owner June 6, 2025 15:58
@inancgumus inancgumus requested review from mstoykov and codebien and removed request for a team June 6, 2025 15:58
@inancgumus inancgumus added the ci label Jun 6, 2025
@inancgumus inancgumus requested review from joanlopez and removed request for mstoykov June 6, 2025 15:58
We can't retrieve secrets for public forks. Otherwise:

Run grafana/shared-workflows/actions/get-vault-secrets@get-vault-secrets/v1.2.1
Run ${GITHUB_ACTION_PATH}/translate-secrets.bash
Secrets that will be queried from Vault:
ci/data/repo/grafana/k6/CODECOV_TOKEN CODECOV_TOKEN | CODECOV_TOKEN;

Run actions/github-script@60a0d83
Error: Error message: Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable
    at OidcClient.<anonymous> (/home/runner/work/_actions/actions/github-script/60a0d83039c74a4aee543508d2ffcb1c3799cdea/dist/index.js:585:23)
    at Generator.next (<anonymous>)
    at /home/runner/work/_actions/actions/github-script/60a0d83039c74a4aee543508d2ffcb1c3799cdea/dist/index.js:522:71
    at new Promise (<anonymous>)
    at __webpack_modules__.8041.__awaiter (/home/runner/work/_actions/actions/github-script/60a0d83039c74a4aee543508d2ffcb1c3799cdea/dist/index.js:518:12)
    at OidcClient.getIDToken (/home/runner/work/_actions/actions/github-script/60a0d83039c74a4aee543508d2ffcb1c3799cdea/dist/index.js:571:16)
    at Object.<anonymous> (/home/runner/work/_actions/actions/github-script/60a0d83039c74a4aee543508d2ffcb1c3799cdea/dist/index.js:421:46)
    at Generator.next (<anonymous>)
    at /home/runner/work/_actions/actions/github-script/60a0d83039c74a4aee543508d2ffcb1c3799cdea/dist/index.js:133:71
    at new Promise (<anonymous>)
Error: Unhandled error: Error: Error message: Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable
@inancgumus inancgumus force-pushed the prevent-testcov-for-forks branch from cecab14 to 786c5db Compare June 6, 2025 15:59
codebien
codebien previously approved these changes Jun 6, 2025
Copy link
Contributor

@joanlopez joanlopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity; I see the condition (i.e. if) is only set for the step to retrieve the token, does that mean that, when this workflow is executed for a fork, the step right after this one (the one that uploads coverage to Codecov) will fail because it will use a blank token?

If so, I guess it would be better if we can skip that one as well and thus prevent confusing errors.

Other than that, it looks good!

@inancgumus inancgumus merged commit ee27d09 into master Jun 9, 2025
30 of 32 checks passed
@inancgumus inancgumus deleted the prevent-testcov-for-forks branch June 9, 2025 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants