Skip to content

Commit b6fce4d

Browse files
Merge pull request #2 from msch-nutrient/add-integration-tests-ci
Add integration tests to CI workflow for pull requests
2 parents f2a7c4b + 06f62f7 commit b6fce4d

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ jobs:
4343
- name: Run type checking with mypy
4444
run: python -m mypy --python-version=${{ matrix.python-version }} src tests
4545

46-
- name: Run tests with pytest
47-
run: python -m pytest -v --cov=nutrient_dws --cov-report=xml --cov-report=term
46+
- name: Run unit tests with pytest
47+
run: python -m pytest tests/unit/ -v --cov=nutrient_dws --cov-report=xml --cov-report=term
4848

4949
- name: Upload coverage to Codecov
5050
uses: codecov/codecov-action@v4
@@ -55,6 +55,44 @@ jobs:
5555
name: codecov-umbrella
5656
fail_ci_if_error: false
5757

58+
integration-test:
59+
runs-on: ubuntu-latest
60+
if: github.event_name == 'pull_request'
61+
62+
steps:
63+
- uses: actions/checkout@v4
64+
65+
- name: Set up Python 3.12
66+
uses: actions/setup-python@v5
67+
with:
68+
python-version: '3.12'
69+
70+
- name: Cache pip dependencies
71+
uses: actions/cache@v4
72+
with:
73+
path: ~/.cache/pip
74+
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
75+
restore-keys: |
76+
${{ runner.os }}-pip-
77+
78+
- name: Install dependencies
79+
run: |
80+
python -m pip install --upgrade pip
81+
pip install -e ".[dev]"
82+
83+
- name: Create integration config with API key
84+
run: |
85+
python -c "
86+
import os
87+
with open('tests/integration/integration_config.py', 'w') as f:
88+
f.write(f'API_KEY = \"{os.environ[\"NUTRIENT_DWS_API_KEY\"]}\"\n')
89+
"
90+
env:
91+
NUTRIENT_DWS_API_KEY: ${{ secrets.NUTRIENT_DWS_API_KEY }}
92+
93+
- name: Run integration tests
94+
run: python -m pytest tests/integration/ -v
95+
5896
build:
5997
runs-on: ubuntu-latest
6098
needs: test

0 commit comments

Comments
 (0)