Skip to content

Commit bc7014b

Browse files
committed
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 4372221 commit bc7014b

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

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

+15-1
Original file line numberDiff line numberDiff line change
@@ -194,10 +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:
200-
token: ${{ secrets.CODECOV_TOKEN }}
214+
token: ${{ env.CODECOV_TOKEN }}
201215
files: ./coverage.txt
202216
flags: unit
203217
fail_ci_if_error: ${{ github.repository == 'arduino/arduino-cli' }}

0 commit comments

Comments
 (0)