Skip to content

Commit 358a451

Browse files
Merge branch 'main' into feature/drop-numpy-1-support
2 parents 63a6065 + b851fde commit 358a451

File tree

19 files changed

+2137
-204
lines changed

19 files changed

+2137
-204
lines changed

.github/workflows/build-test-release.yml

Lines changed: 66 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,37 @@ jobs:
3131
steps:
3232

3333
- name: Checkout source code
34-
uses: actions/checkout@v4
34+
uses: actions/checkout@v5
3535

36-
- name: Setup Python 3.13
37-
uses: actions/setup-python@v5
36+
- name: Install uv
37+
uses: astral-sh/setup-uv@v6
38+
if: ${{ always() }}
3839
with:
39-
python-version: "3.13"
40+
activate-environment: true
41+
enable-cache: true
42+
43+
- name: Install dependencies
44+
if: ${{ always() }}
45+
run: uv sync --frozen
4046

4147
- name: Set PyPI version
4248
uses: PowerGridModel/pgm-version-bump@main
4349
with:
4450
token: ${{ secrets.GITHUB_TOKEN }}
4551

46-
- name: Build
47-
run: |
48-
cat PYPI_VERSION
49-
pip install build
50-
python -m build --outdir wheelhouse .
51-
5252
- name: Save version
5353
id: version
5454
run: echo "version=$(cat PYPI_VERSION)" >> $GITHUB_OUTPUT
5555

56+
- name: Build
57+
run: |
58+
uv build
59+
5660
- name: Store built wheel file
5761
uses: actions/upload-artifact@v4
5862
with:
5963
name: power-grid-model-ds
60-
path: wheelhouse/
64+
path: dist/
6165

6266
tests:
6367
needs: build-python
@@ -70,26 +74,32 @@ jobs:
7074

7175
steps:
7276
- name: Checkout source code
73-
uses: actions/checkout@v4
77+
uses: actions/checkout@v5
7478

75-
- name: Setup Python ${{ matrix.python }}
76-
uses: actions/setup-python@v5
79+
- name: Install uv
80+
uses: astral-sh/setup-uv@v6
81+
if: ${{ always() }}
7782
with:
78-
python-version: ${{ matrix.python }}
83+
activate-environment: true
84+
enable-cache: true
85+
86+
- name: install poe
87+
run: uv tool install poethepoet
7988

8089
- name: Load built wheel file
8190
uses: actions/download-artifact@v4
8291
with:
8392
name: power-grid-model-ds
84-
path: wheelhouse/
93+
path: dist/
8594

8695
- name: Install built wheel file
87-
run: pip install power-grid-model-ds[dev]==${{ needs.build-python.outputs.version }} --find-links=wheelhouse
96+
run: uv pip install power-grid-model-ds[dev]==${{ needs.build-python.outputs.version }} --find-links=dist
8897

89-
- name: Unit test and coverage
90-
run: pytest --verbose
98+
- name: Run All Code Quality Checks & Tests
99+
run: poe all --check
91100

92101
github-release:
102+
if: ${{ github.ref == 'refs/heads/main' && inputs.create_release }}
93103
needs:
94104
- build-python
95105
- tests
@@ -99,22 +109,16 @@ jobs:
99109
outputs:
100110
tag: ${{ steps.tag.outputs.tag }}
101111
steps:
102-
- name: Setup Python 3.13
103-
uses: actions/setup-python@v5
104-
with:
105-
python-version: "3.13"
106-
107112
- name: Checkout source code
108-
uses: actions/checkout@v4 # needed by 'Prevent automatic major/minor release'
113+
uses: actions/checkout@v5
109114

110115
- name: Load built wheel file
111116
uses: actions/download-artifact@v4
112117
with:
113118
name: power-grid-model-ds
114-
path: wheelhouse/
119+
path: dist/
115120

116121
- name: Prevent automatic major/minor release
117-
if: (github.event_name == 'push')
118122
run: |
119123
echo "Fetching the latest release..."
120124
tag=$(gh release view --json tagName --jq '.tagName')
@@ -139,12 +143,44 @@ jobs:
139143
run: echo "${{ steps.tag.outputs.tag }}"
140144

141145
- name: Release
142-
if: (inputs.create_release)
143146
uses: softprops/action-gh-release@v2
144147
with:
145148
files: |
146-
./wheelhouse/*
149+
./dist/*
147150
tag_name: ${{ steps.tag.outputs.tag }}
148-
prerelease: ${{github.ref != 'refs/heads/main'}}
149151
generate_release_notes: true
150152
target_commitish: ${{ github.sha }}
153+
154+
publish:
155+
name: Publish to PyPI
156+
needs: github-release
157+
runs-on: ubuntu-latest
158+
permissions:
159+
contents: write
160+
id-token: write # Required for Trusted Publishing
161+
steps:
162+
- name: Download assets from latest GitHub release using gh CLI
163+
env:
164+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
165+
run: |
166+
mkdir -p assets-to-publish
167+
release_tag="${{ needs.build-test-release.outputs.tag }}"
168+
gh release download "$release_tag" --repo "$GITHUB_REPOSITORY" --dir assets-to-publish
169+
170+
- name: List downloaded assets
171+
run: ls -la assets-to-publish
172+
173+
- name: Upload assets to PyPI
174+
uses: pypa/gh-action-pypi-publish@release/v1
175+
with:
176+
# To test, use the TestPyPI:
177+
# repository-url: https://test.pypi.org/legacy/
178+
# You must also create an account and project on TestPyPI,
179+
# as well as set the trusted-publisher in the project settings:
180+
# https://docs.pypi.org/trusted-publishers/adding-a-publisher/
181+
# To publish to the official PyPI repository, just keep
182+
# repository-url commented out.
183+
packages-dir: assets-to-publish
184+
skip-existing: true
185+
print-hash: true
186+
verbose: true

.github/workflows/check-blocking-labels.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,12 @@
66
name: Check Blocking Labels
77

88
on:
9-
# run pipeline on pull request
109
pull_request:
1110
types:
1211
- opened
1312
- synchronize
1413
- labeled
1514
- unlabeled
16-
# run pipeline on merge queue
17-
merge_group:
18-
# run this workflow manually from the Actions tab
1915
workflow_dispatch:
2016

2117
concurrency:

.github/workflows/check-code-quality.yml

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ name: Check Code Quality
88
on:
99
# run pipeline from another workflow
1010
workflow_call:
11+
inputs:
12+
update_dependencies:
13+
type: boolean
14+
description: Update dependencies to their latest version
15+
default: false
16+
required: false
1117

1218
concurrency:
1319
group: ${{ github.workflow }}-${{ github.ref }}-code-quality
@@ -16,21 +22,52 @@ concurrency:
1622
jobs:
1723
check-code-quality:
1824
runs-on: ubuntu-latest
19-
25+
strategy:
26+
matrix:
27+
python-version: ["3.11", "3.12", "3.13"]
2028
steps:
21-
- name: Checkout
22-
uses: actions/checkout@v4
29+
- name: Checkout source code
30+
uses: actions/checkout@v5
2331

24-
- name: Set up Python
25-
uses: actions/setup-python@v5
32+
- name: Install uv
33+
uses: astral-sh/setup-uv@v6
34+
if: ${{ always() }}
2635
with:
27-
python-version: 3.11
36+
activate-environment: true
37+
enable-cache: true
38+
python-version: ${{ matrix.python-version }}
2839

29-
- name: Upgrade pip
30-
run: pip install --upgrade pip
40+
- name: install poe
41+
if: ${{ always() }}
42+
run: uv tool install poethepoet
3143

3244
- name: Install dependencies
33-
run: pip install -e .[dev]
34-
35-
- name: Run pre-commit on all files
36-
run: pre-commit run --all-files
45+
if: ${{ always() }}
46+
run: uv sync --frozen --dev
47+
48+
- name: Update dependencies
49+
if: ${{ inputs.update_dependencies && always() }}
50+
run: uv sync --upgrade --dev
51+
52+
- name: lint
53+
if: ${{ always() }}
54+
run: poe lint --check
55+
- name: format
56+
if: ${{ always() }}
57+
run: poe format --check
58+
- name: lock
59+
if: ${{ always() }}
60+
run: poe lock
61+
- name: type
62+
if: ${{ always() }}
63+
run: poe type
64+
- name: cover
65+
if: ${{ always() }}
66+
run: poe cover
67+
- name: report
68+
if: ${{ always() }}
69+
run: poe report
70+
71+
- name: Actually stop now if any quality control failed
72+
if: ${{ failure() }}
73+
run: exit 1

.github/workflows/ci.yml

Lines changed: 5 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@
33
# SPDX-License-Identifier: MPL-2.0
44

55

6-
name: CI Build
6+
name: CI/CD
77

88
on:
99
push:
1010
branches:
1111
- main # run pipeline on pull request
1212
pull_request:
13-
merge_group: # run pipeline on merge queue
1413
workflow_dispatch: # run this workflow manually from the Actions tab
1514
inputs:
1615
create_release:
1716
type: boolean
18-
description: Create a (pre-)release when CI passes
17+
description: Create a release (only works on main branch)
1918
default: false
2019
required: true
2120

@@ -30,62 +29,17 @@ jobs:
3029
- run: echo "ci started"
3130

3231
build-test-release:
32+
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
3333
name: build-test-release
3434
uses: "./.github/workflows/build-test-release.yml"
3535
permissions:
3636
contents: write
37+
id-token: write # Required for Trusted Publishing
3738
with:
38-
create_release: ${{ (github.event_name == 'workflow_dispatch' && inputs.create_release) || (github.event_name == 'push') }}
39+
create_release: ${{ inputs.create_release }}
3940

4041
check-code-quality:
4142
uses: "./.github/workflows/check-code-quality.yml"
4243

4344
reuse-compliance:
4445
uses: "./.github/workflows/reuse-compliance.yml"
45-
46-
ci-passed:
47-
runs-on: ubuntu-latest
48-
needs: [ci-started, build-test-release, check-code-quality, reuse-compliance]
49-
if: always()
50-
51-
steps:
52-
# this explicit check is needed cfr. https://github.com/orgs/community/discussions/75568
53-
- name: "Check whether all jobs passed"
54-
run: echo '${{ toJSON(needs) }}' | jq -e 'to_entries | all(.value.result == "success")'
55-
- run: echo "ci passed"
56-
57-
publish:
58-
name: Publish to PyPI
59-
runs-on: ubuntu-latest
60-
permissions:
61-
contents: write
62-
id-token: write # Required for Trusted Publishing
63-
needs: build-test-release
64-
if: (github.event_name == 'workflow_dispatch' && inputs.create_release) || github.event_name == 'push'
65-
66-
steps:
67-
- name: Download assets from latest GitHub release using gh CLI
68-
env:
69-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70-
run: |
71-
mkdir -p assets-to-publish
72-
release_tag="${{ needs.build-test-release.outputs.tag }}"
73-
gh release download "$release_tag" --repo "$GITHUB_REPOSITORY" --dir assets-to-publish
74-
75-
- name: List downloaded assets
76-
run: ls -la assets-to-publish
77-
78-
- name: Upload assets to PyPI
79-
uses: pypa/gh-action-pypi-publish@release/v1
80-
with:
81-
# To test, use the TestPyPI:
82-
# repository-url: https://test.pypi.org/legacy/
83-
# You must also create an account and project on TestPyPI,
84-
# as well as set the trusted-publisher in the project settings:
85-
# https://docs.pypi.org/trusted-publishers/adding-a-publisher/
86-
# To publish to the official PyPI repository, just keep
87-
# repository-url commented out.
88-
packages-dir: assets-to-publish
89-
skip-existing: true
90-
print-hash: true
91-
verbose: true

.github/workflows/citations.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,5 @@ jobs:
3131
steps:
3232
- name: checkout
3333
uses: actions/checkout@v4
34-
- name: Install R
35-
run: |
36-
sudo apt-get update && sudo apt-get install -y r-base
3734
- name: Validate CITATION.cff
3835
uses: dieghernan/cff-validator@v4

.github/workflows/dco-merge-group.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/nightly.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,7 @@ concurrency:
1515
cancel-in-progress: true
1616

1717
jobs:
18-
build-test-release:
19-
uses: "./.github/workflows/build-test-release.yml"
20-
permissions:
21-
contents: write
22-
with:
23-
create_release: false
24-
2518
check-code-quality:
2619
uses: "./.github/workflows/check-code-quality.yml"
27-
28-
reuse-compliance:
29-
uses: "./.github/workflows/reuse-compliance.yml"
20+
with:
21+
update_dependencies: true

0 commit comments

Comments
 (0)