Skip to content

Commit

Permalink
Merge branch 'main' into fista
Browse files Browse the repository at this point in the history
  • Loading branch information
fzimmermann89 authored Nov 12, 2024
2 parents 8ef16ea + 202d395 commit fcf4442
Show file tree
Hide file tree
Showing 157 changed files with 7,913 additions and 1,156 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.github
.vscode
binder
examples
docs
tests
202 changes: 202 additions & 0 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
name: Build and Deploy Package

on:
push:
paths:
- src/mrpro/VERSION

jobs:
build-testpypi-package:
name: Build Package for TestPyPI
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set_suffix.outputs.version }}
suffix: ${{ steps.set_suffix.outputs.suffix }}
version_changed: ${{ steps.changes.outputs.version_changed }}
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Checkout Code
uses: actions/checkout@v4

- name: Check if VERSION file is modified compared to main
uses: dorny/paths-filter@v3
id: changes
with:
base: main
filters: |
version_changed:
- 'src/mrpro/VERSION'
- name: Set Version Suffix
id: set_suffix
run: |
VERSION=$(cat src/mrpro/VERSION)
SUFFIX=rc$(date +%s)
echo "MRPROVERSIONSUFFIX=$SUFFIX" >> $GITHUB_ENV
echo "suffix=$SUFFIX" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Build Package
run: |
python -m pip install --upgrade build
python -m build
- name: Upload TestPyPI Distribution Artifact
uses: actions/upload-artifact@v4
with:
name: testpypi-package-distribution
path: dist/

testpypi-deployment:
name: Deploy to TestPyPI
needs:
- build-testpypi-package
runs-on: ubuntu-latest
if: needs.build-testpypi-package.outputs.version_changed == 'true'

environment:
name: testpypi
url: https://test.pypi.org/p/mrpro

permissions:
id-token: write

steps:
- name: Download TestPyPI Distribution
uses: actions/download-artifact@v4
with:
name: testpypi-package-distribution
path: dist/

- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
verbose: true

test-install-from-testpypi:
name: Test Installation from TestPyPI
needs:
- testpypi-deployment
- build-testpypi-package
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install MRpro from TestPyPI
run: |
VERSION=${{ needs.build-testpypi-package.outputs.version }}
SUFFIX=${{ needs.build-testpypi-package.outputs.suffix }}
for i in {1..3}; do
if python -m pip install mrpro==$VERSION$SUFFIX --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/; then
echo "Package installed successfully."
break
else
echo "Attempt $i failed. Retrying in 10 seconds..."
sleep 10
fi
done
build-pypi-package:
name: Build Package for PyPI
runs-on: ubuntu-latest
needs:
- test-install-from-testpypi
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install Automatic Versioning Tool
run: |
python -m pip install setuptools-git-versioning
- name: Get Current Version
id: get_version
run: |
VERSION=$(python -m setuptools_git_versioning)
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Build Package
run: |
python -m pip install --upgrade build
python -m build
- name: Store PyPI Distribution
uses: actions/upload-artifact@v4
with:
name: pypi-package-distribution
path: dist/

pypi-deployment:
name: Deploy to PyPI
needs:
- build-pypi-package
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest

environment:
name: pypi
url: https://pypi.org/project/mrpro

permissions:
contents: write
id-token: write

steps:
- name: Download PyPI Distribution
uses: actions/download-artifact@v4
with:
name: pypi-package-distribution
path: dist/

- name: Create Tag
uses: actions/github-script@v7
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/v${{ needs.build-pypi-package.outputs.version }}',
sha: context.sha
})
- name: Create Release
uses: actions/github-script@v7
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
script: |
github.rest.repos.createRelease({
draft: false,
generate_release_notes: true,
name: "v${{ needs.build-pypi-package.outputs.version }}",
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: "v${{ needs.build-pypi-package.outputs.version }}",
});
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://upload.pypi.org/legacy/
verbose: true

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

# Cancel in-progress runs when a new workflow with the same group name is triggered
cancel-in-progress: true
5 changes: 4 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ jobs:
permissions:
packages: write
strategy:
fail-fast: false
matrix:
dockerfile: ${{ fromJson(needs.get_dockerfiles.outputs.dockerfiles) }}
steps:
Expand All @@ -87,7 +88,9 @@ jobs:
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./docker
context: .
cache-from: type=gha,scope=${{ matrix.dockerfile }}
cache-to: type=gha,mode=max,scope=${{ matrix.dockerfile }}
file: ./docker/${{ matrix.dockerfile }}
push: true
tags: ${{ steps.image_name.outputs.image_name }}:test
Expand Down
58 changes: 49 additions & 9 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ jobs:
image: ghcr.io/ptb-mr/mrpro_py311:latest
options: --user root
strategy:
fail-fast: false
matrix:
notebook: ${{ fromJson(needs.get_notebooks.outputs.notebooks) }}
steps:
Expand Down Expand Up @@ -137,6 +138,9 @@ jobs:
container:
image: ghcr.io/ptb-mr/mrpro_py311:latest
options: --user runner
permissions:
pull-requests: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -181,21 +185,57 @@ jobs:
done
- name: Build docs
run: sphinx-build -b html ./docs/source ./docs/build/html

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
publish_branch: github-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/build/html
if: github.event_name != 'pull_request'
run: |
sphinx-build -b html ./docs/source ./docs/build/html
rm -rf ./docs/build/html/.doctrees
- name: Save Documentation
id: save_docu
uses: actions/upload-artifact@v4
with:
name: Documentation
path: docs/build/html/

- run: echo 'Artifact url ${{ steps.save_docu.outputs.artifact-url }}'

- run: echo 'Event number ${{ github.event.number }}'

- run: echo 'Event name ${{github.event_name}}'

- name: Update PR with link to summary
if: github.event_name == 'pull_request'
uses: edumserrano/find-create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: '<!-- documentation build ${{ github.event.number }} -->'
comment-author: 'github-actions[bot]'
body: |
<!-- documentation build ${{ github.event.number }} -->
### :books: Documentation
:file_folder: [Download as zip](${{ steps.save_docu.outputs.artifact-url }})
:mag: [View online](https://zimf.de/zipserve/${{ steps.save_docu.outputs.artifact-url }}/)
edit-mode: replace

- name: Upload pages
uses: actions/upload-pages-artifact@v3
with:
path: docs/build/html/
if: github.event_name != 'pull_request'

deploy:
if: github.ref == 'refs/heads/main'
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: create_documentation
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand Down
Loading

0 comments on commit fcf4442

Please sign in to comment.