Skip to content

Commit 51537bd

Browse files
authored
Merge pull request #32 from moshi4/pytest-ci-gh-actions
Add pytest CI gh actions workflow
2 parents 8b4bf91 + 31d4dc4 commit 51537bd

3 files changed

Lines changed: 61 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: [main, develop]
5+
paths: ["src/**", "tests/**", ".github/workflows/ci.yml"]
6+
pull_request:
7+
branches: [main, develop]
8+
paths: ["src/**", "tests/**", ".github/workflows/ci.yml"]
9+
workflow_dispatch:
10+
11+
jobs:
12+
pytest-ci:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
python-version: [3.7, 3.8, 3.9, "3.10"]
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
21+
- name: Setup Python ${{ matrix.python-version}}
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Install Dependencies
27+
run: |
28+
pip install -U pip
29+
pip install wheel seaborn plotnine
30+
pip install pytest pytest-cov
31+
pip install .
32+
33+
- name: Run pytest
34+
run: pytest tests --tb=line --cov=src --cov-report=xml --cov-report=term

tests/__init__.py

Whitespace-only changes.

tests/test_patchworklib.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from pathlib import Path
2+
3+
import seaborn as sns
4+
5+
import patchworklib as pw
6+
7+
8+
def test_example_plot(tmp_path: Path):
9+
"""Test example plot"""
10+
fmri = sns.load_dataset("fmri")
11+
ax1 = pw.Brick(figsize=(3, 2))
12+
sns.lineplot(
13+
x="timepoint", y="signal", hue="region", style="event", data=fmri, ax=ax1
14+
)
15+
ax1.legend(bbox_to_anchor=(1.05, 1.0), loc="upper left")
16+
ax1.set_title("ax1")
17+
18+
titanic = sns.load_dataset("titanic")
19+
ax2 = pw.Brick(figsize=(1, 2))
20+
sns.barplot(x="sex", y="survived", hue="class", data=titanic, ax=ax2)
21+
ax2.move_legend(new_loc="upper left", bbox_to_anchor=(1.05, 1.0))
22+
ax2.set_title("ax2")
23+
24+
result_file = tmp_path / "ax12.png"
25+
ax12 = ax1 | ax2
26+
ax12.savefig(result_file)
27+
assert result_file.exists()

0 commit comments

Comments
 (0)