From 12e5994d7f282bb8d96771f691674dd5da829742 Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 12 Aug 2021 23:56:00 -0700 Subject: [PATCH] Don't require Codecov upload success for test run in fork The "Test Go" workflow uploads code coverage data to Codecov. There will occasionally be spurious upload failures caused by transient network outages. These will typically succeed after the workflow is re-run, but the option to re-run is not offered when the workflow run passes. Because it's important that the data be complete, the `codecov/codecov-action` action is configured to fail the workflow run if the upload does not succeed. However, the upload will never be able to succeed for workflow runs in a fork where the owner has not set up Codecov. For this reason, the `fail_ci_if_error` input setting is made conditional upon the repository name. The result is: - Coverage data upload success is required for all workflow runs in the parent repository, including those for PRs submitted from forks (this data is uploaded to the parent repo's Codecov account, so the upload is able to succeed regardless of whether Codecov is enabled for the fork). - Uploads are attempted for workflow runs in forks (because the fork owner might have Codecov set up and want the data), but they are not required to succeed and will fail silently. --- .../workflow-template-copies/.github/workflows/test-go-task.yml | 2 +- workflow-templates/test-go-task.md | 2 ++ workflow-templates/test-go-task.yml | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/workflow-templates/dependabot/workflow-template-copies/.github/workflows/test-go-task.yml b/workflow-templates/dependabot/workflow-template-copies/.github/workflows/test-go-task.yml index 79fa2f74..7a2e5d80 100644 --- a/workflow-templates/dependabot/workflow-template-copies/.github/workflows/test-go-task.yml +++ b/workflow-templates/dependabot/workflow-template-copies/.github/workflows/test-go-task.yml @@ -73,4 +73,4 @@ jobs: with: file: ${{ matrix.module.path }}coverage_unit.txt flags: ${{ matrix.module.codecov-flags }} - fail_ci_if_error: true + fail_ci_if_error: ${{ github.repository == 'REPO_OWNER/REPO_NAME' }} diff --git a/workflow-templates/test-go-task.md b/workflow-templates/test-go-task.md index 210feb1e..fc152b85 100644 --- a/workflow-templates/test-go-task.md +++ b/workflow-templates/test-go-task.md @@ -25,6 +25,8 @@ Configure the version of Go used for development of the project in the `env.GO_V If the project contains Go modules in paths other than the root of the repository, add their paths to the [job matrix](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix) in `check-go-task.yml` at `jobs.test.strategy.matrix.module[].path` and the [Codecov flag](https://docs.codecov.com/docs/flags) to group their data under at `jobs.test.strategy.matrix.module[].codecov-flags` +Replace `REPO_OWNER/REPO_NAME` with the repository's name (e.g., `arduino/arduino-cli`) in the `codecov/codecov-action` action's `fail_ci_if_error` input in `test-go-task.yml`. + #### `.gitignore` Add the following to `.gitignore`: diff --git a/workflow-templates/test-go-task.yml b/workflow-templates/test-go-task.yml index 79fa2f74..7a2e5d80 100644 --- a/workflow-templates/test-go-task.yml +++ b/workflow-templates/test-go-task.yml @@ -73,4 +73,4 @@ jobs: with: file: ${{ matrix.module.path }}coverage_unit.txt flags: ${{ matrix.module.codecov-flags }} - fail_ci_if_error: true + fail_ci_if_error: ${{ github.repository == 'REPO_OWNER/REPO_NAME' }}