Merge pull request #2371 from tkittel/ncrystal_powdern #4163
Workflow file for this run
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@v6 | |
| with: | |
| path: src | |
| fetch-depth: 2 | |
| - name: Setup python | |
| uses: actions/setup-python@v6 | |
| 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 libnexus-dev | |
| - name: Setup (macOS) | |
| id: setup-macos | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew install bison flex gfortran gsl homebrew/science/nexusformat | |
| - 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 psutil jinja2 | |
| - 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 | |
| id: mcstas-install | |
| if: ${{ matrix.CC != 'cl.exe' && runner.os }} | |
| 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-MSVC | |
| id: mcstas-install-windows-msvc | |
| if: ${{ matrix.CC != 'gcc.exe' && runner.os == 'Windows' }} | |
| shell: cmd | |
| run: > | |
| cmake -B build -S src | |
| "-DCMAKE_INSTALL_PREFIX=./install_mcstas" | |
| -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: ${{ matrix.CC != 'gcc.exe' && runner.os == 'Windows' }} | |
| shell: cmd | |
| run: cmake --build build --config Release -j 2 | |
| - name: CMake install | |
| if: ${{ matrix.CC != 'gcc.exe' && runner.os == 'Windows' }} | |
| run: cmake --install build --config Release | |
| - name: set MCSTAS env var | |
| if: runner.os == 'Windows' | |
| run: echo MCSTAS=%CD%\install_mcstas\share\mcstas\resources >> %GITHUB_ENV% | |
| - name: check MCSTAS env var | |
| if: runner.os == 'Windows' | |
| run: echo %MCSTAS% | |
| - name: Various Windows debugging - McStas | |
| if: runner.os == 'Windows' | |
| shell: cmd | |
| run: | | |
| type .\install_mcstas\share\mcstas\tools\Python\mccodelib\mccode_config.json | |
| .\install_mcstas\bin\mcrun -h | |
| .\install_mcstas\bin\mcstas -v | |
| if [ "${{ matrix.CC }}" != "cl.exe" ]; | |
| then | |
| mcpl-config -s | |
| ncrystal-config -s | |
| fi | |
| - name: Various Windows debugging - MCPL and NCrystal | |
| if: runner.os == 'Windows' | |
| run: | | |
| 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 psutil --break-system-packages | |
| fi | |
| if [ "$RUNNER_OS" == "Linux" ]; | |
| then | |
| python3 -mpip install PyYAML ply McStasscript ncrystal mcpl mcpl-extra jinja2 psutil | |
| 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" | |
| export EXESUFFIX=".exe" | |
| else | |
| export SUFFIX="" | |
| export EXESUFFIX="" | |
| fi | |
| test -f ./install_mcstas/bin/mcstas${EXESUFFIX} | |
| ./install_mcstas/bin/mcstas${EXESUFFIX} --version | |
| ./install_mcstas/bin/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 | |
| export MD5SUM="md5sum" | |
| if [ "$RUNNER_OS" == "macOS" ]; | |
| then | |
| export MD5SUM="md5" | |
| fi | |
| if [ "$RUNNER_OS" == "Windows" ]; | |
| then | |
| export SUFFIX=".bat" | |
| export EXESUFFIX=".exe" | |
| else | |
| export SUFFIX="" | |
| export EXESUFFIX="" | |
| fi | |
| test -f ./install_mcstas/bin/mcstas${EXESUFFIX} | |
| ./install_mcstas/bin/mcstas${EXESUFFIX} --version | |
| ./install_mcstas/bin/mctest${SUFFIX} --instr=BNL_H8 --testdir=run_singletests --suffix=${{ matrix.mpi }} | |
| if [ "${{ matrix.CC }}" != "cl.exe" ]; | |
| then | |
| ./install_mcstas/bin/mctest${SUFFIX} --instr=BNL_H8 --mpi=2 --testdir=run_singletests --suffix=${{ matrix.mpi }} | |
| fi | |
| - name: Launch ISIS_CRISP | |
| id: ISIS_CRISP | |
| if: runner.os != 'Windows' | |
| 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" | |
| export EXESUFFIX=".exe" | |
| else | |
| export SUFFIX="" | |
| export EXESUFFIX="" | |
| fi | |
| test -f ./install_mcstas/bin/mcstas${EXESUFFIX} | |
| ./install_mcstas/bin/mcstas${EXESUFFIX} --version | |
| ./install_mcstas/bin/mctest${SUFFIX} --instr=ISIS_CRISP --testdir=run_singletests --suffix=${{ matrix.mpi }} | |
| ./install_mcstas/bin/mctest${SUFFIX} --instr=ISIS_CRISP --mpi=2 --testdir=run_singletests --suffix=${{ matrix.mpi }} | |
| - name: Launch MCPL test instrument | |
| id: mcpl-test | |
| if: runner.os != 'Windows' | |
| 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" | |
| export EXESUFFIX=".exe" | |
| else | |
| export SUFFIX="" | |
| export EXESUFFIX="" | |
| fi | |
| test -f ./install_mcstas/bin/mcstas${EXESUFFIX} | |
| ./install_mcstas/bin/mcstas${EXESUFFIX} --version | |
| ./install_mcstas/bin/mctest${SUFFIX} --instr=ESS_BEER_MCPL --testdir=run_singletests --suffix=${{ matrix.mpi }} | |
| ./install_mcstas/bin/mctest${SUFFIX} --instr=Test_MCPL_input --testdir=run_singletests --suffix=${{ matrix.mpi }} | |
| ./install_mcstas/bin/mctest${SUFFIX} --instr=Test_MCPL_output --testdir=run_singletests --suffix=${{ matrix.mpi }} | |
| ./install_mcstas/bin/mctest${SUFFIX} --instr=ESS_BEER_MCPL --mpi=2 --testdir=run_singletests --suffix=${{ matrix.mpi }} | |
| ./install_mcstas/bin/mctest${SUFFIX} --instr=Test_MCPL_input --mpi=2 --testdir=run_singletests --suffix=${{ matrix.mpi }} | |
| ./install_mcstas/bin/mctest${SUFFIX} --instr=Test_MCPL_output --mpi=2 --testdir=run_singletests --suffix=${{ matrix.mpi }} | |
| - name: Launch NCrystal test instrument | |
| id: ncrystal-test | |
| if: runner.os != 'Windows' | |
| 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" | |
| export EXESUFFIX=".exe" | |
| else | |
| export SUFFIX="" | |
| export EXESUFFIX="" | |
| fi | |
| test -f ./install_mcstas/bin/mcstas${EXESUFFIX} | |
| ./install_mcstas/bin/mctest${SUFFIX} --instr=NCrystal_example --testdir=run_singletests --suffix=${{ matrix.mpi }} | |
| if [ "${{ matrix.CC }}" != "cl.exe" ]; | |
| then | |
| ./install_mcstas/bin/mctest${SUFFIX} --instr=NCrystal_example --mpi=2 --testdir=run_singletests --suffix=${{ matrix.mpi }} | |
| fi | |
| - name: Launch NeXus test instrument | |
| id: nexus-test | |
| if: runner.os != 'Windows' | |
| 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" | |
| export EXESUFFIX=".exe" | |
| else | |
| export SUFFIX="" | |
| export EXESUFFIX="" | |
| fi | |
| test -f ./install_mcstas/bin/mcstas${EXESUFFIX} | |
| ./install_mcstas/bin/mctest${SUFFIX} --instr=templateSANS_Mantid --testdir=run_singletests --suffix=${{ matrix.mpi }} | |
| if [ "${{ matrix.CC }}" != "cl.exe" ]; | |
| then | |
| ./install_mcstas/bin/mctest${SUFFIX} --instr=templateSANS_Mantid --mpi=2 --testdir=run_singletests --suffix=${{ matrix.mpi }} | |
| 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=CHANGES_${{ matrix.CC }}_${{ matrix.mpi }} $PERMISSIVE --verbose | |
| else | |
| mctest.bat --mpi=2 --testdir run_${comp} --comp=${comp} --suffix=CHANGES_${{ matrix.CC }}_${{ 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 --testdir $PWD $SCOPE --suffix=CHANGES_${{ matrix.CC }} $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.CC }}.${{ matrix.mpi }}.python-${{ matrix.python }}_output.tgz run_* | |
| - name: 'Upload Artifact' | |
| id: tar-upload | |
| uses: actions/upload-artifact@v6 | |
| 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 |