Skip to content

Commit 08d746d

Browse files
authored
[skip changelog] Move upload of coverage data to dedicated job in test workflow (#1915)
* Move upload of coverage data to dedicated job in test workflow The code coverage data generated by running the unit tests in the "Test Go" GitHub Actions workflow is uploaded to Codecov. This upload is prone to occasional transient failures. With the previous workflow configuration this caused a failure of the Linux test run job. Contributors would need to review the logs to understand that these failures were not caused by a test failing. The failure also causes the ongoing jobs that run the tests on other operating systems to be immediately canceled, meaning their full test results are not available. The entire test suite must be reran just to attempt the upload again. Moving the upload to a dedicated workflow job makes it faster and easier for contributors to interpret the cause of a test failure. It also allows the test suite to complete for all operating systems, making their results immediately available to the contributor even when the coverage data upload fails. The coverage upload job can be reran, making recovery from a transient failure more efficient. * Use a single step to upload coverage data in "Test Go" workflow The code coverage data generated by running the unit tests in the "Test Go" GitHub Actions workflow is uploaded to Codecov. Arduino CLI's unit tests are split into two collections: those covering the modernized part of the codebase, and those covering the "legacy" code inherited from arduino-builder. A separate code coverage data file is produced for each of these collections. The `codecov/codecov-action` GitHub Actions action is used to perform this upload. Previously, a separate step was used for the upload of each of the code coverage files. The action provides the capability to specify multiple files for upload in a comma-separated list. This approach will make the workflow more efficient and reliable.
1 parent fb9d4a8 commit 08d746d

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

Diff for: .github/workflows/test-go-task.yml

+21-8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ name: Test Go
44
env:
55
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
66
GO_VERSION: "1.17"
7+
COVERAGE_ARTIFACT: coverage-data
78

89
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
910
on:
@@ -99,18 +100,30 @@ jobs:
99100
if: runner.os == 'Linux'
100101
run: task test-legacy
101102

102-
- name: Send unit tests coverage to Codecov
103+
- name: Upload coverage data to workflow artifact
103104
if: runner.os == 'Linux'
104-
uses: codecov/codecov-action@v3
105+
uses: actions/upload-artifact@v3
105106
with:
106-
file: ./coverage_unit.txt
107-
flags: unit
108-
fail_ci_if_error: ${{ github.repository == 'arduino/arduino-cli' }}
107+
if-no-files-found: error
108+
name: ${{ env.COVERAGE_ARTIFACT }}
109+
path: |
110+
./coverage_unit.txt
111+
./coverage_legacy.txt
109112
110-
- name: Send legacy tests coverage to Codecov
111-
if: runner.os == 'Linux'
113+
coverage-upload:
114+
runs-on: ubuntu-latest
115+
needs: test
116+
steps:
117+
- name: Download coverage data artifact
118+
uses: actions/download-artifact@v3
119+
with:
120+
name: ${{ env.COVERAGE_ARTIFACT }}
121+
122+
- name: Send unit tests coverage to Codecov
112123
uses: codecov/codecov-action@v3
113124
with:
114-
file: ./coverage_legacy.txt
125+
files: >
126+
./coverage_unit.txt,
127+
./coverage_legacy.txt
115128
flags: unit
116129
fail_ci_if_error: ${{ github.repository == 'arduino/arduino-cli' }}

0 commit comments

Comments
 (0)