File tree Expand file tree Collapse file tree 5 files changed +96
-50
lines changed Expand file tree Collapse file tree 5 files changed +96
-50
lines changed Original file line number Diff line number Diff line change 2323 required : false
2424 default : false
2525 type : boolean
26+ with-coverage :
27+ description : " Whether to run tests with coverage reporting"
28+ required : false
29+ default : false
30+ type : boolean
2631
2732defaults :
2833 run :
8994 poetry install --with dev
9095 fi
9196
92- - name : Run pre-commit hooks
93- run : poetry run make pre_commit
97+ - name : Run pytest with coverage
98+ if : inputs.with-coverage
99+ run : poetry run pytest --cov=nemoguardrails tests/ --cov-report=xml:coverage.xml -v
94100
95- - name : Run pytest
101+ - name : Run pytest without coverage
102+ if : inputs.with-coverage == false
96103 run : poetry run pytest -v
104+
105+ - name : Upload coverage to Codecov
106+ if : inputs.with-coverage
107+ uses : codecov/codecov-action@v5
108+ with :
109+ directory : ./coverage/reports/
110+ env_vars : PYTHON
111+ fail_ci_if_error : true
112+ files : ./coverage.xml
113+ flags : python
114+ name : codecov-umbrella
115+ token : ${{ secrets.CODECOV_TOKEN }}
116+ verbose : true
Original file line number Diff line number Diff line change 1+ name : Lint
2+
3+ on :
4+ pull_request :
5+ push :
6+ branches :
7+ - main
8+ - develop
9+ workflow_dispatch :
10+
11+ env :
12+ POETRY_VERSION : 1.8.2
13+ PYTHON_VERSION : " 3.11"
14+
15+ jobs :
16+ lint :
17+ name : Lint Code
18+ runs-on : ubuntu-latest
19+ steps :
20+ - uses : actions/checkout@v4
21+
22+ - name : Set up Python
23+ uses : actions/setup-python@v5
24+ with :
25+ python-version : ${{ env.PYTHON_VERSION }}
26+
27+ - name : Get full Python version
28+ id : full-python-version
29+ run : echo "version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")" >> $GITHUB_OUTPUT
30+
31+ - name : Bootstrap poetry
32+ run : |
33+ curl -sSL https://install.python-poetry.org | POETRY_VERSION=${{ env.POETRY_VERSION }} python -
34+ echo "$HOME/.local/bin" >> $GITHUB_PATH
35+
36+ - name : Configure poetry
37+ run : poetry config virtualenvs.in-project true
38+
39+ - name : Set up cache
40+ uses : actions/cache@v4
41+ id : cache
42+ with :
43+ path : .venv
44+ key : venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
45+
46+ - name : Ensure cache is healthy
47+ if : steps.cache.outputs.cache-hit == 'true'
48+ run : timeout 10s poetry run pip --version || rm -rf .venv
49+
50+ - name : Install dependencies
51+ run : poetry install --with dev
52+
53+ - name : Run pre-commit hooks
54+ run : poetry run make pre_commit
Original file line number Diff line number Diff line change 1+ name : Skip PR Tests
2+
3+ on :
4+ pull_request :
5+ paths :
6+ - " **/*.md"
7+ - " .github/**"
8+
9+ jobs :
10+ pr-tests-summary :
11+ name : PR Tests Summary
12+ runs-on : ubuntu-latest
13+ steps :
14+ - run : echo "Tests skipped (no code changes)"
Original file line number Diff line number Diff line change @@ -2,8 +2,8 @@ name: PR Tests
22
33on :
44 pull_request :
5- # we don't ignore markdkowns to run pre-commits
65 paths-ignore :
6+ - " **/*.md"
77 - " .github/**"
88
99jobs :
@@ -15,12 +15,16 @@ jobs:
1515 include :
1616 - os : Ubuntu
1717 image : ubuntu-latest
18+ - python-version : " 3.11"
19+ with-coverage : true
1820 fail-fast : false
1921 uses : ./.github/workflows/_test.yml
22+ secrets : inherit
2023 with :
2124 os : ${{ matrix.os }}
2225 image : ${{ matrix.image }}
2326 python-version : ${{ matrix.python-version }}
27+ with-coverage : ${{ matrix.with-coverage || false }}
2428 pr-tests-summary :
2529 name : PR Tests Summary
2630 needs : pr-tests-matrix
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments