Skip to content

Commit a50ab82

Browse files
authored
Merge pull request #368 from per1234/codecov-token
Use token when uploading unit test code coverage data to Codecov from workflow
2 parents 9471ab5 + 4b112e8 commit a50ab82

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Diff for: .github/workflows/unit-tests.yml

+16-1
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,23 @@ jobs:
3535
- '*/src/cbor/lib/*'
3636
coverage-data-path: ${{ env.COVERAGE_DATA_PATH }}
3737

38+
# A token is used to avoid intermittent spurious job failures caused by rate limiting.
39+
- name: Set up Codecov upload token
40+
run: |
41+
if [[ "${{ github.repository }}" == "arduino-libraries/ArduinoIoTCloud" ]]; then
42+
# In order to avoid uploads of data from forks, only use the token for runs in the parent repo.
43+
# Token is intentionally exposed.
44+
# See: https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954
45+
CODECOV_TOKEN="47827969-3fda-4ba1-9506-e8d0834ed88c"
46+
else
47+
# codecov/codecov-action does unauthenticated upload if empty string is passed via the `token` input.
48+
CODECOV_TOKEN=""
49+
fi
50+
echo "CODECOV_TOKEN=$CODECOV_TOKEN" >> "$GITHUB_ENV"
51+
3852
- name: Upload coverage report to Codecov
39-
uses: codecov/codecov-action@v1
53+
uses: codecov/codecov-action@v3
4054
with:
4155
file: "${{ env.COVERAGE_DATA_PATH }}"
4256
fail_ci_if_error: true
57+
token: ${{ env.CODECOV_TOKEN }}

0 commit comments

Comments
 (0)