Skip to content

Merge pull request #2283 from mccode-dev/mcxtrace-temp-disable-test #455

Merge pull request #2283 from mccode-dev/mcxtrace-temp-disable-test

Merge pull request #2283 from mccode-dev/mcxtrace-temp-disable-test #455

name: mcstas-conda-basictest
on:
push:
pull_request:
schedule:
- cron: '30 23 * * 0' # 23:30 every Sunday
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
fetch-depth: 2
- 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
# Start of tests
- name: Launch RNG test instrument
id: RNG-test
run: |
set -e
set -u
set -x
export MD5SUM="md5sum"
if [ "$RUNNER_OS" == "macOS" ];
then
export MD5SUM="md5"
fi
if [ "$RUNNER_OS" == "Windows" ];
then
export SUFFIX=".bat"
else
export SUFFIX=""
fi
test -f ${CONDA_PREFIX}/bin/mcstas
mcstas --version
mctest${SUFFIX} --instr=Test_RNG_rand01 --testdir=run_singletests --suffix=${{ matrix.mpi }}
export SUM=`find run_singletests -name rngout.dat | xargs -n1 grep -v \# | ${MD5SUM} | cut -f1 -d\ `
export EXPECTED="f192ce4609e2225bf9d42ce9c5fa5a86"
if [ "${EXPECTED}" == "${SUM}" ];
then
echo RNG test success!
true
else
echo RNG test failure!
false
fi
- name: Launch BNL_H8 instrument
id: h8-test
run: |
set -e
set -u
set -x
if [ "$RUNNER_OS" == "Windows" ];
then
export SUFFIX=".bat"
else
export SUFFIX=""
fi
test -f ${CONDA_PREFIX}/bin/mcstas
mcstas --version
mctest${SUFFIX} --instr=BNL_H8 --testdir=run_singletests --suffix=${{ matrix.mpi }}
mctest${SUFFIX} --instr=BNL_H8 --mpi=2 --testdir=run_singletests --suffix=${{ matrix.mpi }}
- name: Launch ISIS_CRISP
id: ISIS_CRISP
run: |
set -e
set -u
set -x
if [ "$RUNNER_OS" == "Windows" ];
then
export SUFFIX=".bat"
else
export SUFFIX=""
fi
test -f ${CONDA_PREFIX}/bin/mcstas
mcstas --version
mctest${SUFFIX} --instr=ISIS_CRISP --testdir=run_singletests --suffix=${{ matrix.mpi }}
mctest${SUFFIX} --instr=ISIS_CRISP --mpi=2 --testdir=run_singletests --suffix=${{ matrix.mpi }}
- name: Launch MCPL test instrument
id: mcpl-test
run: |
set -e
set -u
set -x
if [ "$RUNNER_OS" == "Windows" ];
then
export SUFFIX=".bat"
else
export SUFFIX=""
fi
test -f ${CONDA_PREFIX}/bin/mcstas
mcstas --version
mctest${SUFFIX} --instr=ESS_BEER_MCPL --testdir=run_singletests --suffix=${{ matrix.mpi }}
mctest${SUFFIX} --instr=ESS_BEER_MCPL --mpi=2 --testdir=run_singletests --suffix=${{ matrix.mpi }}
mctest${SUFFIX} --instr=Test_MCPL_input --testdir=run_singletests --suffix=${{ matrix.mpi }}
mctest${SUFFIX} --instr=Test_MCPL_output --testdir=run_singletests --suffix=${{ matrix.mpi }}
mctest${SUFFIX} --instr=Test_MCPL_input --mpi=2 --testdir=run_singletests --suffix=${{ matrix.mpi }}
mctest${SUFFIX} --instr=Test_MCPL_output --mpi=2 --testdir=run_singletests --suffix=${{ matrix.mpi }}
- name: Launch NCrystal test instrument
id: ncrystal-test
run: |
set -e
set -u
set -x
if [ "$RUNNER_OS" == "Windows" ];
then
export SUFFIX=".bat"
else
export SUFFIX=""
fi
test -f ${CONDA_PREFIX}/bin/mcstas
mcstas --version
mctest${SUFFIX} --instr=NCrystal_example --testdir=run_singletests --suffix=${{ matrix.mpi }}
mctest${SUFFIX} --instr=NCrystal_example --mpi=2 --testdir=run_singletests --suffix=${{ matrix.mpi }}
- name: Launch NeXus test instrument
id: nexus-test
run: |
set -e
set -u
set -x
if [ "$RUNNER_OS" == "Windows" ];
then
export SUFFIX=".bat"
else
export SUFFIX=""
fi
test -f ${CONDA_PREFIX}/bin/mcstas
mcstas --version
mctest${SUFFIX} --instr=templateSANS_Mantid --testdir=run_singletests --suffix=${{ matrix.mpi }}
mctest${SUFFIX} --instr=templateSANS_Mantid --mpi=2 --testdir=run_singletests --suffix=${{ matrix.mpi }}
- name: Check for modified instruments
id: instr-test
run: |
set -e
set -u
set -x
export MCSTAS_EXECUTABLE="mcstas"
export MCRUN_EXECUTABLE="mcrun"
export MCTEST_EXECUTABLE="mctest"
export PERMISSIVE=" "
export PATH=${PATH}:${PWD}/install_mcstas/bin/:${PWD}/install_mcstas/mcstas/3.99.99/bin/
# Check if any instr files were modified during last commit
cd src
export CHANGEDCOMPS=`git diff --name-only HEAD HEAD~1| grep \.comp\$ | grep mcstas-comps | xargs -n1 basename | sed s/\.comp//g | xargs echo`
export NUMCHANGEDCOMPS=`git diff --name-only HEAD HEAD~1|grep \.comp\$ | grep mcstas-comps | wc -l | xargs echo`
cd -
if [ "$NUMCHANGEDCOMPS" != "0" ];
then
for comp in $CHANGEDCOMPS;
do
echo Finding tests including component $comp
NUMMATCH=`find src/mcstas-comps -name \*.instr -exec grep -H ${comp} \{\} \; | cut -f1 -d: | sort | uniq | wc -l`
if [ "$NUMMATCH" -gt "0" ];
then
if [ "$RUNNER_OS" != "Windows" ]; then
mctest --mpi=2 --testdir run_${comp} --comp=${comp} --suffix=CHANGES_${{ matrix.mpi }} $PERMISSIVE --verbose
else
mctest.bat --mpi=2 --testdir run_${comp} --comp=${comp} --suffix=CHANGES_${{ matrix.mpi }} $PERMISSIVE --verbose
fi
else
echo No matching tests found
fi
done
fi
cd src
export RUNALL="NO"
export CHANGEDINSTR=`git diff --name-only HEAD HEAD~1| grep \.instr\$ | grep mcstas-comps | xargs -n1 basename | sed s/\.instr//g | xargs echo`
export CHANGEDINSTR=`echo $CHANGEDINSTR | xargs -n1 echo | sort | uniq | xargs echo | sed s/\ /,/g`
export NUMCHANGEDINSTR=`git diff --name-only HEAD HEAD~1|grep \.instr\$ | grep mcstas-comps | wc -l | xargs echo`
echo ----
echo $NUMCHANGEDCOMPS components and $NUMCHANGEDINSTR instruments were changed, resulting in this list:
echo $CHANGEDINSTR
echo ----
cd -
if [ "$NUMCHANGEDINSTR" -gt "20" ];
then
export RUNALL="YES"
fi
if [ "$NUMCHANGEDINSTR" != "0" ];
then
if [ "$RUNALL" == "NO" ];
then
export SCOPE="--instr=$CHANGEDINSTR"
else
export SCOPE=" "
fi
mkdir run_mctest && cd run_mctest
if [ "$RUNNER_OS" != "Windows" ]; then
mctest --mpi=2 --testdir $PWD $SCOPE --suffix=CHANGES_${{ matrix.mpi }} $PERMISSIVE
mcviewtest --nobrowse $PWD
else
mctest.bat --mpi=2 --testdir $PWD $SCOPE --suffix=CHANGES_${{ matrix.mpi }} $PERMISSIVE
mcviewtest.bat --nobrowse $PWD
fi
fi
- 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_*
- 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