Fix comp header #1773
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-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, mpi: 'openmpi' } | |
| - { os: macos-latest, mpi: 'openmpi' } | |
| - { os: windows-latest, mpi: 'msmpi' } | |
| name: ${{ matrix.os }}.${{ matrix.mpi }}.conda-basictest | |
| runs-on: ${{ matrix.os }} | |
| defaults: | |
| run: | |
| shell: bash -el {0} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| path: src | |
| fetch-depth: 2 | |
| - name: Setup VS in shell Intel | |
| if: runner.os == 'Windows' | |
| uses: egor-tensin/vs-shell@v2 | |
| - name: Get conda dependency list | |
| id: conda-deps | |
| run: | | |
| ./src/devel/bin/mccode-create-conda-yml -m mcstas -n mcstas -o dependencies.yml | |
| cat dependencies.yml | |
| - uses: mamba-org/setup-micromamba@v3 | |
| with: | |
| environment-name: mcstas | |
| environment-file: dependencies.yml | |
| - name: Check versions | |
| id: version-checks | |
| run: | | |
| which python3 | |
| python3 --version | |
| which cmake | |
| cmake --version | |
| - 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: Validate build output | |
| id: build-validation | |
| if: always() | |
| run: | | |
| set -e | |
| set -u | |
| set -x | |
| if [ "$RUNNER_OS" == "Windows" ]; | |
| then | |
| echo "Validating Windows build output..." | |
| echo "CONDA_PREFIX: $CONDA_PREFIX" | |
| echo "Checking for mcstas executable..." | |
| test -f ${CONDA_PREFIX}/bin/mcstas || test -f ${CONDA_PREFIX}/bin/mcstas.bat || { echo "ERROR: mcstas not found"; exit 1; } | |
| echo "Checking for mctest executable..." | |
| test -f ${CONDA_PREFIX}/bin/mctest.bat || { echo "ERROR: mctest.bat not found"; ls -la ${CONDA_PREFIX}/bin/ | grep -i mctest || echo "No mctest found"; exit 1; } | |
| else | |
| echo "Validating Unix build output..." | |
| test -f ${CONDA_PREFIX}/bin/mcstas || { echo "ERROR: mcstas not found"; exit 1; } | |
| test -f ${CONDA_PREFIX}/bin/mctest || { echo "ERROR: mctest not found"; exit 1; } | |
| fi | |
| - 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 and KDSource test instruments | |
| 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 }} | |
| mctest${SUFFIX} --instr=Test_KDSource --testdir=run_singletests --suffix=${{ matrix.mpi }} | |
| mctest${SUFFIX} --instr=Test_KDSource --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/ | |
| if [ "$RUNNER_OS" == "Windows" ]; | |
| then | |
| echo "Windows build - debugging environment:" | |
| echo "PATH: $PATH" | |
| echo "CONDA_PREFIX: $CONDA_PREFIX" | |
| echo "Available mctest files:" | |
| find ${CONDA_PREFIX}/bin/ -name "*mctest*" -type f || echo "No mctest found" | |
| ls -la ${CONDA_PREFIX}/bin/ | grep -i mctest || echo "No mctest in bin directory" | |
| fi | |
| # 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 || { echo "mctest failed with exit code $?"; exit 1; } | |
| else | |
| mctest.bat --mpi=2 --testdir run_${comp} --comp=${comp} --suffix=CHANGES_${{ matrix.mpi }} $PERMISSIVE --verbose || { echo "mctest.bat failed with exit code $?"; exit 1; } | |
| 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 || { echo "mctest failed with exit code $?"; exit 1; } | |
| mcviewtest --nobrowse $PWD | |
| else | |
| mctest.bat --mpi=2 --testdir $PWD $SCOPE --suffix=CHANGES_${{ matrix.mpi }} $PERMISSIVE || { echo "mctest.bat failed with exit code $?"; exit 1; } | |
| 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 }}.conda-basictest_output.tgz run_* | |
| - name: 'Upload Artifact' | |
| id: tar-upload | |
| uses: actions/upload-artifact@v6 | |
| if: always() | |
| with: | |
| name: mcstas-artefacts-${{ matrix.os }}.${{ matrix.mpi }}.conda-basictest | |
| path: "mcstas-${{ matrix.os }}.${{ matrix.mpi }}.conda-basictest_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 |