Skip to content

Commit 952d6cc

Browse files
authored
Run tests as part of CI (#59)
Closes #53. This PR adds a workflow that runs the test suite every Saturday and every time commits are pushed to open PRs or to the master and dev branches. In the interest of green computing, it is only triggered if these commits change at least one of these files: - any `.py` file - the workflow itself, i.e., `.github/workflows/test_suite.yml` - `pyproject.toml` so that we can test the installation Deleted `test_oggm_compat.py` since all tests fail anyway.
1 parent 3664594 commit 952d6cc

File tree

3 files changed

+57
-79
lines changed

3 files changed

+57
-79
lines changed

.github/workflows/test_suite.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: 'Install PyGEM and Run Test Suite'
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- dev
8+
paths:
9+
- '**.py'
10+
- '.github/workflows/test_suite.yml'
11+
- 'pyproject.toml'
12+
13+
pull_request:
14+
paths:
15+
- '**.py'
16+
- '.github/workflows/test_suite.yml'
17+
- 'pyproject.toml'
18+
19+
# Run test suite every Saturday at 1AM GMT (1 hour after the Docker image is updated)
20+
schedule:
21+
- cron: '0 1 * * 6'
22+
23+
# Stop the workflow if a new one is started
24+
concurrency:
25+
group: ${{ github.workflow }}-${{ github.ref }}
26+
cancel-in-progress: true
27+
28+
jobs:
29+
test_suite:
30+
name: 'Test suite'
31+
runs-on: ubuntu-latest
32+
33+
# Use pygem:latest for master branch and pygem:dev otherwise
34+
container:
35+
image: ghcr.io/pygem-community/pygem:${{ github.ref == 'refs/heads/master' && 'latest' || 'dev' }}
36+
options: --user root
37+
38+
steps:
39+
- name: 'Checkout the repo'
40+
id: checkout
41+
uses: actions/checkout@v4
42+
43+
- name: 'Reinstall PyGEM'
44+
run: pip install --break-system-packages -e .
45+
46+
- name: 'Run tests'
47+
run: |
48+
python3 -m coverage erase
49+
python3 -m pytest --cov=pygem -v --durations=20 pygem/tests

pygem/tests/test_oggm_compat.py

Lines changed: 0 additions & 78 deletions
This file was deleted.

pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ jupyter = "^1.1.1"
3434
arviz = "^0.20.0"
3535
oggm = "^1.6.2"
3636
ruamel-yaml = "^0.18.10"
37+
pytest = ">=8.3.4"
38+
pytest-cov = ">=6.0.0"
3739

3840
[tool.poetry.scripts]
3941
initialize = "pygem.bin.op.initialize:main"
@@ -53,4 +55,9 @@ duplicate_gdirs = "pygem.bin.op.duplicate_gdirs:main"
5355

5456
[build-system]
5557
requires = ["poetry-core"]
56-
build-backend = "poetry.core.masonry.api"
58+
build-backend = "poetry.core.masonry.api"
59+
60+
[tool.coverage.report]
61+
omit = ["pygem/tests/*"]
62+
show_missing = true
63+
skip_empty = true

0 commit comments

Comments
 (0)