Skip to content

Commit 5535460

Browse files
authored
Merge branch 'main' into feature/use-enum
Signed-off-by: Zhen Wang <[email protected]>
2 parents a4500e7 + 9062334 commit 5535460

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+7810
-504
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ updates:
99
directory: "/"
1010
schedule:
1111
interval: "weekly"
12+
- package-ecosystem: "pip"
13+
directory: "/"
14+
schedule:
15+
interval: "weekly"

.github/workflows/build-test-and-sonar.yml renamed to .github/workflows/build-test-release.yml

Lines changed: 24 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,9 @@
33
# SPDX-License-Identifier: MPL-2.0
44

55

6-
name: Build, Test, Sonar and Publish
6+
name: Build and Test
77

88
on:
9-
push:
10-
branches:
11-
- main
12-
# run pipeline on pull request
13-
pull_request:
14-
# run pipeline on merge queue
15-
merge_group:
169
# run pipeline from another workflow
1710
workflow_call:
1811
inputs:
@@ -45,15 +38,20 @@ jobs:
4538
- name: Checkout source code
4639
uses: actions/checkout@v4
4740

48-
- name: Setup Python 3.11
41+
- name: Setup Python 3.13
4942
uses: actions/setup-python@v5
5043
with:
51-
python-version: "3.11"
44+
python-version: "3.13"
45+
46+
- name: Set PyPI version
47+
uses: PowerGridModel/pgm-version-bump@main
48+
with:
49+
token: ${{ secrets.GITHUB_TOKEN }}
5250

5351
- name: Build
5452
run: |
55-
pip install requests build
56-
python set_pypi_version.py
53+
cat PYPI_VERSION
54+
pip install build
5755
python -m build --outdir wheelhouse .
5856
5957
- name: Save version
@@ -66,47 +64,12 @@ jobs:
6664
name: power-grid-model-io
6765
path: wheelhouse/
6866

69-
sonar-cloud:
70-
permissions:
71-
contents: write
72-
runs-on: ubuntu-latest
73-
steps:
74-
75-
- name: Checkout source code
76-
uses: actions/checkout@v4
77-
with:
78-
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
79-
80-
- name: Setup Python 3.11
81-
uses: actions/setup-python@v5
82-
with:
83-
python-version: "3.11"
84-
85-
- name: Install in develop mode
86-
run: |
87-
pip install -e .[dev]
88-
89-
- name: Test and Coverage
90-
run: |
91-
pytest --cov-report=xml:coverage.xml --cov-fail-under=0
92-
93-
# Fix relative paths in coverage file
94-
# Known bug: https://community.sonarsource.com/t/sonar-on-github-actions-with-python-coverage-source-issue/36057
95-
sed -i 's@/home/runner/work/power-grid-model-io/power-grid-model-io@/github/workspace@g' coverage.xml
96-
97-
- name: SonarCloud Scan
98-
if: ${{ (github.event_name == 'push') || (github.event.pull_request.head.repo.owner.login == 'PowerGridModel') }}
99-
uses: SonarSource/sonarqube-scan-action@master
100-
env:
101-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
102-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
103-
10467
unit-tests:
10568
needs: build-python
10669
strategy:
10770
matrix:
10871
os: [ubuntu-latest, macos-latest, windows-latest]
109-
python: ["3.11", "3.12"]
72+
python: ["3.11", "3.12", "3.13"]
11073
fail-fast: false
11174
runs-on: ${{ matrix.os }}
11275

@@ -137,7 +100,7 @@ jobs:
137100
strategy:
138101
matrix:
139102
os: [ubuntu-latest, macos-latest, windows-latest]
140-
python: ["3.11", "3.12"]
103+
python: ["3.11", "3.12", "3.13"]
141104
fail-fast: false
142105
runs-on: ${{ matrix.os }}
143106

@@ -163,44 +126,40 @@ jobs:
163126
- name: Validation tests
164127
run: pytest tests/validation --no-cov --verbose
165128

166-
publish:
129+
github-release:
167130
needs:
168131
- build-python
169132
- unit-tests
170133
- validation-tests
171-
- sonar-cloud
172134
permissions:
173135
contents: write
174-
env:
175-
TWINE_USERNAME: ${{ secrets.PYPI_USER }}
176-
TWINE_PASSWORD: ${{ secrets.PYPI_PASS }}
177136
runs-on: ubuntu-latest
178137
steps:
179-
- name: Setup Python 3.11
138+
- name: Setup Python 3.13
180139
uses: actions/setup-python@v5
181140
with:
182-
python-version: "3.11"
141+
python-version: "3.13"
183142

184143
- name: Load built wheel file
185144
uses: actions/download-artifact@v4
186145
with:
187146
name: power-grid-model-io
188147
path: wheelhouse/
189148

190-
- name: Upload wheels
191-
if: (github.event_name == 'push') || ((github.event_name == 'workflow_dispatch') && (github.event.inputs.create_release == 'true'))
192-
run: |
193-
pip install twine
194-
echo "Publish to PyPI..."
195-
twine upload --verbose wheelhouse/*
149+
- name: Get tag
150+
id: tag
151+
run: echo "tag=v${{ needs.build-python.outputs.version }}" >> $GITHUB_OUTPUT
152+
153+
- name: Display tag
154+
run: echo "${{ steps.tag.outputs.tag }}"
196155

197-
- name: Release
198-
if: (github.event_name == 'push') || ((github.event_name == 'workflow_dispatch') && (github.event.inputs.create_release == 'true'))
156+
- name: Create GitHub release
157+
if: (inputs.create_release)
199158
uses: softprops/action-gh-release@v2
200159
with:
201160
files: |
202161
./wheelhouse/*
203-
tag_name: v${{ needs.build-python.outputs.version }}
162+
tag_name: "${{ steps.tag.outputs.tag }}"
204163
prerelease: ${{github.ref != 'refs/heads/main'}}
205164
generate_release_notes: true
206165
target_commitish: ${{ github.sha }}

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

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66
name: Check Code Quality
77

88
on:
9-
push:
10-
branches:
11-
- main
12-
# run pipeline on pull request
13-
pull_request:
14-
# run pipeline on merge queue
15-
merge_group:
169
# run pipeline from another workflow
1710
workflow_call:
1811

@@ -36,25 +29,16 @@ jobs:
3629
- name: Upgrade pip
3730
run: pip install --upgrade pip
3831

39-
- name: Install and run isort
40-
run: |
41-
pip install isort
42-
isort .
43-
44-
- name: Install and run black
45-
run: |
46-
pip install black[jupyter]
47-
black .
48-
4932
- name: Install and run mypy
5033
run: |
5134
pip install mypy
5235
mypy src
5336
54-
- name: Install and run pylint
37+
- name: Install and run ruff
5538
run: |
56-
pip install pylint .
57-
pylint power_grid_model_io
39+
pip install ruff .
40+
ruff check .
41+
ruff format .
5842
5943
- name: If needed raise error
6044
run: |

.github/workflows/check-blocking-labels.yml renamed to .github/workflows/check-pr-labels.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# SPDX-License-Identifier: MPL-2.0
44

55

6-
name: Check Blocking Labels
6+
name: Check PR Labels
77

88
on:
99
# run pipeline on pull request
@@ -19,14 +19,22 @@ on:
1919
workflow_dispatch:
2020

2121
concurrency:
22-
group: ${{ github.workflow }}-${{ github.ref }}-blocking-labels
22+
group: ${{ github.workflow }}-${{ github.ref }}-pr-labels
2323
cancel-in-progress: true
2424

2525
jobs:
26-
check-blocking-labels:
26+
check-pr-labels:
2727
runs-on: ubuntu-latest
2828
steps:
29-
29+
30+
- name: fail-if-no-label
31+
if: github.event_name == 'pull_request'
32+
run: |
33+
if [ "$(jq '.pull_request.labels | length' "$GITHUB_EVENT_PATH")" -eq 0 ]; then
34+
echo "This pull request has no labels. Please add at least one label."
35+
exit 1
36+
fi
37+
3038
- name: do-not-merge
3139
if: contains(github.event.pull_request.labels.*.name, 'do-not-merge')
3240
run: |

.github/workflows/ci.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
2+
#
3+
# SPDX-License-Identifier: MPL-2.0
4+
5+
6+
name: CI Build
7+
8+
on:
9+
push:
10+
branches:
11+
- main
12+
# run pipeline on pull request
13+
pull_request:
14+
# run pipeline on merge queue
15+
merge_group:
16+
# run this workflow manually from the Actions tab
17+
workflow_dispatch:
18+
inputs:
19+
create_release:
20+
type: boolean
21+
description: Create a (pre-)release when CI passes
22+
default: false
23+
required: true
24+
25+
concurrency:
26+
group: ${{ github.workflow }}-${{ github.ref }}-ci-build
27+
cancel-in-progress: true
28+
29+
jobs:
30+
ci-started:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- run: echo "ci started"
34+
35+
build-test-release:
36+
name: build-test-release
37+
uses: "./.github/workflows/build-test-release.yml"
38+
permissions:
39+
contents: write
40+
with:
41+
# create_release becomes true if the event that triggered this workflow is "workflow_dispatch" and inputs.create_release is true
42+
# create_release becomes true if the event that triggered this workflow is "push" on main
43+
# otherwise create_release becomes false
44+
create_release: ${{ (github.event_name == 'workflow_dispatch' && inputs.create_release) || github.event_name == 'push'}}
45+
46+
check-code-quality:
47+
uses: "./.github/workflows/check-code-quality.yml"
48+
49+
reuse-compliance:
50+
uses: "./.github/workflows/reuse-compliance.yml"
51+
52+
ci-passed:
53+
runs-on: ubuntu-latest
54+
needs: [ci-started, build-test-release, check-code-quality, reuse-compliance]
55+
if: always()
56+
57+
steps:
58+
# this explicit check is needed cfr. https://github.com/orgs/community/discussions/75568
59+
- name: "Check whether all jobs passed"
60+
run: echo '${{ toJSON(needs) }}' | jq -e 'to_entries | all(.value.result == "success")'
61+
- run: echo "ci passed"
62+
63+
publish:
64+
name: Publish to PyPI
65+
runs-on: ubuntu-latest
66+
permissions:
67+
contents: write
68+
id-token: write # Required for Trusted Publishing
69+
needs: build-test-release
70+
if: (github.event_name == 'workflow_dispatch' && inputs.create_release) || github.event_name == 'push'
71+
72+
steps:
73+
- name: Download assets from GitHub release
74+
uses: robinraju/release-downloader@v1
75+
with:
76+
repository: ${{ github.repository }}
77+
# download the latest release
78+
latest: true
79+
# don't download pre-releases
80+
preRelease: false
81+
fileName: "*"
82+
# don't download GitHub-generated source tar and zip files
83+
tarBall: false
84+
zipBall: false
85+
# create a directory to store the downloaded assets
86+
out-file-path: assets-to-publish
87+
# don't extract downloaded files
88+
extract: false
89+
90+
- name: List downloaded assets
91+
run: ls -la assets-to-publish
92+
93+
- name: Upload assets to PyPI
94+
uses: pypa/gh-action-pypi-publish@release/v1
95+
with:
96+
# To test, use the TestPyPI:
97+
# repository-url: https://test.pypi.org/legacy/
98+
# You must also create an account and project on TestPyPI,
99+
# as well as set the trusted-publisher in the project settings:
100+
# https://docs.pypi.org/trusted-publishers/adding-a-publisher/
101+
# To publish to the official PyPI repository, just keep
102+
# repository-url commented out.
103+
packages-dir: assets-to-publish
104+
skip-existing: true
105+
print-hash: true
106+
verbose: true

.github/workflows/nightly.yml

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

1717
jobs:
18-
main:
19-
uses: "./.github/workflows/build-test-and-sonar.yml"
18+
build-test-release:
19+
uses: "./.github/workflows/build-test-release.yml"
2020
permissions:
2121
contents: write
2222
with:

.github/workflows/reuse-compliance.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66
name: REUSE Compliance Check
77

88
on:
9-
push:
10-
branches:
11-
- main
12-
# run pipeline on pull request
13-
pull_request:
14-
# run pipeline on merge queue
15-
merge_group:
169
# run pipeline from another workflow
1710
workflow_call:
1811
# run this workflow manually from the Actions tab

0 commit comments

Comments
 (0)