Skip to content

Update Github CI

Update Github CI #4017

Workflow file for this run

name: CI
on:
push:
paths-ignore:
- 'docs/**'
branches: [ master ]
tags:
- '*'
pull_request:
paths-ignore:
- 'docs/**'
branches: [ master ]
schedule:
- cron: '0 0 * * 0,3'
workflow_dispatch:
concurrency:
group: ${{ github.ref }}-ci
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
build_opengate_wheel:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04]
python-version: ['3.10']
steps:
- name: Checkout github repo
uses: actions/checkout@v4
- name: Checkout submodules
shell: bash -l {0}
run: |
export GIT_SSL_NO_VERIFY=1
git submodule update --init --recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'
- name: Create opengate Wheel
run: |
rm -rf $GITHUB_WORKSPACE/opengate/tests/data
cp $GITHUB_WORKSPACE/.git/modules/gam-tests/data/HEAD $GITHUB_WORKSPACE/opengate/tests/
pip install build
python -m build
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: dist-opengate
path: dist/
build_opengate_core_wheel_pr:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, macos-15, windows-2025]
python-version: ['3.10', '3.11', '3.12', '3.13']
exclude:
- os: macos-15
python-version: '3.10'
env:
GEANT4_VERSION: 'v11.3.2'
ITK_VERSION: 'v5.4.4'
steps:
- name: Checkout github repo
uses: actions/checkout@v4
- name: Checkout submodules
shell: bash -l {0}
run: |
if [[ ${{ matrix.os }} == "windows-2025" ]]; then
set "GIT_SSL_NO_VERIFY=1"
else
export GIT_SSL_NO_VERIFY=1
fi
git submodule update --init --recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Get OS version
id: get-os-version
shell: bash -l {0}
run: |
if [[ ${{ matrix.os }} == "ubuntu-24.04" ]] || [[ ${{ matrix.os }} == "ubuntu-24.04-arm" ]]; then
varOS=`cat /etc/os-release | grep "VERSION=" | grep -oP '(?<=\").*?(?=\")'`
varOS=($varOS)
varOS=${varOS[0]}
if [[ ${{ matrix.os }} == "ubuntu-24.04" ]]; then
varOS="${varOS}-intel"
else
varOS="${varOS}-arm"
fi
echo "release=${varOS}" >> $GITHUB_OUTPUT
elif [[ ${{ matrix.os }} == "macos-15" ]] || [[ ${{ matrix.os }} == "macos-15-intel" ]]; then
varOS=$(sw_vers -productVersion)
if [[ ${{ matrix.os }} == "macos-15" ]]; then
varOS="${varOS}-m1"
else
varOS="${varOS}-intel"
fi
echo "release=${varOS}" >> $GITHUB_OUTPUT
else
varOS=`windows`
echo "release=${varOS}" >> $GITHUB_OUTPUT
fi
- name: Cache modules
id: cache_opengate_core_dependencies
uses: actions/cache@v4
with:
path: ~/software
key: ${{ runner.os }}-${{ steps.get-os-version.outputs.release }}_geant4_${{ env.GEANT4_VERSION }}_itk_${{ env.ITK_VERSION }}_build
restore-keys: ${{ runner.os }}-${{ steps.get-os-version.outputs.release }}_geant4_${{ env.GEANT4_VERSION }}_itk_${{ env.ITK_VERSION }}_build
- name: Create opengate_core Wheel Linux
if: (matrix.os == 'ubuntu-24.04') || (matrix.os == 'ubuntu-24.04-arm')
run: |
bash /home/.github/workflows/ci_ubuntu.sh
- uses: conda-incubator/setup-miniconda@v3
if: (matrix.os == 'macos-15') || (matrix.os == 'macos-15-intel') || (matrix.os == 'windows-2025')
with:
miniconda-version: "latest"
auto-update-conda: true
activate-environment: opengate_core
python-version: ${{ matrix.python-version }}
- name: Set up Homebrew
if: (matrix.os == 'macos-15') || (matrix.os == 'macos-15-intel')
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Create opengate_core Wheel Mac
if: (matrix.os == 'macos-15') || (matrix.os == 'macos-15-intel')
shell: bash -l {0}
run: |
bash /home/.github/workflows/ci_macos.sh
- name: Create opengate_core Wheel Windows
if: matrix.os == 'windows-2025'
shell: bash -l {0}
run: |
bash /home/.github/workflows/ci_windows.sh
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.os }}-${{ matrix.python-version }}-opengate-core
path: dist/
build_opengate_core_wheel_ci_or_tag:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm, macos-15-intel, macos-15, windows-2025, windows-11-arm]
python-version: ['3.10', '3.11', '3.12', '3.13']
exclude:
- os: macos-15
python-version: '3.10'
env:
GEANT4_VERSION: 'v11.3.2'
ITK_VERSION: 'v5.4.4'
steps:
- name: Checkout github repo
uses: actions/checkout@v4
- name: Checkout submodules
shell: bash -l {0}
run: |
if [[ ${{ matrix.os }} == "windows-2025" ]]; then
set "GIT_SSL_NO_VERIFY=1"
else
export GIT_SSL_NO_VERIFY=1
fi
git submodule update --init --recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Get OS version
id: get-os-version
shell: bash -l {0}
run: |
if [[ ${{ matrix.os }} == "ubuntu-24.04" ]] || [[ ${{ matrix.os }} == "ubuntu-24.04-arm" ]]; then
varOS=`cat /etc/os-release | grep "VERSION=" | grep -oP '(?<=\").*?(?=\")'`
varOS=($varOS)
varOS=${varOS[0]}
if [[ ${{ matrix.os }} == "ubuntu-24.04" ]]; then
varOS="${varOS}-intel"
else
varOS="${varOS}-arm"
fi
echo "release=${varOS}" >> $GITHUB_OUTPUT
elif [[ ${{ matrix.os }} == "macos-15" ]] || [[ ${{ matrix.os }} == "macos-15-intel" ]]; then
varOS=$(sw_vers -productVersion)
if [[ ${{ matrix.os }} == "macos-15" ]]; then
varOS="${varOS}-m1"
else
varOS="${varOS}-intel"
fi
echo "release=${varOS}" >> $GITHUB_OUTPUT
else
varOS=`windows`
echo "release=${varOS}" >> $GITHUB_OUTPUT
fi
- name: Cache modules
id: cache_opengate_core_dependencies
uses: actions/cache@v4
with:
path: ~/software
key: ${{ runner.os }}-${{ steps.get-os-version.outputs.release }}_geant4_${{ env.GEANT4_VERSION }}_itk_${{ env.ITK_VERSION }}_build
restore-keys: ${{ runner.os }}-${{ steps.get-os-version.outputs.release }}_geant4_${{ env.GEANT4_VERSION }}_itk_${{ env.ITK_VERSION }}_build
- name: Create opengate_core Wheel Linux
if: (matrix.os == 'ubuntu-24.04') || (matrix.os == 'ubuntu-24.04-arm')
run: |
bash /home/.github/workflows/ci_ubuntu.sh
- uses: conda-incubator/setup-miniconda@v3
if: (matrix.os == 'macos-15') || (matrix.os == 'macos-15-intel') || (matrix.os == 'windows-2025')
with:
miniconda-version: "latest"
auto-update-conda: true
activate-environment: opengate_core
python-version: ${{ matrix.python-version }}
- name: Set up Homebrew
if: (matrix.os == 'macos-15') || (matrix.os == 'macos-15-intel')
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Create opengate_core Wheel Mac
if: (matrix.os == 'macos-15') || (matrix.os == 'macos-15-intel')
shell: bash -l {0}
run: |
bash /home/.github/workflows/ci_macos.sh
- name: Create opengate_core Wheel Windows
if: matrix.os == 'windows-2025'
shell: bash -l {0}
run: |
bash /home/.github/workflows/ci_windows.sh
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.os }}-${{ matrix.python-version }}-opengate-core
path: dist/
build_opengate_core_novis_wheel:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04]
python-version: ['3.10', '3.11', '3.12', '3.13']
env:
GEANT4_VERSION: 'v11.3.2'
ITK_VERSION: 'v5.4.4'
steps:
- name: Checkout github repo
uses: actions/checkout@v4
- name: Checkout submodules
shell: bash -l {0}
run: |
export GIT_SSL_NO_VERIFY=1
git submodule update --init --recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'
- name: Get OS version
id: get-os-version
shell: bash -l {0}
run: |
varOS=`cat /etc/os-release | grep "VERSION=" | grep -oP '(?<=\").*?(?=\")'`
varOS=($varOS)
varOS=${varOS[0]}
varOS="${varOS}-intel"
echo "release=${varOS}" >> $GITHUB_OUTPUT
- name: Cache modules
id: cache_opengate_core_dependencies
uses: actions/cache@v4
with:
path: ~/software
key: ${{ runner.os }}-${{ steps.get-os-version.outputs.release }}_geant4_${{ env.GEANT4_VERSION }}_itk_${{ env.ITK_VERSION }}_build
restore-keys: ${{ runner.os }}-${{ steps.get-os-version.outputs.release }}_geant4_${{ env.GEANT4_VERSION }}_itk_${{ env.ITK_VERSION }}_build
- name: Create opengate_core_novis Wheel Linux
run: |
if [ ${{ matrix.python-version }} == "3.10" ]; then
export PYTHONFOLDER="cp310-cp310"
elif [ ${{ matrix.python-version }} == "3.11" ]; then
export PYTHONFOLDER="cp311-cp311"
elif [ ${{ matrix.python-version }} == "3.12" ]; then
export PYTHONFOLDER="cp312-cp312"
elif [ ${{ matrix.python-version }} == "3.13" ]; then
export PYTHONFOLDER="cp313-cp313"
fi
mkdir -p $HOME/software
docker run --rm -e "PYTHONFOLDER=${PYTHONFOLDER}" -v $GITHUB_WORKSPACE:/home tbaudier/opengate_core:${{ env.GEANT4_VERSION }}_novis /home/.github/workflows/createWheelLinux_novis.sh
ls wheelhouse
rm -rf dist
mv wheelhouse dist
sudo chown -R runner:docker dist
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.os }}-${{ matrix.python-version }}-opengate-core-novis
path: dist/
publish_wheel:
runs-on: ubuntu-24.04
needs: [build_opengate_wheel, build_opengate_core_wheel_pr, build_opengate_core_wheel_ci_or_tag, build_opengate_core_novis_wheel]
steps:
- name: Checkout github repo
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: dist-*
merge-multiple: true
path: dist/
- name: Separate the wheels
run: |
mkdir dist_opengate_core dist_opengate dist_opengate_core_novis
mv dist/opengate_core_novis-* dist_opengate_core_novis/ || true
mv dist/opengate_core-* dist_opengate_core/
mv dist/opengate-* dist_opengate/
- name: Publish to PyPI opengate_core_novis
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_OPENGATE_CORE_NOVIS }}
packages_dir: dist_opengate_core_novis/
skip_existing: true
- name: Publish to PyPI opengate_core
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_OPENGATE_CORE }}
packages_dir: dist_opengate_core/
skip_existing: true
- name: Publish to PyPI opengate
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_OPENGATE }}
packages_dir: dist_opengate/
skip_existing: true
# ssh_session:
# env:
# GEANT4_VERSION: 'v11.3.2'
# ITK_VERSION: 'v5.4.4'
# runs-on: macos-13
# steps:
# - name: Checkout github repo
# uses: actions/checkout@v4
# - name: Checkout submodules
# shell: bash -l {0}
# run: |
# export GIT_SSL_NO_VERIFY=1
# git submodule update --init --recursive
# - name: Set up Python
# uses: actions/setup-python@v5
# with:
# python-version: 3.9
# architecture: 'x64'
# - name: Get OS version
# id: get-os-version
# shell: bash -l {0}
# run: |
# varOS=`sw_vers | grep "ProductVersion:"`
# varOS="${varOS#*:}"
# echo "release=${varOS:1}" >> $GITHUB_OUTPUT
# - name: Cache modules
# id: cache_opengate_core_dependencies
# uses: actions/cache@v4
# with:
# path: ~/software
# key: ${{ runner.os }}-${{ steps.get-os-version.outputs.release }}_geant4_${{ env.GEANT4_VERSION }}_itk_${{ env.ITK_VERSION }}_build
# restore-keys: ${{ runner.os }}-${{ steps.get-os-version.outputs.release }}_geant4_${{ env.GEANT4_VERSION }}_itk_${{ env.ITK_VERSION }}_build
# - uses: conda-incubator/setup-miniconda@v3
# with:
# miniconda-version: "latest"
# auto-update-conda: true
# activate-environment: opengate_core
# python-version: 3.9
# - name: Set up Homebrew
# id: set-up-homebrew
# uses: Homebrew/actions/setup-homebrew@master
# - name: Start SSH session
# uses: luchihoratiu/debug-via-ssh@main
# with:
# NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }}
# SSH_PASS: ${{ secrets.SSH_PASS }}
test_wheel:
runs-on: ${{ matrix.os }}
needs: [build_opengate_wheel, build_opengate_core_wheel_pr]
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, macos-15, windows-2025]
python-version: ['3.10', '3.11', '3.12', '3.13']
exclude:
- os: macos-15
python-version: '3.10'
steps:
- uses: actions/download-artifact@v4
with:
pattern: dist-*
merge-multiple: true
path: dist/
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Run tests
shell: bash {0}
run: |
if [[ ${{ matrix.python-version }} == "3.10" ]]; then
export PYTHONFOLDER="cp310-cp310"
elif [[ ${{ matrix.python-version }} == "3.11" ]]; then
export PYTHONFOLDER="cp311-cp311"
elif [[ ${{ matrix.python-version }} == "3.12" ]]; then
export PYTHONFOLDER="cp312-cp312"
elif [[ ${{ matrix.python-version }} == "3.13" ]]; then
export PYTHONFOLDER="cp313-cp313"
fi
if [[ ${{ matrix.os }} == "ubuntu-24.04" ]]; then
export OSNAME="manylinux"
export PLATFORM="x86_"
pip install torch --extra-index-url https://download.pytorch.org/whl/cpu
elif [[ ${{ matrix.os }} == "macos-15" ]]; then
export OSNAME="macosx"
export PLATFORM="arm"
which python
python --version
pip install torch
elif [[ ${{ matrix.os }} == "windows-2025" ]]; then
export OSNAME="win"
export PLATFORM="amd"
pip install torch
fi
pip install SimpleITK
pip install "gaga_phsp>=0.7.6"
pip install dist/opengate_core-*-${PYTHONFOLDER}-${OSNAME}*_${PLATFORM}64.whl
pip install dist/opengate-*.whl
export GIT_SSL_NO_VERIFY=1
if [[ ${{ matrix.os }} == "ubuntu-24.04" ]]; then
path=`opengate_library_path.py -p site_packages`
export LD_LIBRARY_PATH="${path}/opengate_core.libs":${LD_LIBRARY_PATH}
fi
if [[ ${{ matrix.os }} == "windows-2025" ]]; then
path=`opengate_library_path.py -p site_packages`
export LD_LIBRARY_PATH="${path}/opengate_core.libs":${LD_LIBRARY_PATH}
export PATH="${path}\\opengate_core.libs":${PATH}
fi
dashboard_path=`opengate_library_path.py -p tests`
pip freeze
sha=${{ github.sha }}
sha=$sha$OSNAME$PYTHONFOLDER
if [ "${{ github.event_name }}" = "schedule" ]; then
OutputTest=$(opengate_tests)
else
OutputTest=$(opengate_tests -r -s $sha)
fi
echo "$OutputTest"
ls $dashboard_path/../output_dashboard/
cp -r $dashboard_path/../output_dashboard .
OutputTest=$(echo "$OutputTest" | tail -1)
if [[ "$OutputTest" != "True" ]]; then
exit -1
else
exit 0
fi
- name: Upload results
uses: actions/upload-artifact@v4
if: always()
with:
name: results_json-${{ matrix.os }}-${{ matrix.python-version }}
path: output_dashboard/dashboard_output*.json
publish_test:
runs-on: ubuntu-24.04
if: ${{ (always()) && (github.ref == 'refs/heads/master') }}
needs: [test_wheel]
steps:
- name: Checkout github repo
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: results_json-*
merge-multiple: true
path: ./
- uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
auto-update-conda: true
activate-environment: vega-altair
python-version: '3.10'
- name: Merge the results
shell: bash -el {0}
run: |
git clone https://github.com/OpenGATE/opengate_tests_results.git
cd opengate_tests_results
echo $pwd
ls ..
cp ../dashboard_output_*.json .
conda install -c conda-forge altair-all
pip install pandas numpy
python compile_opengate_tests_results.py
- name: Pushes to another repository
continue-on-error: true
uses: cpina/github-action-push-to-another-repository@main
env:
API_TOKEN_GITHUB: ${{ secrets.PUSH_OPENGATE_TESTS_RESULTS }}
with:
source-directory: 'opengate_tests_results'
destination-github-username: 'OpenGATE'
destination-repository-name: 'opengate_tests_results'
user-email: [email protected]
target-branch: master