Skip to content

Commit 5a67f3b

Browse files
authored
[skip-changelog] Added codecov token to solve code-coverage upload issues (#2129)
* Added codecov token to solve upload issues * Use CODECOV_TOKEN also on pull-request runs. It requires to expose the token, this is intentional. https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954
1 parent a9729db commit 5a67f3b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Diff for: .github/workflows/test-go-task.yml

+15
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,24 @@ jobs:
194194
- name: Merge all code coverage artifacts
195195
run: gocovmerge coverage*.txt > coverage.txt
196196

197+
# A token is used to avoid intermittent spurious job failures caused by rate limiting.
198+
- name: Set up Codecov upload token
199+
run: |
200+
if [[ "${{ github.repository }}" == "arduino/arduino-cli" ]]; then
201+
# In order to avoid uploads of data from forks, only use the token for runs in the arduino/arduino-ide repo.
202+
# Token is intentionally exposed.
203+
# See: https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954
204+
CODECOV_TOKEN="18b9885b-cbf2-4166-bfbb-39617323daf0"
205+
else
206+
# codecov/codecov-action does unauthenticated upload if empty string is passed via the `token` input.
207+
CODECOV_TOKEN=""
208+
fi
209+
echo "CODECOV_TOKEN=$CODECOV_TOKEN" >> "$GITHUB_ENV"
210+
197211
- name: Send unit tests coverage to Codecov
198212
uses: codecov/codecov-action@v3
199213
with:
214+
token: ${{ env.CODECOV_TOKEN }}
200215
files: ./coverage.txt
201216
flags: unit
202217
fail_ci_if_error: ${{ github.repository == 'arduino/arduino-cli' }}

0 commit comments

Comments
 (0)