-
Notifications
You must be signed in to change notification settings - Fork 15
166 lines (135 loc) · 5.01 KB
/
workflow_actions.yml
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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: workflow_actions
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
pull_request: []
push:
tags:
- '*'
branches:
- 'main'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
tag: "Manual run"
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
radas:
runs-on: ubuntu-22.04
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- name: Install Poetry
run: curl -sSL https://install.python-poetry.org | python - --version 1.8.2
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'poetry'
- name: Setup
run: poetry install
- name: Cache radas results
id: radas
uses: actions/cache@v4
with:
path: ./radas_dir
key: radas-${{ hashFiles('poetry.lock')}}
- name: Make radas data
if: steps.radas.outputs.cache-hit != 'true'
run: poetry run radas
- name: Upload radas artifacts
uses: actions/upload-artifact@v4
with:
name: radas_dir
path: ./radas_dir
build:
needs: radas
# The type of runner that the job will run on
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12'] # should test the versions we allow for in pyproject.toml
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- name: Install pandoc
run: sudo apt-get update && sudo apt-get install pandoc
- name: Install Poetry
run: curl -sSL https://install.python-poetry.org | python - --version 1.8.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- name: Setup
run: poetry install
- uses: actions/cache/restore@v4
id: radas
with:
path: ./radas_dir
key: radas-${{ hashFiles('poetry.lock')}}
- name: Check cache hit
if: steps.radas.outputs.cache-hit != 'true'
run: exit 1
- name: Tests
run: MPLBACKEND=Agg poetry run pytest tests --nbmake example_cases -m "not docs"
- name: Tests with new regression results
run: |
poetry run python tests/utils/regression_results.py
MPLBACKEND=Agg poetry run pytest --no-cov tests/test_regression_against_cases.py
- name: Upload regression results
uses: actions/upload-artifact@v4
if: failure()
with:
name: regression_results
path: tests/regression_results
- name: Test package
run: |
poetry build -f wheel
python -m venv test_env
source ./test_env/bin/activate
pip install $(find ./dist -name "*.whl")
# enter tempdir so import cfspopcon doesn't find the cfspopcon directory
mkdir tmp_dir && cd tmp_dir
MPLBACKEND=Agg popcon ../example_cases/SPARC_PRD -d radas_dir WORKING_DIR/../radas_dir
- name: Run pre-commit checks
run: poetry run pre-commit run --show-diff-on-failure --color=always --all-files
- name: Test docs
# instead of make html we use sphinx-build directly to add more options
run: |
cd docs
poetry run sphinx-build --keep-going -Wnb html . _build/
poetry run make doctest
poetry run make linkcheck
build_release:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Install Poetry
run: curl -sSL https://install.python-poetry.org | python - --version 1.8.2
- name: Poetry build
run: poetry build
- uses: actions/upload-artifact@v4
with:
name: pypi-build
path: ./dist
publish:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: build_release
runs-on: ubuntu-22.04
environment:
name: pypi-publish
url: https://pypi.org/project/cfspopcon/
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/download-artifact@v4
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: pypi-build/