From b4b8b9db6c46d0ef3af99f07d0424cf0e2c38841 Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 15 Aug 2021 04:58:52 -0700 Subject: [PATCH] Avoid workflow conditional reliance on specific runner In order to catch platform-specific bugs, the "Test Go" workflow uses a job matrix to run the tests on multiple runners. The step that uploads code coverage data to Codecov is intended to run only during the Linux job. The runner name `ubuntu-latest` was used in the conditional to accomplish this. However, I'm observing that sometimes it is necessary or desirable to pin a specific runner version (e.g., `ubuntu-18.04`). The accompanying adjustment to the conditional might be forgotten and there would not be any obvious sign that the coverage upload had stopped, nor why. So I'm thinking the better approach would be to use the general `runner.os` context item to identify the Linux job in the conditional. This will not be ideal in the event multiple Linux runners are added to the workflow's job matrix, but I haven't observed that in practice and the double upload shouldn't cause any problems. --- .../workflow-template-copies/.github/workflows/test-go-task.yml | 2 +- workflow-templates/test-go-task.yml | 2 +- 2 files changed, 2 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 7a2e5d80..ec5460d3 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 @@ -68,7 +68,7 @@ jobs: run: task go:test - name: Send unit tests coverage to Codecov - if: matrix.operating-system == 'ubuntu-latest' + if: runner.os == 'Linux' uses: codecov/codecov-action@v2 with: file: ${{ matrix.module.path }}coverage_unit.txt diff --git a/workflow-templates/test-go-task.yml b/workflow-templates/test-go-task.yml index 7a2e5d80..ec5460d3 100644 --- a/workflow-templates/test-go-task.yml +++ b/workflow-templates/test-go-task.yml @@ -68,7 +68,7 @@ jobs: run: task go:test - name: Send unit tests coverage to Codecov - if: matrix.operating-system == 'ubuntu-latest' + if: runner.os == 'Linux' uses: codecov/codecov-action@v2 with: file: ${{ matrix.module.path }}coverage_unit.txt