Upload code coverage report to Code Climate in separate workflow #27
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.
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.