Skip to content

Commit 9220b70

Browse files
committed
fix(ci): post coverage to Codecov via bash uploader (excoveralls path)
The previous workflow used codecov/codecov-action@v5, which silently failed in CI with: 'Token required - not valid tokenless upload' Codecov changed their policy in 2024 and now requires a token even for public repos. The action needs either: - CODECOV_TOKEN secret set in repo Settings -> Secrets, OR - The Codecov GitHub App installed on the repo This change uses the excoveralls-recommended path for Codecov: 'mix coveralls.json' (already running) + the official bash uploader downloaded at runtime. The bash uploader reads CODECOV_TOKEN from the env. The step gracefully skips if the secret is unset (prints a notice with the codecov.io setup URL) so the build doesn't fail. Also added documentation in AGENTS.md explaining how to obtain and configure the token, and clarifying why 'mix coveralls.post' is NOT the right path (it posts to coveralls.io, not codecov.io).
1 parent 5de4856 commit 9220b70

2 files changed

Lines changed: 48 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,32 @@ jobs:
8686
# is enforced by the previous step.
8787
run: mix coveralls.json
8888

89-
- name: Upload coverage to Codecov
90-
if: always()
91-
uses: codecov/codecov-action@v5
92-
with:
93-
files: ./cover/excoveralls.json
94-
flags: linux
95-
# No token = Codecov uses its public GitHub App integration
96-
# to pick up coverage from public repos without manual setup.
97-
fail_ci_if_error: false
89+
- name: Post coverage to Codecov
90+
# Push the JSON to codecov.io using their bash uploader. This
91+
# is the path recommended by excoveralls for Codecov (vs the
92+
# GitHub Action, which now requires a token anyway).
93+
#
94+
# Requires CODECOV_TOKEN in repo Settings -> Secrets -> Actions.
95+
# The repo token is at https://codecov.io/gh/gilbertwong96/ado_cli
96+
# -> Settings -> Upload Token. The bash uploader reads it from
97+
# the CODECOV_TOKEN env var.
98+
#
99+
# Skip the step if the secret is not set. We don't fail the
100+
# build over missing coverage uploads — coverage is still
101+
# available as an action artifact download.
102+
env:
103+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
104+
run: |
105+
if [ -z "$CODECOV_TOKEN" ]; then
106+
echo "::notice::CODECOV_TOKEN not set — skipping Codecov upload."
107+
echo "Add it at https://codecov.io/gh/gilbertwong96/ado_cli"
108+
echo "to enable the coverage badge."
109+
exit 0
110+
fi
111+
curl -Os https://uploader.codecov.io/latest/linux/codecov
112+
chmod +x codecov
113+
./codecov --token "$CODECOV_TOKEN" --file ./cover/excoveralls.json
114+
continue-on-error: true
98115

99116
- name: Upload coverage artifact
100117
if: always()

AGENTS.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,28 @@ Codecov dashboard; configuration lives in the `coveralls:` section of
3939
The local `mix ci` command is the source of truth — if it passes locally
4040
it will pass on CI. Never skip a check before pushing.
4141

42+
## Coverage reporting (Codecov)
43+
44+
Coverage is reported to Codecov via the official bash uploader. To enable
45+
it on CI, the user must add a `CODECOV_TOKEN` secret to the repo:
46+
47+
1. Visit https://codecov.io/gh/gilbertwong96/ado_cli
48+
2. Sign in with the same GitHub account
49+
3. Go to Settings -> Upload Token
50+
4. Copy the token
51+
5. In the GitHub repo: Settings -> Secrets and variables -> Actions
52+
-> New repository secret
53+
6. Name: `CODECOV_TOKEN`, Value: <paste token>
54+
55+
The CI step that posts to Codecov is conditional on the secret being
56+
set, so it's safe to leave the repo in this state until the user is
57+
ready. When the secret is present, the codecov.io dashboard will start
58+
showing coverage data within a few minutes of a CI run.
59+
60+
Note: `mix coveralls.post` is NOT the right path here — it posts to
61+
coveralls.io, not codecov.io. For Codecov, the canonical path is
62+
`mix coveralls.json` + the codecov bash uploader.
63+
4264
## Additional Quality Commands
4365

4466
```bash

0 commit comments

Comments
 (0)