Merge pull request #2280 from mccode-dev/fix-issue-2279 #3450
This file contains hidden or 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: mcstas-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-24.04, CC: gcc-13, CXX: g++-13, python: '3.12', mpi: 'openmpi' } | |
| - { os: ubuntu-24.04, CC: clang, CXX: clang++, python: '3.12', mpi: 'openmpi' } | |
| - { os: windows-11-arm, CC: cl.exe, CXX: cl.exe, python: "3.13", mpi: 'msmpi' } | |
| - { os: windows-latest, CC: gcc.exe, CXX: g++.exe, python: "3.13", mpi: 'msmpi' } | |
| name: ${{ matrix.os }}.${{ matrix.CC }}.${{ 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 python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| - name: Setup VS in shell Intel | |
| if: runner.os == 'Windows' && matrix.os != 'windows-11-arm' | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| - name: Setup VS in shell arm64 | |
| if: runner.os == 'Windows' && matrix.os == 'windows-11-arm' | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| with: | |
| arch: arm64 | |
| - name: Setup MPI | |
| uses: mpi4py/setup-mpi@v1 | |
| with: | |
| mpi: ${{ matrix.mpi }} | |
| - name: Setup (Linux) | |
| id: setup-linux | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt -y install libgsl-dev | |
| - name: Setup (macOS) | |
| id: setup-macos | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew install bison flex gfortran gsl | |
| - name: Setup (Windows) | |
| id: setup-Windows | |
| if: runner.os == 'Windows' | |
| shell: bash | |
| run: | | |
| cygpath -sm "$MSMPI_INC" > includepath.txt | |
| cygpath -sm "$MSMPI_LIB64" > libpath.txt | |
| choco install winflexbison3 | |
| choco install wget | |
| if [ "$CC" == "gcc.exe" ]; then choco install mingw; fi | |
| pip install mslex PyYAML ply ncrystal mcpl mcpl-extra | |
| - name: Setup (Windows Intel) | |
| id: setup-Windows-intel | |
| if: runner.os == 'Windows' && matrix.os !='windows-11-arm' | |
| shell: bash | |
| run: | | |
| pip install McStasscript ncrystal | |
| - name: Setup MPI cygpath... | |
| id: setup-Windows-paths | |
| if: runner.os == 'Windows' | |
| run: | | |
| set /p MPIINCVAR=<includepath.txt | |
| set /p MPILIBVAR=<libpath.txt | |
| echo MPIINCVAR=%MPIINCVAR% >> %GITHUB_ENV% | |
| echo MPILIBVAR=%MPILIBVAR% >> %GITHUB_ENV% | |
| - name: Check versions | |
| id: version-checks | |
| run: | | |
| which python3 | |
| python3 --version | |
| which cmake | |
| cmake --version | |
| - name: Configure build and install mcstas on Unix | |
| id: mcstas-install-unix | |
| if: runner.os != 'Windows' | |
| run: | | |
| if [ "$RUNNER_OS" == "macOS" ]; then mkdir ${HOME}/tmp; fi | |
| if [ "$RUNNER_OS" == "macOS" ]; then export SDKROOT=$(xcrun --sdk macosx --show-sdk-path); fi | |
| set -e | |
| set -u | |
| set -x | |
| mkdir build_mcstas | |
| cd build_mcstas | |
| export EXTRA_ARGS_FOR_CMAKE="" | |
| if [ "$RUNNER_OS" == "macOS" ] && [ -f "/opt/homebrew/opt/flex/bin/flex" ]; then export HOMEBRW="/opt/homebrew/opt"; export GSLFLAGS="-lgsl -lgslcblas -L/opt/homebrew/lib -I/opt/homebrew/include"; fi | |
| if [ "$RUNNER_OS" == "macOS" ] && [ -f "/usr/local/opt/flex/bin/flex" ]; then export HOMEBRW="/usr/local/opt"; export GSLFLAGS="-lgsl -lgslcblas -L/usr/local/lib -I/usr/local/include"; fi | |
| if [ "$RUNNER_OS" == "macOS" ]; then export EXTRA_ARGS_FOR_CMAKE="-DBISON_EXECUTABLE=${HOMEBRW}/bison/bin/bison -DFLEX_EXECUTABLE=${HOMEBRW}/flex/bin/flex -DCMAKE_Fortran_COMPILER=${HOMEBRW}/gfortran/bin/gfortran"; fi | |
| if [ "$RUNNER_OS" == "Linux" ]; then export EXTRA_ARGS_FOR_CMAKE="-DNEXUSLIB=/usr/lib -DNEXUSINCLUDE=/usr/include/nexus"; fi | |
| if [ "$RUNNER_OS" == "Windows" ]; then export MPIINC=`cygpath -m -s "${MSMPI_INC}"`; export MPILIB=`cygpath -m -s "${MSMPI_LIB64}"`; export EXTRA_ARGS_FOR_CMAKE="-DMPILIBDIR=${MPILIB} -DMPIINCLUDEDIR=${MPIINC}"; fi | |
| cmake \ | |
| -DCMAKE_INSTALL_PREFIX=../install_mcstas \ | |
| -S ../src \ | |
| -G "Unix Makefiles" \ | |
| -DMCVERSION="3.99.99" \ | |
| -DMCCODE_BUILD_CONDA_PKG=OFF \ | |
| -DBUILD_SHARED_LIBS=ON \ | |
| -DCMAKE_INSTALL_LIBDIR=lib \ | |
| -DCMAKE_BUILD_TYPE=Release \ | |
| -DBUILD_MCSTAS=ON \ | |
| -DMCCODE_USE_LEGACY_DESTINATIONS=OFF \ | |
| -DBUILD_TOOLS=ON \ | |
| -DENABLE_COMPONENTS=ON \ | |
| -DENSURE_MCPL=OFF \ | |
| -DENSURE_NCRYSTAL=OFF \ | |
| -DENABLE_CIF2HKL=ON \ | |
| -DENABLE_NEUTRONICS=OFF \ | |
| ${EXTRA_ARGS_FOR_CMAKE} | |
| cmake --build . --config Release | |
| cmake --build . --target install --config Release | |
| export MCSTAS_EXECUTABLE="mcstas" | |
| export MCRUN_EXECUTABLE="mcrun" | |
| if [ "$RUNNER_OS" == "Windows" ]; | |
| then | |
| export MCSTAS_EXECUTABLE="mcstas.exe" | |
| export MCRUN_EXECUTABLE="mcrun.bat" | |
| fi | |
| test -f "../install_mcstas/bin/${MCSTAS_EXECUTABLE}" | |
| test -f "../install_mcstas/bin/${MCRUN_EXECUTABLE}" | |
| test -f "../install_mcstas/share/mcstas/tools/Python/mccodelib/__init__.py" | |
| test -d "../install_mcstas/share/mcstas/resources/data" | |
| if [ "${{ matrix.mpi }}" == "openmpi" ]; then sed -i.bak 's/mpirun/mpirun\ --verbose\ --mca\ btl\ self,vader,tcp/g' ../install_mcstas/share/mcstas/tools/Python/mccodelib/mccode_config.json ; fi | |
| if [ "$RUNNER_OS" == "macOS" ]; then sed -i.bak "s+-lgsl\ -lgslcblas+${GSLFLAGS}+g" ../install_mcstas/share/mcstas/tools/Python/mccodelib/mccode_config.json ; fi | |
| echo ******************************************************************************* | |
| echo Resulting mccode_config.json: | |
| echo ******************************************************************************* | |
| cat ../install_mcstas/share/mcstas/tools/Python/mccodelib/mccode_config.json | |
| echo ******************************************************************************* | |
| - name: Configure build and install mcstas on Windows-Mingw | |
| id: mcstas-install-windows-mingw | |
| if: ${{ matrix.CC == 'gcc.exe' && runner.os == 'Windows' }} | |
| run: > | |
| cmake -B build -S src | |
| -G "Unix Makefiles" | |
| -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc.exe | |
| "-DCMAKE_INSTALL_PREFIX=./install" | |
| -DMCVERSION="3.99.99" | |
| -DMCCODE_BUILD_CONDA_PKG=OFF | |
| -DMCCODE_BUILD_WINDOWS_MINGW=ON | |
| -DMCCODE_CONFIG_MCPL2=ON | |
| -DCMAKE_INSTALL_LIBDIR=lib | |
| -DBUILD_MCSTAS=ON | |
| -DMCCODE_USE_LEGACY_DESTINATIONS=OFF | |
| -DBUILD_TOOLS=ON | |
| -DENABLE_COMPONENTS=ON | |
| -DENABLE_CIF2HKL=ON | |
| -DENABLE_NEUTRONICS=OFF | |
| -DMPIINCLUDEDIR=%MPIINCVAR% | |
| -DMPILIBDIR=%MPILIBVAR% | |
| - name: Configure build and install mcstas on Windows-MSVC | |
| id: mcstas-install-windows-msvc | |
| if: ${{ matrix.CC != 'gcc.exe' && runner.os == 'Windows' }} | |
| run: > | |
| cmake -B build -S src | |
| "-DCMAKE_INSTALL_PREFIX=./install" | |
| -DMCVERSION="3.99.99" | |
| -DMCCODE_BUILD_CONDA_PKG=OFF | |
| -DMCCODE_CONFIG_MCPL2=ON | |
| -DCMAKE_INSTALL_LIBDIR=lib | |
| -DBUILD_MCSTAS=ON | |
| -DMCCODE_USE_LEGACY_DESTINATIONS=OFF | |
| -DBUILD_TOOLS=ON | |
| -DENABLE_COMPONENTS=ON | |
| -DENABLE_CIF2HKL=OFF | |
| -DENABLE_NEUTRONICS=OFF | |
| -DMPIINCLUDEDIR=%MPIINCVAR% | |
| -DMPILIBDIR=%MPILIBVAR% | |
| - name: CMake build | |
| if: runner.os == 'Windows' | |
| shell: cmd | |
| run: cmake --build build --config Release -j 2 | |
| - name: CMake install | |
| if: runner.os == 'Windows' | |
| run: cmake --install build --config Release | |
| - name: set MCSTAS env var | |
| if: runner.os == 'Windows' | |
| run: echo MCSTAS=%CD%\install\share\mcstas\resources >> %GITHUB_ENV% | |
| - name: check MCSTAS env var | |
| if: runner.os == 'Windows' | |
| run: echo %MCSTAS% | |
| - name: Various Windows debugging | |
| if: runner.os == 'Windows' | |
| shell: cmd | |
| run: | | |
| type .\install\share\mcstas\tools\Python\mccodelib\mccode_config.json | |
| .\install\bin\mcrun -h | |
| .\install\bin\mcstas -v | |
| mcpl-config -s | |
| ncrystal-config -s | |
| - name: Pip install Unix | |
| id: pip-install | |
| if: runner.os != 'Windows' | |
| run: | | |
| set -e | |
| set -u | |
| set -x | |
| if [ "$RUNNER_OS" == "macOS" ]; | |
| then | |
| python3 -mpip install PyYAML pyaml ply McStasScript ncrystal mcpl mcpl-extra jinja2 --break-system-packages | |
| fi | |
| if [ "$RUNNER_OS" == "Linux" ]; | |
| then | |
| python3 -mpip install PyYAML ply McStasscript ncrystal mcpl mcpl-extra jinja2 | |
| fi | |
| # Start of Unix tests | |
| - name: Launch RNG test instrument | |
| id: RNG-test | |
| if: runner.os != 'Windows' | |
| # Status: Works on Unixes | |
| run: | | |
| set -e | |
| set -u | |
| set -x | |
| export MCSTAS_EXECUTABLE="mcstas" | |
| export MCSTAS_PYGEN_EXECUTABLE="mcstas-pygen" | |
| export MCRUN_EXECUTABLE="mcrun" | |
| export MD5SUM="md5sum" | |
| if [ "$RUNNER_OS" == "Windows" ]; | |
| then | |
| export MCSTAS_EXECUTABLE="mcstas.exe" | |
| export MCSTAS_PYGEN_EXECUTABLE="mcstas-pygen.exe" | |
| export MCRUN_EXECUTABLE="mcrun.bat" | |
| fi | |
| if [ "$RUNNER_OS" == "macOS" ]; | |
| then | |
| export MD5SUM="md5" | |
| fi | |
| test -f ./install_mcstas/bin/${MCSTAS_EXECUTABLE} | |
| ./install_mcstas/bin/${MCSTAS_EXECUTABLE} --version | |
| mkdir run_RNG && cd run_RNG | |
| cp ../install_mcstas/share/mcstas/resources/examples/Tests_RNG/Test_RNG_rand01/Test_RNG_rand01.instr . | |
| ../install_mcstas/bin/${MCRUN_EXECUTABLE} Test_RNG_rand01.instr -s1000 Ncount=1000 -d RNGtest | |
| export SUM=`grep -v \# RNGtest/rngout.dat | ${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 | |
| if: runner.os != 'Windows' | |
| # Status: Works on Unixes | |
| run: | | |
| set -e | |
| set -u | |
| set -x | |
| export MCSTAS_EXECUTABLE="mcstas" | |
| export MCSTAS_PYGEN_EXECUTABLE="mcstas-pygen" | |
| export MCRUN_EXECUTABLE="mcrun" | |
| if [ "$RUNNER_OS" == "Windows" ]; | |
| then | |
| export MCSTAS_EXECUTABLE="mcstas.exe" | |
| export MCSTAS_PYGEN_EXECUTABLE="mcstas-pygen.exe" | |
| export MCRUN_EXECUTABLE="mcrun.bat" | |
| fi | |
| test -f ./install_mcstas/bin/${MCSTAS_EXECUTABLE} | |
| ./install_mcstas/bin/${MCSTAS_EXECUTABLE} --version | |
| mkdir run_BNL_H8 && cd run_BNL_H8 | |
| cp ../install_mcstas/share/mcstas/resources/examples/BNL/BNL_H8/BNL_H8.instr . | |
| ../install_mcstas/bin/${MCRUN_EXECUTABLE} BNL_H8.instr lambda=2.36 | |
| ../install_mcstas/bin/${MCSTAS_PYGEN_EXECUTABLE} BNL_H8.instr | |
| - name: Launch BNL_H8 instrument (MPI) | |
| id: h8-test-mpi | |
| if: runner.os != 'Windows' | |
| # Status: Works on Unixes | |
| run: | | |
| set -e | |
| set -u | |
| set -x | |
| export MCSTAS_EXECUTABLE="mcstas" | |
| export MCSTAS_PYGEN_EXECUTABLE="mcstas-pygen" | |
| export MCRUN_EXECUTABLE="mcrun" | |
| if [ "$RUNNER_OS" == "macOS" ]; then export TMPDIR=${HOME}/tmp; fi | |
| if [ "$RUNNER_OS" == "Windows" ]; | |
| then | |
| export MCSTAS_EXECUTABLE="mcstas.exe" | |
| export MCSTAS_PYGEN_EXECUTABLE="mcstas-pygen.exe" | |
| export MCRUN_EXECUTABLE="mcrun.bat" | |
| fi | |
| test -f ./install_mcstas/bin/${MCSTAS_EXECUTABLE} | |
| ./install_mcstas/bin/${MCSTAS_EXECUTABLE} --version | |
| mkdir run_BNL_H8_mpi && cd run_BNL_H8_mpi | |
| cp ../install_mcstas/share/mcstas/resources/examples/BNL/BNL_H8/BNL_H8.instr . | |
| ../install_mcstas/bin/${MCRUN_EXECUTABLE} --verbose --mpi=2 BNL_H8.instr lambda=2.36 | |
| - name: Launch MCPL test instrument | |
| id: mcpl-test | |
| if: runner.os != 'Windows' | |
| # Status: Works on Unixes | |
| run: | | |
| set -e | |
| set -u | |
| set -x | |
| export MCSTAS_EXECUTABLE="mcstas" | |
| export MCRUN_EXECUTABLE="mcrun" | |
| if [ "$RUNNER_OS" == "Windows" ]; | |
| then | |
| export MCSTAS_EXECUTABLE="mcstas.exe" | |
| export MCRUN_EXECUTABLE="mcrun.bat" | |
| fi | |
| export PATH=${PATH}:${PWD}/install_mcstas/bin/:${PWD}/install_mcstas/mcstas/3.99.99/bin/ | |
| test -f ./install_mcstas/bin/${MCSTAS_EXECUTABLE} | |
| ./install_mcstas/bin/${MCSTAS_EXECUTABLE} --version | |
| mkdir run_ESS_BEER_MCPL && cd run_ESS_BEER_MCPL | |
| cp ../install_mcstas/share/mcstas/resources/examples/ESS/ESS_BEER_MCPL/* . | |
| ../install_mcstas/bin/${MCRUN_EXECUTABLE} ESS_BEER_MCPL.instr repetition=50 | |
| - name: Launch MCPL test instrument (mpi) | |
| id: mcpl-test-mpi | |
| if: runner.os != 'Windows' | |
| # Status: Works on Unixes | |
| run: | | |
| set -e | |
| set -u | |
| set -x | |
| export MCSTAS_EXECUTABLE="mcstas" | |
| export MCRUN_EXECUTABLE="mcrun" | |
| if [ "$RUNNER_OS" == "macOS" ]; then export TMPDIR=${HOME}/tmp; fi | |
| if [ "$RUNNER_OS" == "Windows" ]; | |
| then | |
| export MCSTAS_EXECUTABLE="mcstas.exe" | |
| export MCRUN_EXECUTABLE="mcrun.bat" | |
| fi | |
| export PATH=${PATH}:${PWD}/install_mcstas/bin/:${PWD}/install_mcstas/mcstas/3.99.99/bin/ | |
| test -f ./install_mcstas/bin/${MCSTAS_EXECUTABLE} | |
| ./install_mcstas/bin/${MCSTAS_EXECUTABLE} --version | |
| mkdir run_ESS_BEER_MCPL_mpi && cd run_ESS_BEER_MCPL_mpi | |
| cp ../install_mcstas/share/mcstas/resources/examples/ESS/ESS_BEER_MCPL/* . | |
| ../install_mcstas/bin/${MCRUN_EXECUTABLE} --verbose --mpi=2 ESS_BEER_MCPL.instr repetition=100 | |
| - name: Launch NCrystal test instrument | |
| id: ncrystal-test | |
| if: runner.os != 'Windows' | |
| # Status: Works on Unixes | |
| run: | | |
| set -e | |
| set -u | |
| set -x | |
| export MCSTAS_EXECUTABLE="mcstas" | |
| export MCRUN_EXECUTABLE="mcrun" | |
| if [ "$RUNNER_OS" == "Windows" ]; | |
| then | |
| export MCSTAS_EXECUTABLE="mcstas.exe" | |
| export MCRUN_EXECUTABLE="mcrun.bat" | |
| fi | |
| export PATH=${PATH}:${PWD}/install_mcstas/bin/:${PWD}/install_mcstas/mcstas/3.99.99/bin/ | |
| test -f ./install_mcstas/bin/${MCSTAS_EXECUTABLE} | |
| ./install_mcstas/bin/${MCSTAS_EXECUTABLE} --version | |
| mkdir run_NCrystal_example && cd run_NCrystal_example | |
| cp ../install_mcstas/share/mcstas/resources/examples/NCrystal/NCrystal_example/NCrystal_example.instr . | |
| ../install_mcstas/bin/${MCRUN_EXECUTABLE} NCrystal_example.instr sample_cfg="Y2O3_sg206_Yttrium_Oxide.ncmat;density=0.6x" | |
| - name: Launch NCrystal test instrument (mpi) | |
| id: ncrystal-test-mpi | |
| if: runner.os != 'Windows' | |
| # Status: Works on Unixes | |
| run: | | |
| set -e | |
| set -u | |
| set -x | |
| export MCSTAS_EXECUTABLE="mcstas" | |
| export MCRUN_EXECUTABLE="mcrun" | |
| if [ "$RUNNER_OS" == "macOS" ]; then export TMPDIR=${HOME}/tmp; fi | |
| if [ "$RUNNER_OS" == "Windows" ]; | |
| then | |
| export MCSTAS_EXECUTABLE="mcstas.exe" | |
| export MCRUN_EXECUTABLE="mcrun.bat" | |
| fi | |
| export PATH=${PATH}:${PWD}/install_mcstas/bin/:${PWD}/install_mcstas/mcstas/3.99.99/bin/ | |
| test -f ./install_mcstas/bin/${MCSTAS_EXECUTABLE} | |
| ./install_mcstas/bin/${MCSTAS_EXECUTABLE} --version | |
| mkdir run_NCrystal_example_mpi && cd run_NCrystal_example_mpi | |
| cp ../install_mcstas/share/mcstas/resources/examples/NCrystal/NCrystal_example/NCrystal_example.instr . | |
| ncrystal-config --version | |
| export NUM_MPI=2 | |
| ../install_mcstas/bin/${MCRUN_EXECUTABLE} --verbose --mpi=${NUM_MPI} NCrystal_example.instr sample_cfg="Y2O3_sg206_Yttrium_Oxide.ncmat;density=0.6x" | |
| - name: Launch NeXus test instrument | |
| id: nexus-test | |
| if: runner.os == 'Linux' # Linux only | |
| # Status: Works on Linux (NeXus packages w/napi.h missing on mac+Windows) | |
| run: | | |
| set -e | |
| set -u | |
| set -x | |
| sudo apt-get update | |
| sudo apt-get -y install libnexus-dev | |
| export MCSTAS_EXECUTABLE="mcstas" | |
| export MCRUN_EXECUTABLE="mcrun" | |
| export PATH=${PATH}:${PWD}/install_mcstas/bin/:${PWD}/install_mcstas/mcstas/3.99.99/bin/ | |
| if [ "x$(uname | cut -f1 -d_)" == "xMINGW64" ]; | |
| then | |
| export MCSTAS_EXECUTABLE="mcstas.exe" | |
| export MCRUN_EXECUTABLE="mcrun.bat" | |
| fi | |
| test -f ./install_mcstas/bin/${MCSTAS_EXECUTABLE} | |
| ./install_mcstas/bin/${MCSTAS_EXECUTABLE} --version | |
| mkdir run_templateSANS_Mantid && cd run_templateSANS_Mantid | |
| cp ../install_mcstas/share/mcstas/resources/examples/Mantid/templateSANS_Mantid/templateSANS_Mantid.instr . | |
| #Not a final solution!!!: | |
| #if [ "x$(uname)" == "xDarwin" ]; then export MCSTAS_CC_OVERRIDE=/usr/bin/clang; fi | |
| if [ "x$(uname)" == "xLinux" ]; then | |
| ../install_mcstas/bin/${MCRUN_EXECUTABLE} --format=NeXus --IDF templateSANS_Mantid.instr lambda=6 | |
| ../install_mcstas/bin/${MCRUN_EXECUTABLE} -c --verbose --mpi=2 --format=NeXus --IDF templateSANS_Mantid.instr lambda=6 | |
| fi | |
| - 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=${{ matrix.CC }}_CHANGES $PERMISSIVE --verbose | |
| else | |
| echo .\\install\\bin\\mctest --verbose --testdir run_${comp} --comp=${comp} --suffix=${{ matrix.CC }}_CHANGES --permissive --verbose >> changedinstr.bat | |
| 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=${{ matrix.CC }}_CHANGES $PERMISSIVE | |
| mcviewtest --nobrowse $PWD | |
| else | |
| echo .\\install\\bin\\mctest --verbose --testdir=run_mctest $SCOPE --suffix=${{ matrix.CC }}_CHANGES --permissive >> ..\\changedinstr.bat | |
| fi | |
| fi | |
| # END of Unix tests | |
| - name: Run modified instruments Win | |
| id: instr-test-Win | |
| if: runner.os == 'Windows' # Windows only | |
| shell: cmd | |
| run: | | |
| if exist changedinstr.bat ( | |
| call .\changedinstr.bat | |
| ) | |
| # Start of Windows tests | |
| - name: Prepare rundirs Windows | |
| if: runner.os == 'Windows' # Windows only | |
| shell: cmd | |
| run: mkdir run_rng run_std run_mcpl_output run_mcpl_input run_mcpl_input_once run_union run_ncrystal | |
| - name: Prepare and run rng instrument Windows | |
| if: runner.os == 'Windows' # Windows only | |
| shell: cmd | |
| working-directory: run_rng | |
| run: | | |
| copy ..\install\share\mcstas\resources\examples\Tests_RNG\Test_RNG_rand01\Test_RNG_rand01.instr test.instr | |
| ..\install\bin\mcrun --verbose test.instr -s1000 Ncount=1000 -d RNGtest | |
| - name: Prepare and run BNL_H8 instrument Windows | |
| if: runner.os == 'Windows' # Windows only | |
| shell: cmd | |
| working-directory: run_std | |
| run: | | |
| copy ..\install\share\mcstas\resources\examples\BNL\BNL_H8\BNL_H8.instr test.instr | |
| ..\install\bin\mcrun --verbose test.instr -s1000 -y | |
| - name: Prepare and run NCrystal instrument Windows | |
| if: runner.os == 'Windows' # Windows only | |
| shell: cmd | |
| working-directory: run_ncrystal | |
| run: | | |
| copy ..\install\share\mcstas\resources\examples\NCrystal\NCrystal_example\NCrystal_example.instr test.instr | |
| ..\install\bin\mcrun --verbose test.instr -s1000 -y | |
| - name: Prepare and run MCPL_input instrument Windows | |
| if: runner.os == 'Windows' # Windows only | |
| shell: cmd | |
| working-directory: run_mcpl_input | |
| run: | | |
| copy ..\install\share\mcstas\resources\examples\Tests_MCPL_etc\Test_MCPL_input\Test_MCPL_input.instr test.instr | |
| copy ..\install\share\mcstas\resources\examples\Tests_MCPL_etc\Test_MCPL_input\voutput.mcpl.gz . | |
| ..\install\bin\mcrun --verbose test.instr -s1000 -y | |
| - name: Prepare and run MCPL_input_once instrument Windows | |
| if: runner.os == 'Windows' # Windows only | |
| shell: cmd | |
| working-directory: run_mcpl_input_once | |
| run: | | |
| copy ..\install\share\mcstas\resources\examples\Tests_MCPL_etc\Test_MCPL_input_once\Test_MCPL_input_once.instr test.instr | |
| copy ..\install\share\mcstas\resources\examples\Tests_MCPL_etc\Test_MCPL_input_once\voutput.mcpl.gz . | |
| ..\install\bin\mcrun --verbose test.instr -s1000 -y | |
| - name: Prepare and run MCPL_output instrument Windows | |
| if: runner.os == 'Windows' # Windows only | |
| shell: cmd | |
| working-directory: run_mcpl_output | |
| run: | | |
| copy ..\install\share\mcstas\resources\examples\Tests_MCPL_etc\Test_MCPL_output\Test_MCPL_output.instr test.instr | |
| ..\install\bin\mcrun --verbose test.instr -s1000 -y | |
| - name: Test RNG instrument output Windows | |
| if: runner.os == 'Windows' # Windows only | |
| working-directory: run_rng | |
| shell: bash | |
| run: | | |
| export SUM=`grep -v \# RNGtest/rngout.dat | dos2unix | md5sum | cut -f1 -d\ ` | |
| export EXPECTED="f192ce4609e2225bf9d42ce9c5fa5a86" | |
| if [ "${EXPECTED}" == "${SUM}" ]; | |
| then | |
| echo RNG test success! | |
| true | |
| else | |
| echo RNG test failure! | |
| false | |
| fi | |
| # END of Windows tests | |
| - 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.CC }}.${{ 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.CC }}.${{ matrix.mpi }}.python-${{ matrix.python }} | |
| path: "mcstas-${{ matrix.os }}.${{ matrix.CC }}.${{ 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 |