Skip to content

Commit 9725e22

Browse files
Shaunak01dremdem
andauthored
HelpersTask597_Configure_Codecov_for_coverage (#598)
* testing * testing * testing * testing * testing * testing * testing * testing * testing * testing * checkpoint * checkpoint * checkpoint * test with superslow * test * test * test * test * flag test * flag test * flag test * test * test * test * test * checkpoint * test * test * test * checkpoint * test * test * test * test * test * checkpoint * checkpoint * test * test * checkpoint * test * test * test * test * test * test * debug * test * test * test * checkpoint * checkpoint * Test Pre-commit checks: - 'check_master' passed - 'check_author' passed - 'check_file_size' passed - 'check_python_compile' passed - 'check_gitleaks' passed All checks passed ✅ * Test Pre-commit checks: - 'check_master' passed - 'check_author' passed - 'check_file_size' passed - 'check_python_compile' passed - 'check_gitleaks' passed All checks passed ✅ * Test Pre-commit checks: - 'check_master' passed - 'check_author' passed - 'check_file_size' passed - 'check_python_compile' passed - 'check_gitleaks' passed All checks passed ✅ * Checkpoint Pre-commit checks: - 'check_master' passed - 'check_author' passed - 'check_file_size' passed - 'check_python_compile' passed - 'check_gitleaks' passed All checks passed ✅ --------- Co-authored-by: Vlad <dremdem@gmail.com>
1 parent 4874e7b commit 9725e22

File tree

7 files changed

+694
-372
lines changed

7 files changed

+694
-372
lines changed

.coveragerc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[report]
2+
# Glob pattern(s) of files to omit from the report.
3+
omit =
4+
*/devops/compose/*
5+
*/helpers/test/outcomes/*/tmp.scratch/*

.github/gh_requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1+
boto3 >= 1.20.17
2+
coverage
13
invoke
2-
tqdm
34
s3fs
4-
boto3 >= 1.20.17
5+
tqdm

.github/workflows/coverage_tests.yml

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
name: Test coverage
2+
3+
on:
4+
workflow_dispatch: {}
5+
# every day at 00:00 UTC.
6+
schedule:
7+
- cron: '0 0 * * *'
8+
9+
env:
10+
CSFY_CI: true
11+
12+
permissions:
13+
# Required to authenticate and retrieve temporary AWS credentials via OIDC.
14+
id-token: write
15+
# Required to fetch and check out code from the repository.
16+
contents: read
17+
# Required to authenticate and pull Docker images from GitHub Container Registry (GHCR).
18+
packages: read
19+
20+
21+
jobs:
22+
run_test_coverage:
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Configure AWS credentials
27+
uses: aws-actions/configure-aws-credentials@v1
28+
with:
29+
role-to-assume: ${{ vars.GH_ACTION_AWS_ROLE_ARN }}
30+
role-session-name: ${{ vars.GH_ACTION_AWS_SESSION_NAME }}
31+
aws-region: ${{ vars.CSFY_AWS_DEFAULT_REGION }}
32+
33+
- name: Login to GHCR
34+
run: docker login ghcr.io -u gpsaggese -p ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Cleanup
37+
run: sudo chmod 777 -R .
38+
39+
- name: Checkout code
40+
uses: actions/checkout@v3
41+
with:
42+
submodules: recursive
43+
fetch-depth: 0
44+
token: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Update PYTHONPATH
47+
run: echo "PYTHONPATH=.:helpers" >> $GITHUB_ENV
48+
49+
- name: Install dependencies
50+
run: |
51+
python -m pip install --upgrade pip
52+
pip install -r .github/gh_requirements.txt
53+
54+
- name: Pull image from GHCR
55+
run: docker pull ghcr.io/${{ github.repository }}:dev
56+
57+
# Only on scheduled runs, capture ISO weekday (1=Mon … 7=Sun).
58+
- name: Set DAY_OF_WEEK
59+
if: github.event_name == 'schedule'
60+
run: echo "DAY_OF_WEEK=$(date -u +'%u')" >> $GITHUB_ENV
61+
62+
# This step is used to trigger the fast test coverage generation using the invoke task.
63+
- name: Run Fast test and generate report
64+
id: run_fast
65+
continue-on-error: true
66+
run: |
67+
echo "Simulating fast test failure"
68+
exit 1
69+
# env:
70+
# GH_ACTION_ACCESS_TOKEN: ${{ secrets.GH_ACTION_ACCESS_TOKEN }}
71+
# CSFY_AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
72+
# CSFY_AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }}
73+
# CSFY_AWS_SESSION_TOKEN: ${{ env.AWS_SESSION_TOKEN }}
74+
# CSFY_AWS_DEFAULT_REGION: ${{ env.AWS_DEFAULT_REGION }}
75+
# CSFY_ECR_BASE_PATH: ghcr.io/${{ github.repository_owner }}
76+
# CSFY_AWS_S3_BUCKET: ${{ vars.CSFY_AWS_S3_BUCKET }}
77+
# run: invoke run_coverage --suite fast
78+
79+
- name: Upload Fast Test Coverage to Codecov
80+
id: upload_fast
81+
# Only upload if the previous fast test run step succeeded (i.r report generated).
82+
# failed step don’t generate a coverage report, so there's nothing to upload.
83+
if: steps.run_fast.outcome == 'success'
84+
continue-on-error: true
85+
uses: codecov/codecov-action@v5
86+
with:
87+
token: ${{ secrets.CODECOV_TOKEN }}
88+
files: ./coverage.xml
89+
# Specify the Codecov flag name associated with this test suite.
90+
# Required to separate coverage reports by type (e.g., fast, slow, superslow) inside the Codecov UI.
91+
flags: fast
92+
name: fast-test-coverage
93+
94+
- name: Run Slow test and generate report
95+
id: run_slow
96+
continue-on-error: true
97+
env:
98+
GH_ACTION_ACCESS_TOKEN: ${{ secrets.GH_ACTION_ACCESS_TOKEN }}
99+
CSFY_AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
100+
CSFY_AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }}
101+
CSFY_AWS_SESSION_TOKEN: ${{ env.AWS_SESSION_TOKEN }}
102+
CSFY_AWS_DEFAULT_REGION: ${{ env.AWS_DEFAULT_REGION }}
103+
CSFY_ECR_BASE_PATH: ghcr.io/${{ github.repository_owner }}
104+
CSFY_AWS_S3_BUCKET: ${{ vars.CSFY_AWS_S3_BUCKET }}
105+
run: invoke run_coverage --suite slow
106+
107+
- name: Upload Slow Test Coverage to Codecov
108+
id: upload_slow
109+
# Only upload if the previous slow test run step succeeded (i.r report generated).
110+
if: steps.run_slow.outcome == 'success'
111+
continue-on-error: true
112+
uses: codecov/codecov-action@v5
113+
with:
114+
token: ${{ secrets.CODECOV_TOKEN }}
115+
files: ./coverage.xml
116+
flags: slow
117+
name: slow-test-coverage
118+
119+
- name: Run Superslow test and generate report
120+
# Run only on scheduled jobs or manual trigger
121+
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
122+
env:
123+
GH_ACTION_ACCESS_TOKEN: ${{ secrets.GH_ACTION_ACCESS_TOKEN }}
124+
CSFY_AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
125+
CSFY_AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }}
126+
CSFY_AWS_SESSION_TOKEN: ${{ env.AWS_SESSION_TOKEN }}
127+
CSFY_AWS_DEFAULT_REGION: ${{ env.AWS_DEFAULT_REGION }}
128+
CSFY_ECR_BASE_PATH: ghcr.io/${{ github.repository_owner }}
129+
CSFY_AWS_S3_BUCKET: ${{ vars.CSFY_AWS_S3_BUCKET }}
130+
run: |
131+
# Only run superslow tests if it's Monday or a manual dispatch.
132+
day_of_week=$(date +%u)
133+
if [ "$day_of_week" = "1" ] || [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
134+
invoke run_coverage --suite superslow
135+
else
136+
echo "Skipping superslow tests — not Monday and not manually triggered"
137+
exit 0
138+
fi
139+
140+
- name: Upload Superslow Test Coverage to Codecov
141+
#TODO(Shaunak): Consider removing it when we turn this workflow into a reusable one.
142+
if: steps.run_superslow.outcome == 'success'
143+
uses: codecov/codecov-action@v5
144+
with:
145+
token: ${{ secrets.CODECOV_TOKEN }}
146+
files: ./coverage.xml
147+
flags: superslow
148+
name: superslow-test-coverage
149+
150+
# Fail the job in CI if any of the fast/ slow run/ upload steps above failed.
151+
- name: Fail if fast/slow test or upload failed
152+
run: |
153+
failed=""
154+
if [ "${{ steps.run_fast.outcome }}" != "success" ]; then
155+
echo "Fast test run failed"
156+
failed="true"
157+
fi
158+
if [ "${{ steps.upload_fast.outcome }}" != "success" ]; then
159+
echo "Fast test coverage upload failed"
160+
failed="true"
161+
fi
162+
if [ "${{ steps.run_slow.outcome }}" != "success" ]; then
163+
echo "Slow test run failed"
164+
failed="true"
165+
fi
166+
if [ "${{ steps.upload_slow.outcome }}" != "success" ]; then
167+
echo "Slow test coverage upload failed"
168+
failed="true"
169+
fi
170+
if [ "$failed" = "true" ]; then
171+
echo "At least one fast/slow test or upload step failed."
172+
exit 1
173+
fi

0 commit comments

Comments
 (0)