Skip to content

Commit 67b8b7a

Browse files
authored
ci: add Codecov integration to workflows (#1143)
The workflow is triggered on pushes and pull requests to the `develop` branch. Codecov integration ensures better visibility into test coverage metrics.
1 parent 46c02bd commit 67b8b7a

File tree

3 files changed

+66
-1
lines changed

3 files changed

+66
-1
lines changed

.github/workflows/codecov.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
informational: true
6+
patch:
7+
default:
8+
informational: true
9+
10+
comment:
11+
layout: " diff, flags, files"
12+
behavior: default
13+
require_changes: false # if true: only post the comment if coverage changes
14+
require_base: false # [true :: must have a base report to post]
15+
require_head: true # [true :: must have a head report to post]
16+
hide_project_coverage: false # [true :: only show coverage on the git diff aka patch coverage]

.github/workflows/pr-tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
name: PR Tests
22

33
on:
4+
push:
5+
46
pull_request:
5-
types: [opened, synchronize, reopened, ready_for_review]
67
# we don't ignore markdkowns to run pre-commits
78
paths-ignore:
89
- ".github/**"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Coverage Report
2+
3+
on:
4+
push:
5+
branches: [develop]
6+
pull_request:
7+
branches: [develop]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.11"
21+
22+
- name: Bootstrap poetry
23+
run: |
24+
curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.8.2 python -
25+
echo "$HOME/.local/bin" >> $GITHUB_PATH
26+
27+
- name: Configure poetry
28+
run: poetry config virtualenvs.in-project true
29+
30+
- name: Install dependencies
31+
run: poetry install --with dev
32+
33+
- name: Run pre-commit hooks
34+
run: poetry run make pre_commit
35+
36+
- name: Run tests with coverage
37+
run: poetry run pytest --cov=nemoguardrails tests/ --cov-report=xml:coverage.xml
38+
- name: Upload coverage to Codecov
39+
uses: codecov/codecov-action@v5
40+
with:
41+
directory: ./coverage/reports/
42+
env_vars: PYTHON
43+
fail_ci_if_error: true
44+
files: ./coverage.xml
45+
flags: python
46+
name: codecov-umbrella
47+
token: ${{ secrets.CODECOV_TOKEN }}
48+
verbose: true

0 commit comments

Comments
 (0)