diff --git a/.gitea/workflows/docker-rh8-build-test.yml b/.gitea/workflows/docker-rh8-build-test.yml new file mode 100644 index 000000000..5959f3a0d --- /dev/null +++ b/.gitea/workflows/docker-rh8-build-test.yml @@ -0,0 +1,44 @@ +name: Build on RHEL8 docker image + +on: + push: + workflow_dispatch: + +permissions: + contents: read + +jobs: + build: + runs-on: "ubuntu-latest" + container: + image: gitea.psi.ch/detectors/rhel8-detectors-dev + steps: + - name: Clone repository + run: | + git lfs install --skip-smudge + echo Cloning ${{ github.ref_name }} + git clone https://${{secrets.GITHUB_TOKEN}}@gitea.psi.ch/${{ github.repository }}.git --branch=${{ github.ref_name }} . + + - name: Build library + run: | + mkdir build && cd build + cmake .. -DSLS_USE_PYTHON=ON -DSLS_USE_TESTS=ON -DSLS_USE_SIMULATOR=ON + make -j 2 + + - name: C++ unit tests + working-directory: ${{gitea.workspace}}/build + run: ctest -j1 --rerun-failed --output-on-failure + + - name: Install Python dependencies + run: | + python3.12 -m pip install --upgrade pip + python3.12 -m pip install pytest + python3.12 -m pip install colorama + python3.12 -m pip install numpy + python3.12 -m pip install pyzmq + + - name: Python unit tests + working-directory: ${{gitea.workspace}} + run: | + export PYTHONPATH=$PWD/build/bin:$PYTHONPATH + python3.12 -m pytest python/tests \ No newline at end of file diff --git a/.gitea/workflows/docker-rh9-build-test.yml b/.gitea/workflows/docker-rh9-build-test.yml new file mode 100644 index 000000000..2783d69ec --- /dev/null +++ b/.gitea/workflows/docker-rh9-build-test.yml @@ -0,0 +1,41 @@ +name: Build on RHEL9 docker image + +on: + push: + workflow_dispatch: + +permissions: + contents: read + +jobs: + build: + runs-on: "ubuntu-latest" + container: + image: gitea.psi.ch/detectors/rhel9-detectors-dev + steps: + - uses: actions/checkout@v4 + + + - name: Build library + run: | + mkdir build && cd build + cmake .. -DSLS_USE_PYTHON=ON -DSLS_USE_TESTS=ON -DSLS_USE_SIMULATOR=ON + make -j 2 + + - name: C++ unit tests + working-directory: ${{gitea.workspace}}/build + run: ctest -j1 --rerun-failed --output-on-failure + + - name: Install Python dependencies + run: | + python3.12 -m pip install --upgrade pip + python3.12 -m pip install pytest + python3.12 -m pip install colorama + python3.12 -m pip install numpy + python3.12 -m pip install pyzmq + + - name: Python unit tests + working-directory: ${{gitea.workspace}} + run: | + export PYTHONPATH=$PWD/build/bin:$PYTHONPATH + python3.12 -m pytest python/tests \ No newline at end of file diff --git a/.gitea/workflows/rh8-local-build-deploy.yml b/.gitea/workflows/rh8-local-build-deploy.yml new file mode 100644 index 000000000..120605dac --- /dev/null +++ b/.gitea/workflows/rh8-local-build-deploy.yml @@ -0,0 +1,32 @@ +name: Build and Deploy on local RHEL8 + +on: + push: + branches: + - developer + workflow_dispatch: + +permissions: + contents: read + +jobs: + build: + runs-on: "detectors-software-RH8" + steps: + - uses: actions/checkout@v4 + + - name: Build library + run: | + source /home/gitea_runner/.bashrc + conda activate det + mkdir build && cd build + conda activate det + cmake .. -DSLS_USE_PYTHON=ON -DSLS_USE_SIMULATOR=ON -DSLS_USE_GUI=ON + make -j 2 + + - name: Deploy to NFS update server + if: gitea.ref == 'refs/heads/developer' + run: | + sftp -r gitea_runner@mpc2935:/slsDetectorSoftware/RH8 <<< $'put build/bin' + sftp -r gitea_runner@mpc2935:/slsDetectorSoftware/RH8 <<< $'put pyctbgui' + sftp -r gitea_runner@mpc2935:/slsDetectorSoftware/RH8 <<< $'put slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer' \ No newline at end of file diff --git a/.gitea/workflows/rh8-local-tests.yml b/.gitea/workflows/rh8-local-tests.yml new file mode 100644 index 000000000..b52e80e8c --- /dev/null +++ b/.gitea/workflows/rh8-local-tests.yml @@ -0,0 +1,61 @@ +name: Run Simulator Tests on local RHEL8 + +on: + push: + workflow_dispatch: + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Debug + + +jobs: + build: + runs-on: "detectors-software-RH8" + steps: + - uses: actions/checkout@v4 + + - name: Configure CMake + run: | + source /home/gitea_runner/.bashrc + conda activate det + cmake -B build \ + -DCMAKE_BUILD_TYPE=Debug \ + -DSLS_USE_TESTS=ON \ + -DSLS_USE_SIMULATOR=ON \ + -DSLS_USE_PYTHON=On \ + -DSLS_USE_HDF5=ON + + - name: Build + # Build your program with the given configuration + run: | + source /home/gitea_runner/.bashrc + conda activate det + cmake --build build -j4 --config Debug + + - name: Python unit tests with simulators + run: | + source /home/gitea_runner/.bashrc + conda activate det + export PYTHONPATH=$PWD/build/bin:$PYTHONPATH + export SLSDETNAME=gitea_runner_tests + python -m pytest python/tests + + + - name: Simulator unit tests + run: | + source /home/gitea_runner/.bashrc + conda activate det + export PYTHONPATH=$PWD/build/bin:$PYTHONPATH + export PATH=$PWD/build/bin:$PATH + cd build/bin + python test_simulators.py + + - name: Run frame synchronizer tests + run: | + source /home/gitea_runner/.bashrc + conda activate det + export PYTHONPATH=$PWD/build/bin:$PYTHONPATH + export PATH=$PWD/build/bin:$PATH + cd build/bin + python test_frame_synchronizer.py diff --git a/.gitea/workflows/rh9-local-build-deploy.yml b/.gitea/workflows/rh9-local-build-deploy.yml new file mode 100644 index 000000000..94db2a2ec --- /dev/null +++ b/.gitea/workflows/rh9-local-build-deploy.yml @@ -0,0 +1,29 @@ +name: Build and Deploy on local RHEL9 + +on: + push: + branches: + - developer + workflow_dispatch: + +permissions: + contents: read + +jobs: + build: + runs-on: "detectors-software-RH9" + steps: + - uses: actions/checkout@v4 + + - name: Build library + run: | + mkdir build && cd build + cmake -DSLS_USE_PYTHON=ON -DPython_EXECUTABLE=/usr/bin/python3.13 -DPython_INCLUDE_DIR=/usr/include/python3.13 -DPython_LIBRARY=/usr/lib64/libpython3.13.so -DSLS_USE_SIMULATOR=ON -DSLS_USE_GUI=ON .. + make -j 2 + + - name: Deploy to NFS update server + if: gitea.ref == 'refs/heads/developer' + run: | + sftp -r gitea_runner@mpc2935:/slsDetectorSoftware/RH9 <<< $'put build/bin' + sftp -r gitea_runner@mpc2935:/slsDetectorSoftware/RH9 <<< $'put pyctbgui' + sftp -r gitea_runner@mpc2935:/slsDetectorSoftware/RH9 <<< $'put slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer' \ No newline at end of file diff --git a/.gitea/workflows/rh9-local-tests.yml b/.gitea/workflows/rh9-local-tests.yml new file mode 100644 index 000000000..a6a3d1f98 --- /dev/null +++ b/.gitea/workflows/rh9-local-tests.yml @@ -0,0 +1,52 @@ +name: Run Simulator Tests on local RHEL9 + +on: + push: + workflow_dispatch: + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Debug + + +jobs: + build: + runs-on: "detectors-software-RH9" + steps: + - uses: actions/checkout@v4 + + - name: Configure CMake + run: | + cmake -B build \ + -DCMAKE_BUILD_TYPE=Debug \ + -DSLS_USE_TESTS=ON \ + -DSLS_USE_SIMULATOR=ON \ + -DSLS_USE_PYTHON=On \ + -DPython_EXECUTABLE=/usr/bin/python3.13 \ + -DPython_INCLUDE_DIR=/usr/include/python3.13 \ + -DPython_LIBRARY=/usr/lib64/libpython3.13.so \ + -DSLS_USE_HDF5=ON + + - name: Build + # Build your program with the given configuration + run: cmake --build build -j4 --config Debug + + - name: Python unit tests with simulators + run: | + export PYTHONPATH=$PWD/build/bin:$PYTHONPATH + export SLSDETNAME=gitea_runner_tests + python3.13 -m pytest python/tests + + - name: Simulator unit tests + run: | + export PYTHONPATH=$PWD/build/bin:$PYTHONPATH + export PATH=$PWD/build/bin:$PATH + cd build/bin + python3.13 test_simulators.py + + - name: Run frame synchronizer tests + run: | + export PYTHONPATH=$PWD/build/bin:$PYTHONPATH + export PATH=$PWD/build/bin:$PATH + cd build/bin + python3.13 test_frame_synchronizer.py diff --git a/.github/workflows/build_wheel.yml b/.github/workflows/build_wheel.yml new file mode 100644 index 000000000..9e1d2df20 --- /dev/null +++ b/.github/workflows/build_wheel.yml @@ -0,0 +1,64 @@ +name: Build wheel + +on: + workflow_dispatch: + pull_request: + push: + branches: + - main + release: + types: + - published + + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest,] + + steps: + - uses: actions/checkout@v6 + + - name: Build wheels + run: pipx run cibuildwheel==3.2.1 + + - uses: actions/upload-artifact@v7 + with: + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl + + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + + - name: Build sdist + run: pipx run build --sdist + + - uses: actions/upload-artifact@v7 + with: + name: cibw-sdist + path: dist/*.tar.gz + + upload_pypi: + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + environment: pypi + permissions: + id-token: write + if: github.event_name == 'release' && github.event.action == 'published' + # or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this) + # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + steps: + - uses: actions/download-artifact@v7 + with: + # unpacks all CIBW artifacts into dist/ + pattern: cibw-* + path: dist + merge-multiple: true + + - uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/cmake.yaml b/.github/workflows/cmake.yaml index 00d6a4b86..2b3512644 100644 --- a/.github/workflows/cmake.yaml +++ b/.github/workflows/cmake.yaml @@ -1,6 +1,6 @@ name: Native CMake Build -on: [push, pull_request] +on: [push, pull_request, workflow_dispatch] env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) @@ -14,34 +14,43 @@ jobs: runs-on: ubuntu-latest name: Configure and build using cmake steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@v6 + - uses: actions/setup-python@v6 with: python-version: 3.12 cache: 'pip' - - run: pip install pytest numpy + - run: pip install pytest numpy colorama - - uses: awalsh128/cache-apt-pkgs-action@latest + # using a stable action version instead of latest to create/restore cache for now + - uses: awalsh128/cache-apt-pkgs-action@v1.6.1 with: - packages: libhdf5-dev qtbase5-dev qt5-qmake libqt5svg5-dev libpng-dev libtiff-dev + packages: libhdf5-dev qtbase5-dev qt5-qmake libqt5svg5-dev libpng-dev libtiff-dev libfmt-dev version: 1.0 - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DSLS_USE_TESTS=ON -DSLS_USE_HDF5=ON -DSLS_USE_GUI=ON -DSLS_USE_MOENCH=ON -DSLS_USE_PYTHON=ON + run: | + cmake -B ${{github.workspace}}/build \ + -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ + -DSLS_USE_TESTS=ON \ + -DSLS_USE_SIMULATOR=ON \ + -DSLS_USE_PYTHON=ON \ + -DSLS_USE_HDF5=ON \ + -DSLS_USE_GUI=ON \ + -DSLS_USE_MOENCH=ON \ + -DSLS_TREAT_WARNINGS_AS_ERRORS=ON \ + -DSLS_USE_MATTERHORN=ON - name: Build # Build your program with the given configuration run: cmake --build ${{github.workspace}}/build -j4 --config ${{env.BUILD_TYPE}} - - name: C++ unit tests - working-directory: ${{github.workspace}}/build - run: ctest -C ${{env.BUILD_TYPE}} -j1 - - - name: Python unit tests - working-directory: ${{github.workspace}}/build/bin - run: | - python -m pytest ${{github.workspace}}/python/tests + + + + + + diff --git a/.github/workflows/conda_library.yaml b/.github/workflows/conda_library.yaml index 23f94d467..58a504bd6 100644 --- a/.github/workflows/conda_library.yaml +++ b/.github/workflows/conda_library.yaml @@ -1,7 +1,7 @@ name: Build slsdetlib on: [pull_request] - + jobs: build: strategy: @@ -18,10 +18,10 @@ jobs: shell: "bash -l {0}" steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Get conda - uses: conda-incubator/setup-miniconda@v3.0.4 + uses: conda-incubator/setup-miniconda@v4 with: python-version: ${{ matrix.python-version }} channels: conda-forge @@ -33,10 +33,10 @@ jobs: run: conda config --set anaconda_upload no - name: Build - run: conda build conda-recipes/main-library --output-folder build_output + run: conda-build conda-recipes/main-library --output-folder build_output - name: Upload all Conda packages - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: conda-packages path: build_output/** # Uploads all packages \ No newline at end of file diff --git a/.github/workflows/conda_python.yaml b/.github/workflows/conda_python.yaml index 4b12cb3ff..d95d430b8 100644 --- a/.github/workflows/conda_python.yaml +++ b/.github/workflows/conda_python.yaml @@ -1,7 +1,7 @@ name: slsdet on: [pull_request] - + jobs: build: strategy: @@ -18,10 +18,10 @@ jobs: shell: "bash -l {0}" steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Get conda - uses: conda-incubator/setup-miniconda@v3.0.4 + uses: conda-incubator/setup-miniconda@v4 with: python-version: ${{ matrix.python-version }} channels: conda-forge @@ -33,10 +33,10 @@ jobs: run: conda config --set anaconda_upload no - name: Build - run: conda build conda-recipes/python-client --output-folder build_output + run: conda-build conda-recipes/python-client --output-folder build_output - name: Upload all Conda packages - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: conda-packages path: build_output/** # Uploads all packages \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index b1d035d76..bb2c5b382 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -330,6 +330,7 @@ endif (SLS_USE_INTEGRATION_TESTS) if (SLS_USE_PYTHON) find_package (Python 3.8 COMPONENTS Interpreter Development) + set(PYBIND11_FINDPYTHON ON) # Needed for RH8 if(SLS_FETCH_PYBIND11_FROM_GITHUB) FetchContent_Declare( pybind11 diff --git a/tests/scripts/utils_for_test.py b/tests/scripts/utils_for_test.py index bc703648a..a529082f3 100644 --- a/tests/scripts/utils_for_test.py +++ b/tests/scripts/utils_for_test.py @@ -83,7 +83,6 @@ def cleanSharedmemory(fp): except: raise RuntimeException('Could not free shared memory') - def cleanup(fp): Log(LogLevel.INFO, 'Cleaning up') Log(LogLevel.INFO, 'Cleaning up', fp)