Unverified Commit 08d746dd authored by per1234's avatar per1234 Committed by GitHub

[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.
parent fb9d4a8e
......@@ -4,6 +4,7 @@ name: Test Go
env:
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
GO_VERSION: "1.17"
COVERAGE_ARTIFACT: coverage-data
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
on:
......@@ -99,18 +100,30 @@ jobs:
if: runner.os == 'Linux'
run: task test-legacy
- name: Send unit tests coverage to Codecov
- name: Upload coverage data to workflow artifact
if: runner.os == 'Linux'
uses: codecov/codecov-action@v3
uses: actions/upload-artifact@v3
with:
file: ./coverage_unit.txt
flags: unit
fail_ci_if_error: ${{ github.repository == 'arduino/arduino-cli' }}
if-no-files-found: error
name: ${{ env.COVERAGE_ARTIFACT }}
path: |
./coverage_unit.txt
./coverage_legacy.txt
- name: Send legacy tests coverage to Codecov
if: runner.os == 'Linux'
coverage-upload:
runs-on: ubuntu-latest
needs: test
steps:
- name: Download coverage data artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.COVERAGE_ARTIFACT }}
- name: Send unit tests coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage_legacy.txt
files: >
./coverage_unit.txt,
./coverage_legacy.txt
flags: unit
fail_ci_if_error: ${{ github.repository == 'arduino/arduino-cli' }}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment