Skip to content

Commit ad2ef4a

Browse files
committed
Added codecov token in cleartext
The Codecov upload token will be no longer optional in v4 of the action, so it will be necessary to adjust the workflow to provide the token to the action at the same time as the bump. Doing so is a good idea anyway because, although supported in v3, the lack of a token was causing periodic spurious coverage data upload failures. That was done already in the Arduino CLI repo (arduino/arduino-cli#2129) and the approach used there has passed the test of time with flying colors. The workflow does currently use the token input of the action, but it uses the flawed approach of storing it in a secret, which would cause the workflow run to fail on any PR submitted from a fork after the action bump. So the workflow must be updated to use the system implemented in the Arduino CLI workflow.
1 parent f2eee1f commit ad2ef4a

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
@@ -92,11 +92,25 @@ jobs:
9292
GO_MODULE_PATH: ${{ matrix.module.path }}
9393
run: task go:test
9494

95+
# A token is used to avoid intermittent spurious job failures caused by rate limiting.
96+
- name: Set up Codecov upload token
97+
run: |
98+
if [[ "${{ github.repository }}" == "arduino/pluggable-discovery-protocol-handler" ]]; then
99+
# In order to avoid uploads of data from forks, only use the token for runs in this repo.
100+
# Token is intentionally exposed.
101+
# See: https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954
102+
CODECOV_TOKEN="d2497f03-291d-4e0c-9d31-d94614ed7c16"
103+
else
104+
# codecov/codecov-action does unauthenticated upload if empty string is passed via the `token` input.
105+
CODECOV_TOKEN=""
106+
fi
107+
echo "CODECOV_TOKEN=$CODECOV_TOKEN" >> "$GITHUB_ENV"
108+
95109
- name: Send unit tests coverage to Codecov
96110
if: runner.os == 'Linux'
97111
uses: codecov/codecov-action@v3
98112
with:
113+
token: ${{ env.CODECOV_TOKEN }}
99114
file: ${{ matrix.module.path }}coverage_unit.txt
100115
flags: ${{ matrix.module.codecov-flags }}
101-
token: ${{ secrets.CODECOV_TOKEN }}
102116
fail_ci_if_error: ${{ github.repository == 'arduino/pluggable-discovery-protocol-handler' }}

0 commit comments

Comments
 (0)