Skip to content

Commit 8c1781f

Browse files
committed
Update github actions to latest
1 parent 95e3c66 commit 8c1781f

1 file changed

Lines changed: 87 additions & 72 deletions

File tree

Lines changed: 87 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,166 +1,181 @@
1-
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
1+
name: CI/CD Pipeline
32

4-
name: workflow_actions
5-
6-
# Controls when the workflow will run
73
on:
8-
# Triggers the workflow on push or pull request events but only for the "main" branch
9-
pull_request: []
104
push:
11-
tags:
12-
- '*'
13-
branches:
14-
- 'main'
15-
# Allows you to run this workflow manually from the Actions tab
5+
branches: [main]
6+
tags: ['*']
7+
pull_request:
8+
branches: [main]
169
workflow_dispatch:
17-
tag: "Manual run"
1810

19-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
11+
# Opt-in to Node 24 and cancel redundant runs
12+
env:
13+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
2019
jobs:
20+
# --- JOB 1: GENERATE RADAS DATA ---
2121
radas:
22-
runs-on: ubuntu-24.04
22+
name: Generate Radas Data
23+
runs-on: ubuntu-latest
2324
steps:
24-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
25-
- uses: actions/checkout@v4
25+
- uses: actions/checkout@v5
2626

2727
- name: Install Poetry
28-
run: curl -sSL https://install.python-poetry.org | python - --version 2.1.3
28+
run: pipx install poetry==2.1.3
2929

30-
- name: Set up Python 3.11
31-
uses: actions/setup-python@v5
30+
- name: Set up Python 3.12
31+
uses: actions/setup-python@v6
3232
with:
33-
python-version: '3.11'
33+
python-version: '3.12'
3434
cache: 'poetry'
3535

36-
- name: Setup
36+
- name: Install dependencies
3737
run: poetry install
3838

3939
- name: Cache radas results
40-
id: radas
41-
uses: actions/cache@v4
40+
id: radas-cache
41+
uses: actions/cache@v5
4242
with:
4343
path: ./radas_dir
44-
key: radas-${{ hashFiles('poetry.lock')}}
44+
key: radas-${{ hashFiles('poetry.lock') }}
4545

4646
- name: Make radas data
47-
if: steps.radas.outputs.cache-hit != 'true'
47+
if: steps.radas-cache.outputs.cache-hit != 'true'
4848
run: poetry run radas -c radas_config.yaml
4949

5050
- name: Upload radas artifacts
51-
uses: actions/upload-artifact@v4
51+
uses: actions/upload-artifact@v5
5252
with:
5353
name: radas_dir
5454
path: ./radas_dir
55+
retention-days: 180
5556

57+
# --- JOB 2: TEST & LINT ---
5658
build:
59+
name: Test (Python ${{ matrix.python-version }})
5760
needs: radas
58-
# The type of runner that the job will run on
59-
runs-on: ubuntu-24.04
61+
runs-on: ubuntu-latest
6062
strategy:
6163
fail-fast: false
6264
matrix:
63-
python-version: ['3.10', '3.11', '3.12'] # should test the versions we allow for in pyproject.toml
65+
python-version: ['3.12', '3.13', '3.14']
6466

65-
# Steps represent a sequence of tasks that will be executed as part of the job
6667
steps:
67-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
68-
- uses: actions/checkout@v4
68+
- uses: actions/checkout@v5
6969

70-
- name: Install pandoc
71-
run: sudo apt-get update && sudo apt-get install pandoc
70+
- name: Install system dependencies
71+
run: |
72+
sudo apt-get update
73+
sudo apt-get install -y pandoc
7274
7375
- name: Install Poetry
74-
run: curl -sSL https://install.python-poetry.org | python - --version 2.1.3
76+
run: pipx install poetry==2.1.3
7577

7678
- name: Set up Python ${{ matrix.python-version }}
77-
uses: actions/setup-python@v5
79+
uses: actions/setup-python@v6
7880
with:
7981
python-version: ${{ matrix.python-version }}
8082
cache: 'poetry'
8183

82-
- name: Setup
84+
- name: Install dependencies
8385
run: poetry install
8486

85-
- uses: actions/cache/restore@v4
86-
id: radas
87+
- name: Restore radas data
88+
uses: actions/cache/restore@v5
89+
id: radas-restore
8790
with:
8891
path: ./radas_dir
89-
key: radas-${{ hashFiles('poetry.lock')}}
92+
key: radas-${{ hashFiles('poetry.lock') }}
9093

91-
- name: Check cache hit
92-
if: steps.radas.outputs.cache-hit != 'true'
94+
- name: Verify Cache
95+
if: steps.radas-restore.outputs.cache-hit != 'true'
9396
run: exit 1
9497

95-
- name: Tests
96-
run: MPLBACKEND=Agg poetry run pytest tests --nbmake example_cases -m "not docs"
98+
- name: Run Tests
99+
env:
100+
MPLBACKEND: Agg
101+
run: poetry run pytest tests --nbmake example_cases -m "not docs"
97102

98-
- name: Tests with new regression results
103+
- name: Regression Tests
104+
env:
105+
MPLBACKEND: Agg
99106
run: |
100107
poetry run python tests/utils/regression_results.py
101-
MPLBACKEND=Agg poetry run pytest --no-cov tests/test_regression_against_cases.py
108+
poetry run pytest --no-cov tests/test_regression_against_cases.py
102109
103-
- name: Upload regression results
104-
uses: actions/upload-artifact@v4
110+
- name: Upload regression results on failure
111+
uses: actions/upload-artifact@v5
105112
if: failure()
106113
with:
107-
name: regression_results
114+
name: regression_results-${{ matrix.python-version }}
108115
path: tests/regression_results
109116

110-
- name: Test package
117+
- name: Smoke test package
118+
env:
119+
MPLBACKEND: Agg
111120
run: |
112121
poetry build -f wheel
113122
python -m venv test_env
114-
source ./test_env/bin/activate
115-
pip install $(find ./dist -name "*.whl")
116-
# enter tempdir so import cfspopcon doesn't find the cfspopcon directory
123+
source test_env/bin/activate
124+
pip install dist/*.whl
117125
mkdir tmp_dir && cd tmp_dir
118-
MPLBACKEND=Agg popcon ../example_cases/SPARC_PRD -d radas_dir WORKING_DIR/../radas_dir
126+
popcon ../example_cases/SPARC_PRD -d radas_dir WORKING_DIR/../radas_dir
119127
120-
- name: Run pre-commit checks
128+
- name: Pre-commit checks
121129
run: poetry run pre-commit run --show-diff-on-failure --color=always --all-files
122130

123-
- name: Test docs
124-
# instead of make html we use sphinx-build directly to add more options
131+
- name: Documentation tests
125132
run: |
126133
cd docs
127134
poetry run sphinx-build --keep-going -Wnb html . _build/
128135
poetry run make doctest
129136
poetry run make linkcheck
130137
131-
138+
# --- JOB 3: PREPARE RELEASE ---
132139
build_release:
133-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
140+
name: Build Release
141+
if: startsWith(github.ref, 'refs/tags')
134142
needs: build
135-
runs-on: ubuntu-24.04
136-
143+
runs-on: ubuntu-latest
137144
steps:
138-
- uses: actions/checkout@v4
145+
- uses: actions/checkout@v5
139146

140147
- name: Install Poetry
141-
run: curl -sSL https://install.python-poetry.org | python - --version 2.1.3
148+
run: pipx install poetry==2.1.3
142149

143-
- name: Poetry build
150+
- name: Build distributions
144151
run: poetry build
145152

146-
- uses: actions/upload-artifact@v4
153+
- name: Upload PyPI artifacts
154+
uses: actions/upload-artifact@v5
147155
with:
148156
name: pypi-build
149157
path: ./dist
158+
retention-days: 1
150159

160+
# --- JOB 4: PUBLISH ---
151161
publish:
152-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
162+
name: Publish to PyPI
163+
if: startsWith(github.ref, 'refs/tags')
153164
needs: build_release
154-
runs-on: ubuntu-24.04
165+
runs-on: ubuntu-latest
155166
environment:
156167
name: pypi-publish
157168
url: https://pypi.org/project/cfspopcon/
158169
permissions:
159-
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
170+
id-token: write
160171
steps:
161-
- uses: actions/download-artifact@v4
172+
- name: Download artifacts
173+
uses: actions/download-artifact@v5
174+
with:
175+
name: pypi-build
176+
path: dist/
162177

163-
- name: Publish package distributions to PyPI
178+
- name: Publish to PyPI
164179
uses: pypa/gh-action-pypi-publish@release/v1
165180
with:
166-
packages-dir: pypi-build/
181+
packages-dir: dist/

0 commit comments

Comments
 (0)