Add tests for autodiff of operators #2444
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PyTest | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
jobs: | |
get_dockerfiles: | |
name: Get List of Dockerfiles for Containers | |
runs-on: ubuntu-latest | |
permissions: | |
packages: read | |
outputs: | |
imagenames: ${{ steps.set-matrix.outputs.imagenames }} | |
steps: | |
- name: Retrieve Docker Image Names | |
id: set-matrix | |
env: | |
GH_TOKEN: ${{ secrets.GHCR_TOKEN }} | |
run: | | |
imagenames=$(curl -s --request GET \ | |
--url "https://api.github.com/orgs/PTB-MR/packages?package_type=container" \ | |
--header "Authorization: Bearer $GH_TOKEN" | jq -r '.[].name') | |
echo "image names: $imagenames" | |
imagenames_latest=() | |
for image in $(echo $imagenames) | |
do | |
echo "checking $image ..." | |
if docker manifest inspect "ghcr.io/ptb-mr/"$image":latest" >/dev/null; then | |
echo "... $image added" | |
imagenames_latest+=$image":" | |
fi | |
done | |
echo "image names with tag latest: $imagenames_latest" | |
imagenames_latest=$(echo $imagenames_latest | jq -R -c 'split(":")[:-1]') | |
echo "image names with tag latest: $imagenames_latest" | |
echo "imagenames=$imagenames_latest" >> $GITHUB_OUTPUT | |
- name: Dockerfile Overview | |
run: | | |
echo "Final list of images with tag latest: ${{ steps.set-matrix.outputs.imagenames }}" | |
test: | |
name: Run Tests and Coverage Report | |
needs: get_dockerfiles | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
contents: write | |
strategy: | |
fail-fast: false | |
matrix: | |
imagename: ${{ fromJson(needs.get_dockerfiles.outputs.imagenames) }} | |
container: | |
image: ghcr.io/ptb-mr/${{ matrix.imagename }}:latest | |
options: --user runner | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Install MRpro and Dependencies | |
run: pip install --upgrade --upgrade-strategy eager .[test] | |
- name: Install PyTest GitHub Annotation Plugin | |
run: pip install pytest-github-actions-annotate-failures | |
- name: Run PyTest and Generate Coverage Report | |
run: | | |
pytest -n 4 -m "not cuda" --junitxml=pytest.xml \ | |
--cov-report=term-missing:skip-covered --cov=mrpro | tee pytest-coverage.txt | |
- name: Verify PyTest XML Output | |
run: | | |
if [ ! -f pytest.xml ]; then | |
echo "PyTest XML report not found. Please check the previous 'Run PyTest' step for errors." | |
exit 1 | |
fi | |
- name: Post PyTest Coverage Comment | |
id: coverageComment | |
uses: MishaKav/[email protected] | |
with: | |
pytest-coverage-path: ./pytest-coverage.txt | |
junitxml-path: ./pytest.xml | |
- name: Create Coverage Badge on Main Branch Push | |
uses: schneegans/[email protected] | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
with: | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: 48e334a10caf60e6708d7c712e56d241 | |
filename: coverage.json | |
label: Coverage Report | |
message: ${{ steps.coverageComment.outputs.coverage }} | |
color: ${{ steps.coverageComment.outputs.color }} | |
namedLogo: python | |
- name: Set Pipeline Status Based on Test Results | |
if: steps.coverageComment.outputs.errors != 0 || steps.coverageComment.outputs.failures != 0 | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
core.setFailed("PyTest workflow failed with ${{ steps.coverageComment.outputs.errors }} errors and ${{ steps.coverageComment.outputs.failures }} failures.") | |
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 |