Skip to content

mcstas-conda-testsuite #99

mcstas-conda-testsuite

mcstas-conda-testsuite #99

name: mcstas-conda-testsuite
on:
schedule:
- cron: '00 02 * * *' # 02:00 every day
workflow_dispatch:
inputs:
manual-debugging:
type: boolean
description: Launch manual debugging tmate for inspection (automatic in case of errors)
default: false
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, python: '3.12', mpi: 'openmpi' }
- { os: ubuntu-latest, python: '3.12', mpi: 'mpich' }
- { os: macos-latest, python: '3.12', mpi: 'openmpi' }
- { os: macos-latest, python: '3.12', mpi: 'mpich' }
- { os: windows-latest, python: '3.12', mpi: 'msmpi' }
name: ${{ matrix.os }}.${{ matrix.mpi }}.python-${{ matrix.python }}
runs-on: ${{ matrix.os }}
env:
CC: ${{ matrix.CC }}
CXX: ${{ matrix.CXX }}
defaults:
run:
shell: bash -el {0}
steps:
- name: Checkout
uses: actions/checkout@v5
with:
path: src
- name: Setup VS in shell Intel
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
- uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: mcstas
auto-update-conda: true
conda-remove-defaults: true
channels: conda-forge
python-version: ${{ matrix.python }}
- name: Setup conda
id: setup-conda
run: |
./src/devel/bin/mccode-create-conda-yml -m mcstas -n mcstas -o dependencies.yml
conda env update --file dependencies.yml
echo DONE
- name: Check versions
id: version-checks
run: |
which python3
python3 --version
which cmake
cmake --version
if [ "$RUNNER_OS" != "Windows" ];
then
echo C compiler: $CC
$CC --version
else
echo C compiler: cl.exe
cl.exe
fi
- name: Configure build and install mcstas
id: mcstas-install
run: |
./src/devel/bin/mccode-build-conda -m mcstas -s $PWD/src -b $PWD/build_mcstas
- name: Post install openmpi hacks macOS
id: post-install-openmpi-hacks-macOS
if: runner.os == 'macOS'
run: |
if [ "${{ matrix.mpi }}" == "openmpi" ]; then
sed -i.bak 's+mpirun+mpirun\ -mca\ regx\ naive\ --verbose\ --mca\ btl_tcp_if_include\ lo0+g' ${CONDA_PREFIX}/share/mcstas/tools/Python/mccodelib/mccode_config.json
fi
- name: Test suite, up to 2-core MPI
id: test-suite
run: |
# Create and cd to directory for test output data
mkdir run_test-suite && cd run_test-suite
# Test script name
export MCTEST_EXECUTABLE="mctest"
if [ "$RUNNER_OS" == "Windows" ];
then
export MCTEST_EXECUTABLE="mctest.bat"
fi
# Workaround for warning about "too long" tmpdir name on macOS/openmpi
if [ "$RUNNER_OS" == "macOS" ];
then
mkdir ${HOME}/tmp
export TMPDIR=${HOME}/tmp
fi
# Run the test with 2 core mpi
${MCTEST_EXECUTABLE} --verbose --testdir $PWD --suffix ${{ matrix.os }}_${{ matrix.mpi }} --mpi=2
- name: 'Tar output files'
id: tar-package
if: always()
run: |
set -e
set -u
set -x
# Clear out binaries from sim dir and tar up artifact
ls | grep run_ | xargs -n1 ./src/devel/bin/mccode-simdir-cleanfiles -d
tar cvfz mcstas-${{ matrix.os }}.${{ matrix.mpi }}.python-${{ matrix.python }}_output.tgz run_test-suite
- name: 'Upload Artifact'
id: tar-upload
uses: actions/upload-artifact@v4
if: always()
with:
name: mcstas-artefacts-${{ matrix.os }}.${{ matrix.mpi }}.python-${{ matrix.python }}
path: "mcstas-${{ matrix.os }}.${{ matrix.mpi }}.python-${{ matrix.python }}_output.tgz"
- name: Setup tmate session for manual debugging
uses: mxschmitt/action-tmate@v3
if: always() && (inputs.manual-debugging == true)
with:
limit-access-to-actor: true