Skip to content

Commit 187cdd7

Browse files
committed
Split Codecov upload into a separate job. Make it auto-retry up to five times
1 parent 3fcb113 commit 187cdd7

1 file changed

Lines changed: 38 additions & 5 deletions

File tree

.github/workflows/build.yml

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,16 @@ jobs:
9393
- name: Run specs (unit tests)
9494
run: yarn run test:headless
9595

96+
# Upload code coverage report to artifact (for one version of Node only),
97+
# so that it can be shared with the 'codecov' job (see below)
9698
# NOTE: Angular CLI only supports code coverage for specs. See https://github.com/angular/angular-cli/issues/6286
97-
# Upload coverage reports to Codecov (for one version of Node only)
98-
# https://github.com/codecov/codecov-action
99-
- name: Upload coverage to Codecov.io
100-
uses: codecov/codecov-action@v3
101-
if: matrix.node-version == '16.x'
99+
- name: Upload code coverage report to Artifact
100+
uses: actions/upload-artifact@v3
101+
if: matrix.node-version == '18.x'
102+
with:
103+
name: dspace-angular coverage report
104+
path: 'coverage/dspace-angular/lcov.info'
105+
retention-days: 14
102106

103107
# Using docker-compose start backend using CI configuration
104108
# and load assetstore from a cached copy
@@ -176,3 +180,32 @@ jobs:
176180

177181
- name: Shutdown Docker containers
178182
run: docker-compose -f ./docker/docker-compose-ci.yml down
183+
184+
# Codecov upload is a separate job in order to allow us to restart this separate from the entire build/test
185+
# job above. This is necessary because Codecov uploads seem to randomly fail at times.
186+
# See https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954
187+
codecov:
188+
# Must run after 'tests' job above
189+
needs: tests
190+
runs-on: ubuntu-latest
191+
steps:
192+
- name: Checkout
193+
uses: actions/checkout@v3
194+
195+
# Download artifacts from previous 'tests' job
196+
- name: Download coverage artifacts
197+
uses: actions/download-artifact@v3
198+
199+
# Now attempt upload to Codecov using its action.
200+
# NOTE: We use a retry action to retry the Codecov upload if it fails the first time.
201+
#
202+
# Retry action: https://github.com/marketplace/actions/retry-action
203+
# Codecov action: https://github.com/codecov/codecov-action
204+
- name: Upload coverage to Codecov.io
205+
uses: Wandalen/wretry.action@v1.0.36
206+
with:
207+
action: codecov/codecov-action@v3
208+
# Try upload 5 times max
209+
attempt_limit: 5
210+
# Run again in 30 seconds
211+
attempt_delay: 30000

0 commit comments

Comments
 (0)