Add conda package testing to CI and fix CMake package configuration #13
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: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| actions: read | |
| checks: write | |
| pull-requests: write | |
| pages: write | |
| id-token: write | |
| jobs: | |
| build-linux: | |
| runs-on: ubuntu-22.04 | |
| name: Build (linux) | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up build environment | |
| uses: ./.github/actions/setup | |
| with: | |
| platform: linux | |
| - name: Configure project | |
| uses: ./.github/actions/cmake-configure | |
| with: | |
| platform: linux | |
| - name: Build project | |
| uses: ./.github/actions/build | |
| with: | |
| platform: linux | |
| build-other-platforms: | |
| needs: build-linux | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: macos-14 | |
| platform: macos-arm | |
| - os: windows-2022 | |
| platform: windows | |
| runs-on: ${{ matrix.os }} | |
| name: Build (${{ matrix.platform }}) | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up build environment | |
| uses: ./.github/actions/setup | |
| with: | |
| platform: ${{ matrix.platform }} | |
| - name: Configure project | |
| uses: ./.github/actions/cmake-configure | |
| with: | |
| platform: ${{ matrix.platform }} | |
| - name: Build project | |
| uses: ./.github/actions/build | |
| with: | |
| platform: ${{ matrix.platform }} | |
| conda-build-linux: | |
| needs: build-linux | |
| runs-on: ubuntu-22.04 | |
| name: Conda Build (linux) | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up Miniconda | |
| uses: conda-incubator/setup-miniconda@v3 | |
| with: | |
| auto-update-conda: true | |
| conda-solver: libmamba | |
| channels: conda-forge | |
| - name: Install conda-build | |
| shell: bash -el {0} | |
| run: conda install -y conda-build | |
| - name: Build conda package | |
| shell: bash -el {0} | |
| run: conda build dependencies/recipe/ --output-folder conda-output | |
| - name: Upload conda package artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: conda-package-linux | |
| path: conda-output/ | |
| retention-days: 1 | |
| conda-build-macos: | |
| needs: build-other-platforms | |
| runs-on: macos-14 | |
| name: Conda Build (macos-arm) | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up Miniconda | |
| uses: conda-incubator/setup-miniconda@v3 | |
| with: | |
| auto-update-conda: true | |
| conda-solver: libmamba | |
| channels: conda-forge | |
| - name: Install conda-build | |
| shell: bash -el {0} | |
| run: conda install -y conda-build | |
| - name: Build conda package | |
| shell: bash -el {0} | |
| run: conda build dependencies/recipe/ --output-folder conda-output | |
| - name: Upload conda package artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: conda-package-macos | |
| path: conda-output/ | |
| retention-days: 1 | |
| conda-build-windows: | |
| needs: build-other-platforms | |
| runs-on: windows-2022 | |
| name: Conda Build (windows) | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up Miniconda | |
| uses: conda-incubator/setup-miniconda@v3 | |
| with: | |
| auto-update-conda: true | |
| conda-solver: libmamba | |
| channels: conda-forge | |
| - name: Install conda-build | |
| shell: bash -el {0} | |
| run: conda install -y conda-build | |
| - name: Build conda package | |
| shell: bash -el {0} | |
| run: conda build dependencies/recipe/ --output-folder conda-output | |
| - name: Upload conda package artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: conda-package-windows | |
| path: conda-output/ | |
| retention-days: 1 | |
| conda-test-linux: | |
| needs: conda-build-linux | |
| runs-on: ubuntu-22.04 | |
| name: Conda Package Test (linux) | |
| steps: | |
| - name: Checkout code (for test files only) | |
| uses: actions/checkout@v4 | |
| with: | |
| sparse-checkout: | | |
| tests/packaging | |
| sparse-checkout-cone-mode: false | |
| - name: Download conda package artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: conda-package-linux | |
| path: conda-package | |
| - name: Set up Miniconda | |
| uses: conda-incubator/setup-miniconda@v3 | |
| with: | |
| auto-update-conda: true | |
| conda-solver: libmamba | |
| channels: conda-forge | |
| activate-environment: test-env | |
| auto-activate-base: false | |
| - name: Install dependencies and local package | |
| shell: bash -el {0} | |
| run: | | |
| conda install -y cmake ninja | |
| conda install -y -c file://$PWD/conda-package vira | |
| - name: Build and run packaging test | |
| shell: bash -el {0} | |
| run: | | |
| cd tests/packaging | |
| mkdir build && cd build | |
| cmake .. -DCMAKE_PREFIX_PATH=$CONDA_PREFIX | |
| cmake --build . | |
| ctest --output-on-failure | |
| conda-test-macos: | |
| needs: conda-build-macos | |
| runs-on: macos-14 | |
| name: Conda Package Test (macos-arm) | |
| steps: | |
| - name: Checkout code (for test files only) | |
| uses: actions/checkout@v4 | |
| with: | |
| sparse-checkout: | | |
| tests/packaging | |
| sparse-checkout-cone-mode: false | |
| - name: Download conda package artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: conda-package-macos | |
| path: conda-package | |
| - name: Set up Miniconda | |
| uses: conda-incubator/setup-miniconda@v3 | |
| with: | |
| auto-update-conda: true | |
| conda-solver: libmamba | |
| channels: conda-forge | |
| activate-environment: test-env | |
| auto-activate-base: false | |
| - name: Install dependencies and local package | |
| shell: bash -el {0} | |
| run: | | |
| conda install -y cmake ninja | |
| conda install -y -c file://$PWD/conda-package vira | |
| - name: Build and run packaging test | |
| shell: bash -el {0} | |
| run: | | |
| cd tests/packaging | |
| mkdir build && cd build | |
| cmake .. -DCMAKE_PREFIX_PATH=$CONDA_PREFIX | |
| cmake --build . | |
| ctest --output-on-failure | |
| conda-test-windows: | |
| needs: conda-build-windows | |
| runs-on: windows-2022 | |
| name: Conda Package Test (windows) | |
| steps: | |
| - name: Checkout code (for test files only) | |
| uses: actions/checkout@v4 | |
| with: | |
| sparse-checkout: | | |
| tests/packaging | |
| sparse-checkout-cone-mode: false | |
| - name: Download conda package artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: conda-package-windows | |
| path: conda-package | |
| - name: Set up Miniconda | |
| uses: conda-incubator/setup-miniconda@v3 | |
| with: | |
| auto-update-conda: true | |
| conda-solver: libmamba | |
| channels: conda-forge | |
| activate-environment: test-env | |
| auto-activate-base: false | |
| - name: Install dependencies and local package | |
| shell: bash -el {0} | |
| run: | | |
| conda install -y cmake ninja | |
| # On Windows, convert path to proper file URL format | |
| CHANNEL_PATH=$(cygpath -m "$PWD/conda-package") | |
| conda install -y -c "file:///$CHANNEL_PATH" vira | |
| - name: Build and run packaging test | |
| shell: powershell | |
| run: | | |
| cd tests/packaging | |
| mkdir build | |
| cd build | |
| cmake .. -DCMAKE_PREFIX_PATH="$env:CONDA_PREFIX;$env:CONDA_PREFIX/Library" | |
| cmake --build . --config Release | |
| ctest -C Release --output-on-failure | |
| docs: | |
| needs: build-linux | |
| runs-on: ubuntu-22.04 | |
| name: Documentation | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up build environment | |
| uses: ./.github/actions/setup-docs | |
| with: | |
| platform: linux | |
| - name: Configure project | |
| uses: ./.github/actions/cmake-configure-docs | |
| with: | |
| platform: linux | |
| - name: Build project | |
| uses: ./.github/actions/build | |
| with: | |
| platform: linux | |
| - name: Setup Pages | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| uses: actions/configure-pages@v4 | |
| - name: Upload Pages artifact | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./build/vira_docs/ | |
| - name: Deploy to GitHub Pages | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| # Gate job that depends on all other jobs - use this for branch protection | |
| ci: | |
| name: CI | |
| if: always() | |
| needs: | |
| - build-linux | |
| - build-other-platforms | |
| - conda-build-linux | |
| - conda-build-macos | |
| - conda-build-windows | |
| - conda-test-linux | |
| - conda-test-macos | |
| - conda-test-windows | |
| - docs | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Check all jobs passed | |
| run: | | |
| if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" || "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then | |
| echo "One or more jobs failed or were cancelled" | |
| exit 1 | |
| fi | |
| echo "All jobs passed successfully" |