-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (86 loc) · 2.71 KB
/
ci.yml
File metadata and controls
98 lines (86 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: CI
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
- name: Lint (black)
run: black --check src tests
- name: Lint (ruff)
run: ruff check src tests
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
- name: Run unit tests (coverage on 3.12)
run: |
mkdir -p reports
if [[ "${{ matrix.python-version }}" == "3.12" ]]; then
pytest --maxfail=1 --disable-warnings -q --junitxml=reports/pytest.xml --cov=src/notebook_tidy --cov-report=xml:reports/coverage.xml --cov-fail-under=80
else
pytest --maxfail=1 --disable-warnings -q
fi
- name: Smoke CLI (extract + plan)
run: |
cat > /tmp/ci-config.yaml <<'EOF'
strip:
outputs: true
execution_count: true
reorder:
enabled: true
tags: [imports, export]
extract:
enabled: true
module_dir: /tmp/ci_modules
default_module_name: notebook_utils.py
remove_extracted_cells: true
remove_extracted_cells_tags: [export]
EOF
notebook-tidy tests/data/sample.ipynb \
--output /tmp/ci_out.ipynb \
--config /tmp/ci-config.yaml \
--plan --plan-file /tmp/plan.json
head -n 40 /tmp/plan.json
- name: Upload artifacts on failure (main only)
if: failure() && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: ci-artifacts-${{ matrix.python-version }}
path: |
reports/pytest.xml
reports/coverage.xml
/tmp/plan.json
/tmp/ci_out.ipynb
/tmp/ci_modules
if-no-files-found: ignore