Skip to content

Commit b043d06

Browse files
Coverage reaches Codecov: every upload signs in with OIDC (#2162)
* Coverage reaches Codecov: every upload signs in with OIDC Codecov takes an upload without a token only from a fork's branch. From a branch of this repository it answers "Token required because branch is protected", and codecov-action logs that and finishes green. None of the four legs had a token, so all four collected coverage and Codecov kept none of it. The newest master commit it holds is 90c00a8, from 2022-11-28, and the newest pull request upload came from a fork on 2026-08-04. On today's master runs of C# Test, F# Test, Interactive Test and C++ Test, and on #2161's C++ Test, every upload step logs that error. Each upload step now sets use_oidc in a job granted id-token: write. That gets a token for the run, so no secret is stored. On a fork's pull request the action skips it and Codecov still takes the upload without a token. fail_ci_if_error is set for pushes to master, so a refused upload turns master red and an outage at Codecov cannot fail a pull request. The cpp flag from #1038 was uploaded but never declared in codecov.yml, so it had no path scope and no carry-forward. It is declared now, scoped to the C++ wrapper that Coverage.md says it measures. Part of #397 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura * codecov.yml is valid: patch and changes sit under status Codecov's validator rejected the file with "Error at ['coverage', 'changes']: unknown field". Since it was added in 2021, `patch: no` and `changes: no` had sat directly under `coverage`, while Codecov reads them under `coverage.status`. For an invalid file Codecov "keep[s] using the last valid YAML provided" (https://docs.codecov.com/docs/codecov-yaml), and this one had no valid version. So the flags #798 declared never applied, and the patch status they meant to turn off has been posted anyway: it appears on #2162. Moved under status, the validator answers Valid! and reads back all four flags with their paths and carry-forward. The comment and Coverage.md give the command to check the next edit. Part of #397 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 583338e commit b043d06

6 files changed

Lines changed: 103 additions & 4 deletions

File tree

‎.github/codecov.yml‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@ coverage:
55
precision: 2
66
round: down
77
range: "50...100"
8-
patch: no
9-
changes: no
8+
# Under status, which is where Codecov reads them. Written directly under coverage, as they
9+
# were from 2021, they made the file invalid, and for an invalid file Codecov "keep[s] using
10+
# the last valid YAML provided" (https://docs.codecov.com/docs/codecov-yaml). This one had
11+
# never been valid, so none of it applied, the flags below included. Check an edit with
12+
# curl -s -X POST --data-binary @.github/codecov.yml https://api.codecov.io/validate
13+
status:
14+
patch: no
15+
changes: no
1016

1117
# Flags are declared so that each one is scoped to the code it actually measures and is
1218
# carried forward when its leg does not run. Both matter here: every flag is uploaded from
13-
# exactly one operating system of its matrix (csharp from windows, fsharp and interactive
14-
# from ubuntu), so on any run where that leg is skipped an undeclared flag reports as
19+
# exactly one operating system of its matrix (csharp from windows, fsharp, interactive and
20+
# cpp from ubuntu), so on any run where that leg is skipped an undeclared flag reports as
1521
# missing rather than unchanged, and the report reads as a coverage drop that did not
1622
# happen. https://github.com/asc-community/AngouriMath/issues/397
1723
flags:
@@ -28,6 +34,10 @@ flags:
2834
- Sources/Wrappers/AngouriMath.Interactive/
2935
- Sources/Terminal/
3036
carryforward: true
37+
cpp:
38+
paths:
39+
- Sources/Wrappers/AngouriMath.CPP.Importing/
40+
carryforward: true
3141

3242
parsers:
3343
gcov:

‎.github/workflows/CPPTest.yml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ jobs:
3838

3939
runs-on: ${{ matrix.os }}
4040

41+
# id-token is what the codecov step signs in with. Naming one permission sets every other to
42+
# none, so contents: read is there for the checkout.
43+
permissions:
44+
contents: read
45+
id-token: write
46+
4147
steps:
4248
- uses: actions/checkout@v6
4349

@@ -130,6 +136,12 @@ jobs:
130136
# reports -- the whole of googletest and of /usr/include/c++/13 -- so the flag would have
131137
# carried everything the filter above exists to exclude. `disable_search` and `plugins: noop`
132138
# keep it to the one report gcovr wrote.
139+
# Codecov takes an upload from a branch of this repository only with a token, and without one
140+
# it rejected them while this step stayed green: master's newest report there is from
141+
# 2022-11-28. use_oidc gets a token for the run; on a fork's pull request the action skips it,
142+
# and Codecov takes that upload without one. A rejected upload fails the run on a push to
143+
# master only, so that an outage at Codecov does not fail a pull request. See
144+
# Sources/AngouriMath/Docs/Contributing/Coverage.md.
133145
- name: 'Send to codecov'
134146
if: ${{ matrix.os == 'ubuntu-latest' }}
135147
uses: codecov/codecov-action@v5
@@ -138,6 +150,8 @@ jobs:
138150
disable_search: true
139151
plugins: noop
140152
flags: cpp
153+
use_oidc: true
154+
fail_ci_if_error: ${{ github.event_name == 'push' }}
141155

142156
- name: 'Upload logs'
143157
if: failure()

‎.github/workflows/CSharpTest.yml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ jobs:
2121

2222
runs-on: ${{ matrix.os }}
2323

24+
# id-token is what the codecov step signs in with. Naming one permission sets every other to
25+
# none, so contents: read is there for the checkout.
26+
permissions:
27+
contents: read
28+
id-token: write
29+
2430
steps:
2531
- uses: actions/checkout@v6
2632
with:
@@ -95,9 +101,17 @@ jobs:
95101
# `files`, not `file`. v5 of the action does not take `file`: it warns about an unexpected
96102
# input, ignores the path, and searches the workspace instead, so the named report was never
97103
# what made this flag.
104+
# Codecov takes an upload from a branch of this repository only with a token, and without one
105+
# it rejected them while this step stayed green: master's newest report there is from
106+
# 2022-11-28. use_oidc gets a token for the run; on a fork's pull request the action skips it,
107+
# and Codecov takes that upload without one. A rejected upload fails the run on a push to
108+
# master only, so that an outage at Codecov does not fail a pull request. See
109+
# Sources/AngouriMath/Docs/Contributing/Coverage.md.
98110
- name: 'Send to codecov'
99111
if: ${{ matrix.os == 'windows-latest' }}
100112
uses: codecov/codecov-action@v5
101113
with:
102114
files: ./Sources/Tests/UnitTests/coverage.opencover.xml
103115
flags: csharp
116+
use_oidc: true
117+
fail_ci_if_error: ${{ github.event_name == 'push' }}

‎.github/workflows/FSharpTest.yml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ jobs:
1616

1717
runs-on: ${{ matrix.os }}
1818

19+
# id-token is what the codecov step signs in with. Naming one permission sets every other to
20+
# none, so contents: read is there for the checkout.
21+
permissions:
22+
contents: read
23+
id-token: write
24+
1925
steps:
2026
- uses: actions/checkout@v6
2127
with:
@@ -43,9 +49,17 @@ jobs:
4349
run: |
4450
dotnet test "Sources/Tests/FSharpWrapperUnitTests" -c Release -l GitHubActions --collect:"XPlat Code Coverage" --results-directory ./coverage -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
4551
52+
# Codecov takes an upload from a branch of this repository only with a token, and without one
53+
# it rejected them while this step stayed green: master's newest report there is from
54+
# 2022-11-28. use_oidc gets a token for the run; on a fork's pull request the action skips it,
55+
# and Codecov takes that upload without one. A rejected upload fails the run on a push to
56+
# master only, so that an outage at Codecov does not fail a pull request. See
57+
# Sources/AngouriMath/Docs/Contributing/Coverage.md.
4658
- name: 'Send to codecov'
4759
if: ${{ matrix.os == 'ubuntu-latest' }}
4860
uses: codecov/codecov-action@v5
4961
with:
5062
directory: ./coverage
5163
flags: fsharp
64+
use_oidc: true
65+
fail_ci_if_error: ${{ github.event_name == 'push' }}

‎.github/workflows/InteractiveTest.yml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ jobs:
1616

1717
runs-on: ${{ matrix.os }}
1818

19+
# id-token is what the codecov step signs in with. Naming one permission sets every other to
20+
# none, so contents: read is there for the checkout.
21+
permissions:
22+
contents: read
23+
id-token: write
24+
1925
steps:
2026
- uses: actions/checkout@v6
2127
with:
@@ -58,9 +64,17 @@ jobs:
5864
dotnet test "Sources/Tests/TerminalUnitTests" -c Release --collect:"XPlat Code Coverage" --results-directory ./coverage -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
5965
dotnet test "Sources/Tests/McpUnitTests" -c Release --collect:"XPlat Code Coverage" --results-directory ./coverage -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
6066
67+
# Codecov takes an upload from a branch of this repository only with a token, and without one
68+
# it rejected them while this step stayed green: master's newest report there is from
69+
# 2022-11-28. use_oidc gets a token for the run; on a fork's pull request the action skips it,
70+
# and Codecov takes that upload without one. A rejected upload fails the run on a push to
71+
# master only, so that an outage at Codecov does not fail a pull request. See
72+
# Sources/AngouriMath/Docs/Contributing/Coverage.md.
6173
- name: 'Send to codecov'
6274
if: ${{ matrix.os == 'ubuntu-latest' }}
6375
uses: codecov/codecov-action@v5
6476
with:
6577
directory: ./coverage
6678
flags: interactive
79+
use_oidc: true
80+
fail_ci_if_error: ${{ github.event_name == 'push' }}

‎Sources/AngouriMath/Docs/Contributing/Coverage.md‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,36 @@ The filter is the honest part. Without it the report is mostly vendored googlete
5757

5858
To reproduce it locally, publish the exporting project as `CPPTest.yml` does, then configure the
5959
tests with the two cmake flags above and run `gcovr` from the build directory.
60+
61+
## How a report reaches Codecov
62+
63+
Codecov takes an upload without a token only from a fork's branch. From a branch of this
64+
repository, `master` included, it answers `Token required because branch is protected`, and
65+
`codecov-action` logs that as an error and finishes green unless `fail_ci_if_error` is set. No
66+
leg had a token or set it, so the four legs collected coverage and Codecov kept none of it: the
67+
newest `master` commit it holds is from 2022-11-28, and the newest pull request upload came from
68+
a fork on 2026-08-04.
69+
70+
Each upload step now sets `use_oidc: true`, in a job granted `id-token: write`. The job asks
71+
GitHub for a token that lasts for the run, so no secret is stored anywhere. On a fork's pull
72+
request the action skips it, since GitHub gives a fork no id-token, and Codecov takes that upload
73+
without one. `fail_ci_if_error` is set on pushes to `master` only, so a rejected upload turns
74+
`master` red, and an outage at Codecov does not fail a pull request.
75+
76+
`.github/codecov.yml` itself had not been valid since it was added: `patch` and `changes` sat
77+
directly under `coverage` instead of under `coverage.status`. Codecov keeps using the last valid
78+
version of an invalid file, and there was none, so the flags it declares had never applied.
79+
Check an edit to it with
80+
81+
```
82+
curl -s -X POST --data-binary @.github/codecov.yml https://api.codecov.io/validate
83+
```
84+
85+
which answers `Valid!` or names the field it rejects.
86+
87+
To check a run, read the upload step's log. `Upload queued for processing complete` is followed
88+
by `Upload queued for processing failed: …` when Codecov refused it. To see what Codecov holds:
89+
90+
```
91+
curl -s 'https://api.codecov.io/api/v2/github/asc-community/repos/AngouriMath/commits/?branch=master'
92+
```

0 commit comments

Comments
 (0)