From 76247b57c163074e5f05da28d06e41d507ab5443 Mon Sep 17 00:00:00 2001 From: Chris Hold Date: Tue, 6 Feb 2024 18:54:54 +0200 Subject: [PATCH] CI setup (#3): Building and testing on all platforms * Create python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Add SAF submodule * Adapt build path to reflect submodule * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Change branch in SAF * Add develop branch to SAF * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Link saf_performance lib explicitly * Split into two jobs * Update python-safpy.yml * Revert needs same job * CI: run python version matrix * CI: Use Python versions * CI: Introduce macOS * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update Spatial_Audio_Framework * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update Spatial_Audio_Framework * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Introduce MSVC complex type to safpy_build.py * Move complex typedef in safpy_build.py * Use _Complex in safpy_build.py * Revert "Use _Complex in safpy_build.py" This reverts commit b0d91dcae67522743674cf367ef78044ec83e5b7. * Revert "Move complex typedef in safpy_build.py" This reverts commit d5b0844f6913a8d31926edd101b2aac76be38ef3. * Revert "Introduce MSVC complex type to safpy_build.py" This reverts commit b5e598c3f9bf0705fce1d20a898a67f19a8d6441. * Use Ninja on Windows * Same test run for all * Update python-safpy.yml * Update python-safpy.yml * Update python-safpy.yml * Update safpy_build.py * Update python-safpy.yml * Link only openBLAS * Update safpy_build.py * Safpy_build: switch typedef complex on win32 * CI: use msvc again * Update python-safpy.yml * Update safpy_build.py * Trying to use the native _Complex * Update safpy_build.py * Revert "Trying to use the native _Complex" This reverts commit 6932d600418d757220c637a8dedf8b2440f3d9d4. * Trying typedef struct float_complex * Update safpy_build.py * Update safpy_build.py * Update safpy_build.py * Copy openblas on windows to safpy folder * Update python-safpy.yml * Update python-safpy.yml * More defaults for win and openblas * Update python-safpy.yml * Update Spatial_Audio_Framework * Cleanup --- .github/workflows/python-safpy.yml | 79 +++++++++++++++++++++++------- 1 file changed, 61 insertions(+), 18 deletions(-) diff --git a/.github/workflows/python-safpy.yml b/.github/workflows/python-safpy.yml index c623ffc..5c4e6e9 100644 --- a/.github/workflows/python-safpy.yml +++ b/.github/workflows/python-safpy.yml @@ -14,42 +14,82 @@ permissions: jobs: build-and-test: - runs-on: ubuntu-latest + + name: Test on ${{ matrix.os }} with Python ${{ matrix.python-version }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macOS-latest, windows-latest] + python-version: ["3.10", "3.11"] steps: - uses: actions/checkout@v3 - - name: Set up Python 3.10 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v3 with: - python-version: "3.10" - - name: Install dependencies + python-version: ${{ matrix.python-version }} + - name: Install Python package dependencies run: | python -m pip install --upgrade pip pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi pip install cffi numpy spaudiopy - name: Checkout submodules - run: git submodule update --init --recursive - - - name: Dependency packages - run: | - sudo apt-get update && sudo apt-get install libsndfile1 liblapack3 liblapack-dev libopenblas-base libopenblas-dev liblapacke-dev - sudo ldconfig + run: git submodule update --init --recursive --depth=1 + + - name: Install system dependencies + run: | + if [ "$RUNNER_OS" == "Linux" ]; then + sudo apt-get update && sudo apt-get install libsndfile1 liblapack3 liblapack-dev libopenblas-base libopenblas-dev liblapacke-dev + sudo ldconfig + elif [ "$RUNNER_OS" == "macOS" ]; then + brew install openblas + elif [ "$RUNNER_OS" == "Windows" ]; then + curl https://github.com/OpenMathLib/OpenBLAS/releases/download/v0.3.26/OpenBLAS-0.3.26-x64.zip -L -o tmp.zip + 7z x ./tmp.zip -oOpenBLAS + cp ./OpenBLAS/lib/libopenblas.lib $GITHUB_WORKSPACE + cp ./OpenBLAS/bin/libopenblas.dll $GITHUB_WORKSPACE + echo "$GITHUB_WORKSPACE" >> $GITHUB_PATH + else + echo "$RUNNER_OS not supported" + exit 1 + fi + shell: bash - - name: Configure CMake (Linux) + - name: Configure CMake # Note the current convention is to use the -S and -B options here to specify source # and build directories, but this is only available with CMake 3.13 and higher. # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 run: | cmake -E make_directory ./Spatial_Audio_Framework/build - cmake -S ./Spatial_Audio_Framework/ -B ./Spatial_Audio_Framework/build -DSAF_PERFORMANCE_LIB=SAF_USE_OPEN_BLAS_AND_LAPACKE -DSAF_BUILD_EXAMPLES=0 + if [ "$RUNNER_OS" == "Linux" ]; then + cmake -S ./Spatial_Audio_Framework/ -B ./Spatial_Audio_Framework/build -DSAF_PERFORMANCE_LIB=SAF_USE_OPEN_BLAS_AND_LAPACKE -DSAF_BUILD_EXAMPLES=0 + elif [ "$RUNNER_OS" == "macOS" ]; then + cmake -S ./Spatial_Audio_Framework/ -B ./Spatial_Audio_Framework/build -DSAF_PERFORMANCE_LIB=SAF_USE_APPLE_ACCELERATE -DSAF_BUILD_EXAMPLES=0 + elif [ "$RUNNER_OS" == "Windows" ]; then + cmake -S ./Spatial_Audio_Framework/ -B ./Spatial_Audio_Framework/build -DSAF_PERFORMANCE_LIB=SAF_USE_OPEN_BLAS_AND_LAPACKE -DOPENBLAS_LIBRARY=$GITHUB_WORKSPACE/OpenBLAS/lib/libopenblas.lib -DLAPACKE_LIBRARY=$GITHUB_WORKSPACE/OpenBLAS/lib/libopenblas.lib -DOPENBLAS_HEADER_PATH=$GITHUB_WORKSPACE/OpenBLAS/include/ -DSAF_BUILD_EXAMPLES=0 + fi + shell: bash + - name: Build SAF # Execute the build. You can specify a specific target with "--target " - run: cmake --build ./Spatial_Audio_Framework/build + run: cmake --build ./Spatial_Audio_Framework/build -j2 + + - name: Print shared object dependencies + if: ${{ contains( runner.os, 'Linux' ) }} + run: ldd ./Spatial_Audio_Framework/build/test/saf_test + - name: Test SAF run: | - ldd ./Spatial_Audio_Framework/build/test/saf_test - ./Spatial_Audio_Framework/build/test/saf_test + if [ "$RUNNER_OS" != "Windows" ]; then + ./Spatial_Audio_Framework/build/test/saf_test + else + cp ./Spatial_Audio_Framework/build/test/Debug/saf_test.exe ./Spatial_Audio_Framework/build/test/ + cp ./Spatial_Audio_Framework/build/framework/Debug/saf.lib ./Spatial_Audio_Framework/build/framework/ + + ./Spatial_Audio_Framework/build/test/saf_test.exe + fi + shell: bash - name: Lint with flake8 run: | @@ -58,8 +98,11 @@ jobs: # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Build package + run: python setup.py build + - name: Build and install package run: python -m pip install -e . + - name: Test with pytest - run: | - pytest -vvv + run: pytest -vvv