From a75bd6fe3e216dd59a0ca0770ec6d4eb0987e7c5 Mon Sep 17 00:00:00 2001 From: Juraj Smiesko <34742917+kjvbrt@users.noreply.github.com> Date: Wed, 13 Dec 2023 09:52:25 +0100 Subject: [PATCH] Improving tests (#325) * Adding OS(centos7,alma9,ubuntu) in CI tests * ubuntu -> ubuntu22 * Removing new lines * Running tests in parallel --- .github/workflows/test.yml | 32 ++++++++++++--------- examples/FCCee/test/jet_constituents.py | 2 +- examples/FCCee/weaver/analysis_inference.py | 5 +++- python/Parsers.py | 6 ++++ python/test.py | 4 +++ 5 files changed, 34 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 35f068856f..6f506a5c72 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: linux +name: 'Build and Test' on: [push, pull_request] @@ -8,42 +8,48 @@ jobs: strategy: fail-fast: false matrix: - SETUP: ['/cvmfs/sw.hsf.org/key4hep/setup.sh', '/cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh'] + STACK: ['/cvmfs/sw.hsf.org/key4hep/setup.sh', + '/cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh'] + OS: ['aidasoft/centos7', + 'key4hep/key4hep-images/alma9', + 'key4hep/key4hep-images/ubuntu22'] steps: - uses: actions/checkout@v3 - uses: cvmfs-contrib/github-action-cvmfs@v3 - name: Start container run: | - docker run -it --name CI_container -v ${GITHUB_WORKSPACE}:/Package -v /cvmfs:/cvmfs:shared -d ghcr.io/aidasoft/centos7:latest /bin/bash + docker run -it --name CI_container \ + -v ${GITHUB_WORKSPACE}:/Package \ + -v /cvmfs:/cvmfs:shared \ + -d ghcr.io/${{ matrix.OS }}:latest /bin/bash - name: CMake Configure run: | docker exec CI_container /bin/bash -c 'cd Package;\ mkdir -p build install;\ - source ${{ matrix.SETUP }};\ + source ${{ matrix.STACK }};\ cd build;\ - cmake -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_FLAGS=" -fdiagnostics-color=always " -DWITH_DD4HEP=ON -DWITH_ACTS=ON -DWITH_ONNX=ON -G Ninja ..;' + cmake -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_FLAGS=" -fdiagnostics-color=always " -DWITH_DD4HEP=ON -DWITH_ACTS=ON -DWITH_ONNX=ON -G Ninja ..;' - name: Compile run: | docker exec CI_container /bin/bash -c 'cd ./Package;\ - source ${{ matrix.SETUP }};\ + source ${{ matrix.STACK }};\ cd build;\ ninja -k0;' - name: Install run: | docker exec CI_container /bin/bash -c 'cd ./Package;\ - source ${{ matrix.SETUP }};\ + source ${{ matrix.STACK }};\ cd build;\ ninja -k0 install;' - name: Test run: | docker exec CI_container /bin/bash -c 'cd ./Package;\ - source ${{ matrix.SETUP }};\ + source ${{ matrix.STACK }};\ cd build;\ ninja -k0 && ctest --output-on-failure;' - name: Test using local Setup.sh run: | - docker exec CI_container /bin/bash -c 'cd ./Package - source ${{ matrix.SETUP }} - source ./setup.sh - fccanalysis run examples/FCCee/higgs/mH-recoil/mumu/analysis_stage1.py --output myoutput.root --files-list root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/spring2021/IDEA/p8_ee_Zbb_ecm91_EvtGen_Bc2TauNuTAUHADNU/events_131527278.root - ' + docker exec CI_container /bin/bash -c 'cd ./Package;\ + source ${{ matrix.STACK }};\ + source ./setup.sh;\ + fccanalysis run examples/FCCee/higgs/mH-recoil/mumu/analysis_stage1.py --output myoutput.root --files-list root://eospublic.cern.ch//eos/experiment/fcc/ee/generation/DelphesEvents/spring2021/IDEA/p8_ee_Zbb_ecm91_EvtGen_Bc2TauNuTAUHADNU/events_131527278.root' diff --git a/examples/FCCee/test/jet_constituents.py b/examples/FCCee/test/jet_constituents.py index 475be563d7..54450749c5 100644 --- a/examples/FCCee/test/jet_constituents.py +++ b/examples/FCCee/test/jet_constituents.py @@ -7,7 +7,7 @@ prodTag = "FCCee/spring2021/IDEA/" #Optional: output directory, default is local running directory -outputDir = "." +outputDir = "outputs/jet_constituents" #Optional nCPUS = 8 diff --git a/examples/FCCee/weaver/analysis_inference.py b/examples/FCCee/weaver/analysis_inference.py index d406362adf..623d4a4739 100644 --- a/examples/FCCee/weaver/analysis_inference.py +++ b/examples/FCCee/weaver/analysis_inference.py @@ -11,9 +11,12 @@ def get_file_path(url, filename): # ____________________________________________________________ -## input file needed for unit test in CI +## input file needed for unit test in CI testFile = "https://fccsw.web.cern.ch/fccsw/testsamples/wzp6_ee_nunuH_Hss_ecm240.root" +## output directory +outputDir = "outputs/inference" + ## latest particle transformer model, trainied on 9M jets in winter2023 samples model_name = "fccee_flavtagging_edm4hep_wc_v1" diff --git a/python/Parsers.py b/python/Parsers.py index 6841befdac..a52e62fa05 100644 --- a/python/Parsers.py +++ b/python/Parsers.py @@ -39,6 +39,12 @@ def setup_test_parser(parser): type=str, help='Exclude tests matching regular expression' ) + test_args.add_argument( + '-j', '--parallel', + type=int, + default=-1, + help='number of tests running in parallel (equivalent to `ctest -j`)' + ) def setup_pin_parser(parser): diff --git a/python/test.py b/python/test.py index e2d155643e..75cf05309e 100644 --- a/python/test.py +++ b/python/test.py @@ -57,4 +57,8 @@ def test_fccanalyses(mainparser): ctest_command.append('-E') ctest_command.append(args.exclude_regex) + if args.parallel != -1: + ctest_command.append('-j') + ctest_command.append(str(args.parallel)) + run_subprocess(ctest_command, local_dir + '/build')