Skip to content
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

Upload code coverage report to Code Climate in separate workflow #27

Merged
merged 1 commit into from
Mar 5, 2024

Conversation

KevinBrowne
Copy link
Member

One of the jobs in the CI workflow uploads a code coverage report to Code Climate. To so this, it needs a secret. However, CI runs triggered by PRs from forks and Dependabot have no access to the repository secrets, so the upload fails.

Our branch protection rules restrict changes to master to PRs that pass CI checks, among them some Code Climate checks that depend on the coverage report. This means that PRs from forks and from Dependabot can never pass CI.

To work around this, add a separate workflow to upload the report, triggered by the workflow_run event, on the successful completion of the CI workflow. This new workflow will have access to the secrets, even if the triggering workflow did not. It will only fetch and upload the report.

The new workflow depends on the CI workflow having saved the coverage report as an artefact. That change will need to be done in a separate PR. The new workflow will run only if it's already on master, so it needs to land before the CI workflow changes to upload the artefact. It is expected to fail if the report artefact is not present, but this should not fail the CI build.

One of the jobs in the CI workflow uploads a code coverage report to
Code Climate. To so this, it needs a secret. However, CI runs
triggered by PRs from forks and Dependabot have no access to the
repository secrets, so the upload fails.

Our branch protection rules restrict changes to master to PRs that
pass CI checks, among them some Code Climate checks that depend on the
coverage report. This means that PRs from forks and from Dependabot
can never pass CI.

To work around this, add a separate workflow to upload the report,
triggered by the workflow_run event, on the successful completion of
the CI workflow. This new workflow will have access to the secrets,
even if the triggering workflow did not. It will only fetch and upload
the report.

The new workflow depends on the CI workflow having saved the coverage
report as an artefact. That change will need to be done in a separate
PR. The new workflow will run only if it's already on master, so it
needs to land before the CI workflow changes to upload the
artefact. It is expected to fail if the report artefact is not
present, but this should not fail the CI build.
@KevinBrowne KevinBrowne self-assigned this Mar 4, 2024
Copy link

codeclimate bot commented Mar 4, 2024

Code Climate has analyzed commit 8a57a63 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (95% is the threshold).

This pull request will bring the total coverage in the repository to 95.6% (0.0% change).

View more on Code Climate.

@timlapluie timlapluie merged commit b20d4a5 into master Mar 5, 2024
10 checks passed
@timlapluie timlapluie deleted the upload_coverage_report_in_separate_workflow branch March 5, 2024 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants