@@ -46,177 +46,6 @@ jobs:
4646 # otherwise create_release becomes false
4747 create_release : ${{ (github.event_name == 'workflow_dispatch' && inputs.create_release) || github.event_name == 'push'}}
4848
49- build-python :
50- runs-on : ubuntu-latest
51- outputs :
52- version : ${{ steps.version.outputs.version }}
53- steps :
54-
55- - name : Checkout source code
56- uses : actions/checkout@v4
57-
58- - name : Setup Python 3.13
59- uses : actions/setup-python@v5
60- with :
61- python-version : " 3.13"
62-
63- - name : Set PyPI version
64- uses : PowerGridModel/pgm-version-bump@main
65- with :
66- token : ${{ secrets.GITHUB_TOKEN }}
67-
68- - name : Build
69- run : |
70- cat PYPI_VERSION
71- pip install build
72- python -m build --outdir wheelhouse .
73-
74- - name : Save version
75- id : version
76- run : echo "version=$(cat PYPI_VERSION)" >> $GITHUB_OUTPUT
77-
78- - name : Store built wheel file
79- uses : actions/upload-artifact@v4
80- with :
81- name : power-grid-model-io
82- path : wheelhouse/
83-
84- sonar-cloud :
85- permissions :
86- contents : write
87- runs-on : ubuntu-latest
88- steps :
89-
90- - name : Checkout source code
91- uses : actions/checkout@v4
92- with :
93- fetch-depth : 0 # Shallow clones should be disabled for a better relevancy of analysis
94-
95- - name : Setup Python 3.11
96- uses : actions/setup-python@v5
97- with :
98- python-version : " 3.11"
99-
100- - name : Install in develop mode
101- run : |
102- pip install -e .[dev]
103-
104- - name : Test and Coverage
105- run : |
106- pytest --cov-report=xml:coverage.xml --cov-fail-under=0
107-
108- # Fix relative paths in coverage file
109- # Known bug: https://community.sonarsource.com/t/sonar-on-github-actions-with-python-coverage-source-issue/36057
110- sed -i 's@/home/runner/work/power-grid-model-io/power-grid-model-io@/github/workspace@g' coverage.xml
111-
112- - name : SonarCloud Scan
113- if : ${{ (github.event_name == 'push') || (github.event.pull_request.head.repo.owner.login == 'PowerGridModel') }}
114- uses : SonarSource/sonarqube-scan-action@master
115- env :
116- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
117- SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
118-
119- unit-tests :
120- needs : build-python
121- strategy :
122- matrix :
123- os : [ubuntu-latest, macos-latest, windows-latest]
124- python : ["3.11", "3.12"]
125- fail-fast : false
126- runs-on : ${{ matrix.os }}
127-
128- steps :
129-
130- - name : Checkout source code
131- uses : actions/checkout@v4
132-
133- - name : Setup Python ${{ matrix.python }}
134- uses : actions/setup-python@v5
135- with :
136- python-version : ${{ matrix.python }}
137-
138- - name : Load built wheel file
139- uses : actions/download-artifact@v4
140- with :
141- name : power-grid-model-io
142- path : wheelhouse/
143-
144- - name : Install built wheel file
145- run : pip install power-grid-model-io[dev]==${{ needs.build-python.outputs.version }} --find-links=wheelhouse
146-
147- - name : Unit test and coverage
148- run : pytest --verbose
149-
150- validation-tests :
151- needs : build-python
152- strategy :
153- matrix :
154- os : [ubuntu-latest, macos-latest, windows-latest]
155- python : ["3.11", "3.12"]
156- fail-fast : false
157- runs-on : ${{ matrix.os }}
158-
159- steps :
160-
161- - name : Checkout source code
162- uses : actions/checkout@v4
163-
164- - name : Setup Python ${{ matrix.python }}
165- uses : actions/setup-python@v5
166- with :
167- python-version : ${{ matrix.python }}
168-
169- - name : Load built wheel file
170- uses : actions/download-artifact@v4
171- with :
172- name : power-grid-model-io
173- path : wheelhouse/
174-
175- - name : Install built wheel file
176- run : pip install power-grid-model-io[dev]==${{ needs.build-python.outputs.version }} --find-links=wheelhouse
177-
178- - name : Validation tests
179- run : pytest tests/validation --no-cov --verbose
180-
181- github-release :
182- needs :
183- - build-python
184- - unit-tests
185- - validation-tests
186- - sonar-cloud
187- permissions :
188- contents : write
189- runs-on : ubuntu-latest
190- steps :
191- - name : Setup Python 3.13
192- uses : actions/setup-python@v5
193- with :
194- python-version : " 3.13"
195-
196- - name : Load built wheel file
197- uses : actions/download-artifact@v4
198- with :
199- name : power-grid-model-io
200- path : wheelhouse/
201-
202- - name : Get tag
203- id : tag
204- run : echo "tag=v${{ needs.build-python.outputs.version }}" >> $GITHUB_OUTPUT
205-
206- - name : Display tag
207- run : echo "${{ steps.tag.outputs.tag }}"
208-
209- - name : Create GitHub release
210- if : (github.event_name == 'push') || ((github.event_name == 'workflow_dispatch') && (github.event.inputs.create_release == 'true'))
211- uses : softprops/action-gh-release@v2
212- with :
213- files : |
214- ./wheelhouse/*
215- tag_name : " ${{ steps.tag.outputs.tag }}"
216- prerelease : ${{github.ref != 'refs/heads/main'}}
217- generate_release_notes : true
218- target_commitish : ${{ github.sha }}
219-
22049 publish :
22150 name : Publish to PyPI
22251 runs-on : ubuntu-latest
0 commit comments