Skip to content

Commit fcf4442

Browse files
Merge branch 'main' into fista
2 parents 8ef16ea + 202d395 commit fcf4442

File tree

157 files changed

+7913
-1156
lines changed

Some content is hidden

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

157 files changed

+7913
-1156
lines changed

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.github
2+
.vscode
3+
binder
4+
examples
5+
docs
6+
tests

.github/workflows/deployment.yml

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
name: Build and Deploy Package
2+
3+
on:
4+
push:
5+
paths:
6+
- src/mrpro/VERSION
7+
8+
jobs:
9+
build-testpypi-package:
10+
name: Build Package for TestPyPI
11+
runs-on: ubuntu-latest
12+
outputs:
13+
version: ${{ steps.set_suffix.outputs.version }}
14+
suffix: ${{ steps.set_suffix.outputs.suffix }}
15+
version_changed: ${{ steps.changes.outputs.version_changed }}
16+
steps:
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.x"
21+
22+
- name: Checkout Code
23+
uses: actions/checkout@v4
24+
25+
- name: Check if VERSION file is modified compared to main
26+
uses: dorny/paths-filter@v3
27+
id: changes
28+
with:
29+
base: main
30+
filters: |
31+
version_changed:
32+
- 'src/mrpro/VERSION'
33+
34+
- name: Set Version Suffix
35+
id: set_suffix
36+
run: |
37+
VERSION=$(cat src/mrpro/VERSION)
38+
SUFFIX=rc$(date +%s)
39+
echo "MRPROVERSIONSUFFIX=$SUFFIX" >> $GITHUB_ENV
40+
echo "suffix=$SUFFIX" >> $GITHUB_OUTPUT
41+
echo "version=$VERSION" >> $GITHUB_OUTPUT
42+
43+
- name: Build Package
44+
run: |
45+
python -m pip install --upgrade build
46+
python -m build
47+
48+
- name: Upload TestPyPI Distribution Artifact
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: testpypi-package-distribution
52+
path: dist/
53+
54+
testpypi-deployment:
55+
name: Deploy to TestPyPI
56+
needs:
57+
- build-testpypi-package
58+
runs-on: ubuntu-latest
59+
if: needs.build-testpypi-package.outputs.version_changed == 'true'
60+
61+
environment:
62+
name: testpypi
63+
url: https://test.pypi.org/p/mrpro
64+
65+
permissions:
66+
id-token: write
67+
68+
steps:
69+
- name: Download TestPyPI Distribution
70+
uses: actions/download-artifact@v4
71+
with:
72+
name: testpypi-package-distribution
73+
path: dist/
74+
75+
- name: Publish to TestPyPI
76+
uses: pypa/gh-action-pypi-publish@release/v1
77+
with:
78+
repository-url: https://test.pypi.org/legacy/
79+
verbose: true
80+
81+
test-install-from-testpypi:
82+
name: Test Installation from TestPyPI
83+
needs:
84+
- testpypi-deployment
85+
- build-testpypi-package
86+
runs-on: ubuntu-latest
87+
steps:
88+
- name: Set up Python
89+
uses: actions/setup-python@v5
90+
with:
91+
python-version: "3.x"
92+
93+
- name: Install MRpro from TestPyPI
94+
run: |
95+
VERSION=${{ needs.build-testpypi-package.outputs.version }}
96+
SUFFIX=${{ needs.build-testpypi-package.outputs.suffix }}
97+
for i in {1..3}; do
98+
if python -m pip install mrpro==$VERSION$SUFFIX --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/; then
99+
echo "Package installed successfully."
100+
break
101+
else
102+
echo "Attempt $i failed. Retrying in 10 seconds..."
103+
sleep 10
104+
fi
105+
done
106+
107+
build-pypi-package:
108+
name: Build Package for PyPI
109+
runs-on: ubuntu-latest
110+
needs:
111+
- test-install-from-testpypi
112+
outputs:
113+
version: ${{ steps.get_version.outputs.version }}
114+
steps:
115+
- name: Checkout Code
116+
uses: actions/checkout@v4
117+
118+
- name: Set up Python
119+
uses: actions/setup-python@v5
120+
with:
121+
python-version: "3.x"
122+
123+
- name: Install Automatic Versioning Tool
124+
run: |
125+
python -m pip install setuptools-git-versioning
126+
127+
- name: Get Current Version
128+
id: get_version
129+
run: |
130+
VERSION=$(python -m setuptools_git_versioning)
131+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
132+
133+
- name: Build Package
134+
run: |
135+
python -m pip install --upgrade build
136+
python -m build
137+
138+
- name: Store PyPI Distribution
139+
uses: actions/upload-artifact@v4
140+
with:
141+
name: pypi-package-distribution
142+
path: dist/
143+
144+
pypi-deployment:
145+
name: Deploy to PyPI
146+
needs:
147+
- build-pypi-package
148+
if: github.ref == 'refs/heads/main'
149+
runs-on: ubuntu-latest
150+
151+
environment:
152+
name: pypi
153+
url: https://pypi.org/project/mrpro
154+
155+
permissions:
156+
contents: write
157+
id-token: write
158+
159+
steps:
160+
- name: Download PyPI Distribution
161+
uses: actions/download-artifact@v4
162+
with:
163+
name: pypi-package-distribution
164+
path: dist/
165+
166+
- name: Create Tag
167+
uses: actions/github-script@v7
168+
with:
169+
script: |
170+
github.rest.git.createRef({
171+
owner: context.repo.owner,
172+
repo: context.repo.repo,
173+
ref: 'refs/tags/v${{ needs.build-pypi-package.outputs.version }}',
174+
sha: context.sha
175+
})
176+
177+
- name: Create Release
178+
uses: actions/github-script@v7
179+
with:
180+
github-token: "${{ secrets.GITHUB_TOKEN }}"
181+
script: |
182+
github.rest.repos.createRelease({
183+
draft: false,
184+
generate_release_notes: true,
185+
name: "v${{ needs.build-pypi-package.outputs.version }}",
186+
owner: context.repo.owner,
187+
prerelease: false,
188+
repo: context.repo.repo,
189+
tag_name: "v${{ needs.build-pypi-package.outputs.version }}",
190+
});
191+
192+
- name: Publish to PyPI
193+
uses: pypa/gh-action-pypi-publish@release/v1
194+
with:
195+
repository-url: https://upload.pypi.org/legacy/
196+
verbose: true
197+
198+
concurrency:
199+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
200+
201+
# Cancel in-progress runs when a new workflow with the same group name is triggered
202+
cancel-in-progress: true

.github/workflows/docker.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ jobs:
6262
permissions:
6363
packages: write
6464
strategy:
65+
fail-fast: false
6566
matrix:
6667
dockerfile: ${{ fromJson(needs.get_dockerfiles.outputs.dockerfiles) }}
6768
steps:
@@ -87,7 +88,9 @@ jobs:
8788
- name: Build and push Docker image
8889
uses: docker/build-push-action@v6
8990
with:
90-
context: ./docker
91+
context: .
92+
cache-from: type=gha,scope=${{ matrix.dockerfile }}
93+
cache-to: type=gha,mode=max,scope=${{ matrix.dockerfile }}
9194
file: ./docker/${{ matrix.dockerfile }}
9295
push: true
9396
tags: ${{ steps.image_name.outputs.image_name }}:test

.github/workflows/docs.yml

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ jobs:
9292
image: ghcr.io/ptb-mr/mrpro_py311:latest
9393
options: --user root
9494
strategy:
95+
fail-fast: false
9596
matrix:
9697
notebook: ${{ fromJson(needs.get_notebooks.outputs.notebooks) }}
9798
steps:
@@ -137,6 +138,9 @@ jobs:
137138
container:
138139
image: ghcr.io/ptb-mr/mrpro_py311:latest
139140
options: --user runner
141+
permissions:
142+
pull-requests: write
143+
contents: write
140144
steps:
141145
- name: Checkout
142146
uses: actions/checkout@v4
@@ -181,21 +185,57 @@ jobs:
181185
done
182186
183187
- name: Build docs
184-
run: sphinx-build -b html ./docs/source ./docs/build/html
185-
186-
- name: Deploy to GitHub Pages
187-
uses: peaceiris/actions-gh-pages@v4
188-
with:
189-
publish_branch: github-pages
190-
github_token: ${{ secrets.GITHUB_TOKEN }}
191-
publish_dir: ./docs/build/html
192-
if: github.event_name != 'pull_request'
188+
run: |
189+
sphinx-build -b html ./docs/source ./docs/build/html
190+
rm -rf ./docs/build/html/.doctrees
193191
194192
- name: Save Documentation
193+
id: save_docu
195194
uses: actions/upload-artifact@v4
196195
with:
197196
name: Documentation
198197
path: docs/build/html/
198+
199+
- run: echo 'Artifact url ${{ steps.save_docu.outputs.artifact-url }}'
200+
201+
- run: echo 'Event number ${{ github.event.number }}'
202+
203+
- run: echo 'Event name ${{github.event_name}}'
204+
205+
- name: Update PR with link to summary
206+
if: github.event_name == 'pull_request'
207+
uses: edumserrano/find-create-or-update-comment@v3
208+
with:
209+
issue-number: ${{ github.event.pull_request.number }}
210+
body-includes: '<!-- documentation build ${{ github.event.number }} -->'
211+
comment-author: 'github-actions[bot]'
212+
body: |
213+
<!-- documentation build ${{ github.event.number }} -->
214+
### :books: Documentation
215+
:file_folder: [Download as zip](${{ steps.save_docu.outputs.artifact-url }})
216+
:mag: [View online](https://zimf.de/zipserve/${{ steps.save_docu.outputs.artifact-url }}/)
217+
edit-mode: replace
218+
219+
- name: Upload pages
220+
uses: actions/upload-pages-artifact@v3
221+
with:
222+
path: docs/build/html/
223+
if: github.event_name != 'pull_request'
224+
225+
deploy:
226+
if: github.ref == 'refs/heads/main'
227+
permissions:
228+
pages: write
229+
id-token: write
230+
environment:
231+
name: github-pages
232+
url: ${{ steps.deployment.outputs.page_url }}
233+
runs-on: ubuntu-latest
234+
needs: create_documentation
235+
steps:
236+
- name: Deploy to GitHub Pages
237+
id: deployment
238+
uses: actions/deploy-pages@v4
199239

200240
concurrency:
201241
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}

0 commit comments

Comments
 (0)