Skip to content

Commit 3f15f98

Browse files
committed
Fix premature Codecov status report
The Checks pipeline has 2 separate jobs that upload codecov results - Test and Acceptance. Test job always finishes first, so Codecov calculates status before Acceptance finishes, showing a red status (i.e. reduced coverage) that later turns green. To fix that, upload all coverage together after both Test and Acceptance jobs complete. Ref: https://issues.redhat.com/browse/EC-1591 Assisted-by: Claude
1 parent 9f4e9bf commit 3f15f98

File tree

1 file changed

+73
-27
lines changed

1 file changed

+73
-27
lines changed

.github/workflows/checks-codecov.yaml

Lines changed: 73 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -85,32 +85,15 @@ jobs:
8585
- name: Test
8686
run: make test
8787

88-
- name: Upload unit test coverage report
89-
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
90-
env:
91-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
88+
- name: Upload test coverage artifacts
89+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.0
9290
with:
93-
files: ./coverage-unit.out
94-
disable_search: true
95-
flags: unit
96-
97-
- name: Upload generative test coverage report
98-
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
99-
env:
100-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
101-
with:
102-
files: ./coverage-generative.out
103-
disable_search: true
104-
flags: generative
105-
106-
- name: Upload integration test coverage report
107-
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
108-
env:
109-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
110-
with:
111-
files: ./coverage-integration.out
112-
disable_search: true
113-
flags: integration
91+
name: coverage-test
92+
path: |
93+
./coverage-unit.out
94+
./coverage-generative.out
95+
./coverage-integration.out
96+
retention-days: 1
11497

11598
Acceptance:
11699
runs-on: ubuntu-latest
@@ -149,12 +132,75 @@ jobs:
149132
id: acceptance_test
150133
run: E2E_INSTRUMENTATION=true make acceptance
151134

152-
- name: Upload coverage report
135+
- name: Upload acceptance coverage artifact
136+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.0
137+
with:
138+
name: coverage-acceptance
139+
path: ./coverage-acceptance.out
140+
retention-days: 1
141+
142+
Upload:
143+
name: "Upload Coverage Statistics"
144+
runs-on: ubuntu-latest
145+
needs: [Test, Acceptance]
146+
steps:
147+
- name: Harden Runner
148+
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
149+
with:
150+
egress-policy: audit
151+
disable-telemetry: true
152+
153+
# checkout is required for codecov to map the coverage data back to files in the repo
154+
- name: Checkout repository
155+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
156+
with:
157+
fetch-depth: 0
158+
159+
- name: Download test coverage artifacts
160+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
161+
with:
162+
name: coverage-test
163+
path: ./coverage
164+
165+
- name: Download acceptance coverage artifact
166+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
167+
with:
168+
name: coverage-acceptance
169+
path: ./coverage
170+
171+
- name: Upload unit test coverage report
172+
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
173+
env:
174+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
175+
with:
176+
files: ./coverage/coverage-unit.out
177+
disable_search: true
178+
flags: unit
179+
180+
- name: Upload generative test coverage report
181+
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
182+
env:
183+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
184+
with:
185+
files: ./coverage/coverage-generative.out
186+
disable_search: true
187+
flags: generative
188+
189+
- name: Upload integration test coverage report
190+
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
191+
env:
192+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
193+
with:
194+
files: ./coverage/coverage-integration.out
195+
disable_search: true
196+
flags: integration
197+
198+
- name: Upload acceptance test coverage report
153199
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
154200
env:
155201
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
156202
with:
157-
files: ./coverage-acceptance.out
203+
files: ./coverage/coverage-acceptance.out
158204
disable_search: true
159205
flags: acceptance
160206

0 commit comments

Comments
 (0)