From bd4c8f129ff1cf5aee3a27141e7b6744ffe28a25 Mon Sep 17 00:00:00 2001 From: per1234 Date: Mon, 10 Oct 2022 05:07:45 -0700 Subject: [PATCH 1/2] 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. --- .github/workflows/test-go-task.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-go-task.yml b/.github/workflows/test-go-task.yml index d8266519e59..be0602eb69f 100644 --- a/.github/workflows/test-go-task.yml +++ b/.github/workflows/test-go-task.yml @@ -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,8 +100,26 @@ 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: actions/upload-artifact@v3 + with: + if-no-files-found: error + name: ${{ env.COVERAGE_ARTIFACT }} + path: | + ./coverage_unit.txt + ./coverage_legacy.txt + + 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_unit.txt From 1e470e6370f1a82d285f8401babfc70943342b14 Mon Sep 17 00:00:00 2001 From: per1234 Date: Mon, 10 Oct 2022 05:30:44 -0700 Subject: [PATCH 2/2] 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. --- .github/workflows/test-go-task.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test-go-task.yml b/.github/workflows/test-go-task.yml index be0602eb69f..836940ef262 100644 --- a/.github/workflows/test-go-task.yml +++ b/.github/workflows/test-go-task.yml @@ -122,14 +122,8 @@ jobs: - name: Send unit tests coverage to Codecov uses: codecov/codecov-action@v3 with: - file: ./coverage_unit.txt - flags: unit - fail_ci_if_error: ${{ github.repository == 'arduino/arduino-cli' }} - - - name: Send legacy tests coverage to Codecov - if: runner.os == 'Linux' - 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' }}