From 16b66ea2adf15be7cbbf68b4321cb41b7d7411c3 Mon Sep 17 00:00:00 2001 From: Shahzad Lone Date: Tue, 28 Nov 2023 10:23:04 -0500 Subject: [PATCH] ci(i): Upload code coverage even if some matrix jobs fail (#2089) ## Relevant issue(s) Resolves #2088 ## Description - Enable uploading whatever coverage reports we have (even if a matrix job failed). - Don't upload coverage reports if manually canceled the workflow/jobs. - Fix coverage reports that were overwritten because of OS name clashing (was uploading only 18 artifacts instead of 20). - Increase retention period to 7 days, for the coverage reports. For example: Currently windows build is flaky, and on a windows build failure it doesn't upload any code coverage reports to codecov. Before this PR the coverage upload job skips: https://github.com/sourcenetwork/defradb/actions/runs/7016532008/job/19088626645 ## Testing ### One Fail so 19 artifacts + Upload successful: Here is a test run to see this working in action: https://github.com/sourcenetwork/defradb/actions/runs/7018970859/attempts/1?pr=2089pr%3D2089 Note: even with 1 failure the build still uploads the report and the total artifact count is 19 (-1 due to windows failure). ### Passed with 20 artifacts + Upload successful: https://github.com/sourcenetwork/defradb/actions/runs/7018970859 --- .github/workflows/test-and-upload-coverage.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-and-upload-coverage.yml b/.github/workflows/test-and-upload-coverage.yml index d92ae01cce..de7c9df848 100644 --- a/.github/workflows/test-and-upload-coverage.yml +++ b/.github/workflows/test-and-upload-coverage.yml @@ -95,18 +95,23 @@ jobs: if: ${{ !matrix.detect-changes }} uses: actions/upload-artifact@v3 with: - name: ${{ matrix.client-type }}_${{ matrix.database-type }}_${{ matrix.mutation-type }} + name: ${{ matrix.os }}_${{ matrix.client-type }}_${{ matrix.database-type }}_${{ matrix.mutation-type }} path: coverage.txt if-no-files-found: error - retention-days: 1 + retention-days: 7 upload-coverage: name: Upload test code coverage job - runs-on: ubuntu-latest - needs: run-tests + # Important to know: + # - We didn't use `if: always()` here, so this job doesn't run if we manually canceled. + # - `if: success()` is always implied unless `always()` or `failure()` is specified. + if: success() || failure() + + runs-on: ubuntu-latest + steps: - name: Checkout code into the directory uses: actions/checkout@v3