Skip to content

Commit 34d5fb7

Browse files
committed
Add CI pipeline
1 parent 960a14f commit 34d5fb7

2 files changed

Lines changed: 101 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
defaults:
14+
run:
15+
shell: bash -l {0}
16+
17+
jobs:
18+
lint:
19+
name: Lint (ruff)
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- uses: actions/setup-python@v5
25+
with:
26+
python-version: "3.11"
27+
28+
- name: Install ruff
29+
run: pip install ruff
30+
31+
- name: Run ruff
32+
run: ruff check .
33+
34+
typecheck:
35+
name: Type-check (mypy)
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- uses: actions/setup-python@v5
41+
with:
42+
python-version: "3.11"
43+
44+
- name: Install package + mypy
45+
run: pip install mypy numpy h5py && pip install -e .
46+
47+
- name: Run mypy
48+
run: mypy pyxdm --ignore-missing-imports
49+
50+
test:
51+
name: Tests (Python ${{ matrix.python-version }})
52+
runs-on: ubuntu-latest
53+
strategy:
54+
fail-fast: false
55+
matrix:
56+
python-version: ["3.10", "3.11", "3.12"]
57+
58+
steps:
59+
- uses: actions/checkout@v4
60+
61+
- name: Set up conda (miniforge)
62+
uses: conda-incubator/setup-miniconda@v3
63+
with:
64+
miniforge-version: latest
65+
python-version: ${{ matrix.python-version }}
66+
activate-environment: pyxdm
67+
environment-file: environment.yaml
68+
auto-activate-base: false
69+
70+
- name: Install package + test dependencies
71+
run: pip install -e ".[test]"
72+
73+
- name: Run tests with coverage
74+
run: pytest
75+
76+
- name: Upload coverage to Codecov
77+
if: matrix.python-version == '3.11'
78+
uses: codecov/codecov-action@v4
79+
with:
80+
files: coverage.xml
81+
fail_ci_if_error: false

pyproject.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,26 @@ known-first-party = ["pyxdm"]
7676
combine-as-imports = true
7777
force-single-line = false
7878

79+
[tool.pytest.ini_options]
80+
testpaths = ["pyxdm/tests"]
81+
addopts = [
82+
"--cov=pyxdm",
83+
"--cov-report=term-missing",
84+
"--cov-report=xml",
85+
"-v",
86+
]
87+
88+
[tool.coverage.run]
89+
source = ["pyxdm"]
90+
omit = ["pyxdm/tests/*"]
91+
92+
[tool.coverage.report]
93+
exclude_lines = [
94+
"pragma: no cover",
95+
"if TYPE_CHECKING:",
96+
"raise NotImplementedError",
97+
]
98+
7999
[tool.mypy]
80100
python_version = "3.10"
81101
warn_return_any = true

0 commit comments

Comments
 (0)