Skip to content

Commit ee05ed7

Browse files
committed
fix: change codecov configuration
Signed-off-by: mamoralesiob <miguelangel@io.builders>
1 parent 8cff8d6 commit ee05ed7

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

.github/workflows/100-flow-ats-test.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
- "packages/ats/**"
99
- "apps/ats/**"
1010
- "package.json"
11+
- "codecov.yml"
1112
- ".github/workflows/*ats*.yaml"
1213
workflow_dispatch:
1314

@@ -17,6 +18,7 @@ defaults:
1718

1819
permissions:
1920
contents: read
21+
statuses: read # gate step reads the codecov/project commit status
2022

2123
jobs:
2224
test-ats:
@@ -99,3 +101,33 @@ jobs:
99101
- name: Upload coverage report
100102
if: ${{ steps.generate_coverage.outcome == 'success' }}
101103
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v5.4.0
104+
105+
# Codecov evaluates coverage server-side and posts the `codecov/project`
106+
# commit status asynchronously, after the upload returns. This step waits
107+
# for that status on the PR head commit and fails the job if coverage
108+
# dropped versus the base branch's last uploaded report (target: auto +
109+
# threshold: 0% in codecov.yml).
110+
- name: Enforce coverage did not decrease
111+
if: ${{ github.event_name == 'pull_request' && steps.generate_coverage.outcome == 'success' }}
112+
env:
113+
GH_TOKEN: ${{ github.token }}
114+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
115+
REPO: ${{ github.repository }}
116+
run: |
117+
echo "Waiting for Codecov to post codecov/project for ${HEAD_SHA}..."
118+
state=""
119+
for attempt in $(seq 1 30); do
120+
state=$(gh api "repos/${REPO}/commits/${HEAD_SHA}/statuses" \
121+
--jq 'map(select(.context == "codecov/project")) | .[0].state // ""')
122+
if [ -n "${state}" ] && [ "${state}" != "pending" ]; then
123+
break
124+
fi
125+
echo " attempt ${attempt}/30: state='${state:-<none>}' — retrying in 10s"
126+
sleep 10
127+
done
128+
echo "Final codecov/project state: '${state:-<none>}'"
129+
if [ "${state}" != "success" ]; then
130+
echo "::error::Coverage decreased versus the base branch's last report (codecov/project='${state:-none/timed-out}')."
131+
exit 1
132+
fi
133+
echo "✓ Coverage did not decrease"

codecov.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ coverage:
1010
default:
1111
target: auto
1212
threshold: 0%
13+
if_ci_failed: error
1314
project:
1415
default:
1516
target: auto
1617
threshold: 0%
18+
if_ci_failed: error # don't report success if the test job itself failed
19+
informational: false # blocking status, not advisory (this is the default — explicit here)
1720

1821
ignore:
1922
- "packages/*/dist"

0 commit comments

Comments
 (0)