Skip to content

Commit 85d9589

Browse files
authored
ci(feat): Codecov (#583)
* ci(feat): Codecov Signed-off-by: oliver könig <[email protected]> * f Signed-off-by: oliver könig <[email protected]> --------- Signed-off-by: oliver könig <[email protected]>
1 parent 8745303 commit 85d9589

File tree

5 files changed

+85
-9
lines changed

5 files changed

+85
-9
lines changed

.coveragerc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[paths]
2+
source =
3+
nemo_curator/
4+
/home/runner/work/NeMo-Curator/NeMo-Curator/nemo_curator
5+
/opt/NeMo-Curator/nemo_curator
6+
[run]
7+
omit =
8+
nemo_curator/scripts/*

.github/workflows/gpuci.yml

+48-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ jobs:
4444
timeout-minutes: 30
4545
# "run-gpu-tests" job is run if the "gpuci" label is added to the PR
4646
if: ${{ github.event.label.name == 'gpuci' || github.ref == 'refs/heads/main' }}
47-
47+
env:
48+
DIR: ${{ github.run_id }}
4849
steps:
4950
# If something went wrong during the last cleanup, this step ensures any existing container is removed
5051
- name: Remove existing container if it exists
@@ -79,8 +80,24 @@ jobs:
7980
# We specify the `rootdir` to help locate the "pyproject.toml" file (which is in the root directory of the repository),
8081
# and then the directory where the PyTests are located
8182
- name: Run PyTests with GPU mark
83+
id: coverage
8284
run: |
83-
docker exec nemo-curator-container pytest -m gpu --rootdir /opt/NeMo-Curator /opt/NeMo-Curator/tests
85+
docker exec nemo-curator-container bash -c '
86+
cd /opt/NeMo-Curator && \
87+
coverage run \
88+
--branch \
89+
--source=nemo_curator \
90+
--omit=nemo_curator/scripts/* \
91+
-m pytest -m gpu --rootdir /opt/NeMo-Curator tests && \
92+
cp .coverage ../
93+
'
94+
95+
docker exec nemo-curator-container coverage xml
96+
97+
docker cp nemo-curator-container:/opt/.coverage $DIR/.coverage
98+
docker cp nemo-curator-container:/opt/coverage.xml $DIR/coverage.xml
99+
coverage_report="codecov"
100+
echo "report=$coverage_report" | tee -a "$GITHUB_OUTPUT"
84101
85102
# After running `docker stop`, the container remains in an exited state
86103
# It is still present on our system and could be restarted with `docker start`
@@ -89,3 +106,32 @@ jobs:
89106
if: always()
90107
run: |
91108
docker stop nemo-curator-container && docker rm nemo-curator-container
109+
110+
- name: Upload artifacts
111+
uses: actions/upload-artifact@v4
112+
if: ${{ steps.coverage.outputs.report == 'codecov' }}
113+
with:
114+
name: ${{ github.run_id }}
115+
path: |
116+
${{ github.run_id }}/coverage.xml
117+
${{ github.run_id }}/.coverage
118+
include-hidden-files: true
119+
120+
upload-coverage:
121+
runs-on: ubuntu-latest
122+
needs: [run-gpu-tests]
123+
steps:
124+
- name: Checkout
125+
uses: actions/checkout@v4
126+
127+
- name: Download coverage reports of current branch
128+
uses: actions/download-artifact@v4
129+
with:
130+
name: ${{ github.run_id }}
131+
132+
- name: Upload coverage reports to Codecov
133+
uses: codecov/codecov-action@v5
134+
with:
135+
token: ${{ secrets.CODECOV_TOKEN }}
136+
verbose: true
137+
flags: gpu

.github/workflows/test.yml

+18-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,24 @@ jobs:
3838
# Installing wheel beforehand due to fasttext issue:
3939
# https://github.com/facebookresearch/fastText/issues/512#issuecomment-1837367666
4040
run: |
41-
pip install wheel
41+
pip install -U pip
42+
pip install --no-cache-dir wheel
4243
pip install --no-cache-dir .
43-
pip install pytest
44+
pip install --no-cache-dir pytest coverage
45+
4446
- name: Run tests
4547
run: |
46-
python -m pytest -v --cpu
48+
python -m coverage run --branch --source=nemo_curator --omit=nemo_curator/scripts/* -m pytest -v --cpu
49+
50+
- name: Generate report
51+
run: |
52+
python -m coverage xml
53+
python -m coverage report
54+
55+
- name: Upload coverage reports to Codecov
56+
uses: codecov/codecov-action@v5
57+
with:
58+
token: ${{ secrets.CODECOV_TOKEN }}
59+
files: coverage.xml
60+
verbose: true
61+
flags: cpu

Dockerfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ RUN conda create -y --name curator -c nvidia/label/cuda-${CUDA_VER} -c conda-for
4242
libcusolver \
4343
cuda-nvvm && \
4444
source activate curator && \
45-
pip install --upgrade pytest pip
45+
pip install --upgrade pytest pip pytest-coverage
4646

4747
RUN \
48-
--mount=type=bind,source=/opt/NeMo-Curator/nemo_curator/__init__.py,target=/opt/NeMo-Curator/nemo_curator/__init__.py,from=curator-update \
49-
--mount=type=bind,source=/opt/NeMo-Curator/nemo_curator/package_info.py,target=/opt/NeMo-Curator/nemo_curator/package_info.py,from=curator-update \
50-
--mount=type=bind,source=/opt/NeMo-Curator/pyproject.toml,target=/opt/NeMo-Curator/pyproject.toml,from=curator-update \
48+
--mount=type=bind,source=/opt/NeMo-Curator/nemo_curator/__init__.py,target=/opt/NeMo-Curator/nemo_curator/__init__.py,from=curator-update \
49+
--mount=type=bind,source=/opt/NeMo-Curator/nemo_curator/package_info.py,target=/opt/NeMo-Curator/nemo_curator/package_info.py,from=curator-update \
50+
--mount=type=bind,source=/opt/NeMo-Curator/pyproject.toml,target=/opt/NeMo-Curator/pyproject.toml,from=curator-update \
5151
cd /opt/NeMo-Curator && \
5252
source activate curator && \
5353
pip install ".[all]"

codecov.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
comment: false
2+
coverage:
3+
status:
4+
patch: false
5+
project: false
6+
fixes:
7+
- "/opt/NeMo-Curator/::"

0 commit comments

Comments
 (0)