-
Notifications
You must be signed in to change notification settings - Fork 19
181 lines (151 loc) · 4.53 KB
/
Copy pathworkflow_actions.yml
File metadata and controls
181 lines (151 loc) · 4.53 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
name: CI/CD Pipeline
on:
release:
types: [published]
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# --- JOB 1: GENERATE RADAS DATA ---
radas:
name: Generate Radas Data
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Poetry
run: pipx install "poetry>=2,<3"
- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: '3.12'
cache: 'poetry'
- name: Install dependencies
run: poetry install
- name: Cache radas results
id: radas-cache
uses: actions/cache@v5
with:
path: ./radas_dir
key: radas-${{ hashFiles('poetry.lock') }}
- name: Make radas data
if: steps.radas-cache.outputs.cache-hit != 'true'
run: poetry run radas -c radas_config.yaml
- name: Upload radas artifacts
uses: actions/upload-artifact@v7
with:
name: radas_dir
path: ./radas_dir
retention-days: 30
# --- JOB 2: TEST & LINT ---
build:
name: Test (Python ${{ matrix.python-version }})
needs: radas
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.12', '3.13', '3.14']
steps:
- uses: actions/checkout@v6
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y pandoc
- name: Install Poetry
run: pipx install "poetry>=2,<3"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- name: Install dependencies
run: poetry install
- name: Restore radas data
uses: actions/cache/restore@v5
id: radas-restore
with:
path: ./radas_dir
key: radas-${{ hashFiles('poetry.lock') }}
- name: Verify Cache
if: steps.radas-restore.outputs.cache-hit != 'true'
run: exit 1
- name: Run Tests
env:
MPLBACKEND: Agg
run: poetry run pytest tests --nbmake example_cases -m "not docs"
- name: Regression Tests
env:
MPLBACKEND: Agg
run: |
poetry run python tests/utils/regression_results.py
poetry run pytest --no-cov tests/test_regression_against_cases.py
- name: Upload regression results on failure
uses: actions/upload-artifact@v7
if: failure()
with:
name: regression_results-${{ matrix.python-version }}
path: tests/regression_results
- name: Smoke test package
env:
MPLBACKEND: Agg
run: |
poetry build -f wheel
python -m venv test_env
source test_env/bin/activate
pip install dist/*.whl
mkdir tmp_dir && cd tmp_dir
popcon ../example_cases/SPARC_PRD -d radas_dir WORKING_DIR/../radas_dir
- name: Pre-commit checks
run: poetry run pre-commit run --show-diff-on-failure --color=always --all-files
- name: Documentation tests
run: |
cd docs
poetry run sphinx-build --keep-going -Wnb html . _build/
poetry run make doctest
poetry run make linkcheck
# --- JOB 3: PREPARE RELEASE ---
build_release:
name: Build Release
if: startsWith(github.ref, 'refs/tags')
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Poetry
run: pipx install "poetry>=2,<3"
- name: Build distributions
run: poetry build
- name: Upload PyPI artifacts
uses: actions/upload-artifact@v7
with:
name: pypi-build
path: ./dist
retention-days: 1
# --- JOB 4: PUBLISH ---
publish:
name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags')
needs: build_release
runs-on: ubuntu-latest
environment:
name: pypi-publish
url: https://pypi.org/project/cfspopcon/
permissions:
id-token: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v8
with:
name: pypi-build
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/