ci(amr): GitHub Actions CI/CD pipeline #1
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 | |
| on: | |
| push: | |
| branches: [main, cpp-sequential] | |
| pull_request: | |
| workflow_dispatch: | |
| # Cancel superseded runs on the same ref (don't waste runners on stale pushes). | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| # Least privilege: read-only token unless a job opts into more. | |
| permissions: | |
| contents: read | |
| jobs: | |
| # ---------------------------------------------------------------- lint ------- | |
| lint: | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| cache: pip | |
| - name: Install clang-format / cmake-format | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang-format-17 | |
| sudo ln -sf "$(command -v clang-format-17)" /usr/local/bin/clang-format | |
| - run: pip install pre-commit | |
| - name: pre-commit (all files) | |
| run: pre-commit run --all-files --show-diff-on-failure | |
| # ----------------------------------------------------- CPU build + test ------ | |
| cpu: | |
| needs: lint | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| compiler: | |
| - { cc: gcc-13, cxx: g++-13 } | |
| - { cc: clang-17, cxx: clang++-17 } | |
| build_type: [Debug, Release] | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 30 | |
| env: | |
| CC: ${{ matrix.compiler.cc }} | |
| CXX: ${{ matrix.compiler.cxx }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install toolchain (OpenMP + MPI + Catch2) | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake ninja-build libomp-dev \ | |
| openmpi-bin libopenmpi-dev catch2 ccache | |
| - uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/ccache | |
| key: ccache-${{ matrix.compiler.cxx }}-${{ matrix.build_type }}-${{ github.sha }} | |
| restore-keys: ccache-${{ matrix.compiler.cxx }}-${{ matrix.build_type }}- | |
| - name: Configure (OpenMP + MPI; sanitizers on Debug) | |
| run: > | |
| cmake -B build -G Ninja | |
| -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | |
| -DAMR_BUILD_MPI=ON -DAMR_BUILD_CUDA=OFF | |
| -DENABLE_SANITIZERS=${{ matrix.build_type == 'Debug' && 'ON' || 'OFF' }} | |
| -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache | |
| - name: Build | |
| run: cmake --build build --parallel | |
| - name: Test (ctest; MPI over tcp,self to avoid the shared-mem btl hang) | |
| env: | |
| OMPI_MCA_btl: tcp,self | |
| OMPI_MCA_rmaps_base_oversubscribe: "1" | |
| run: ctest --test-dir build --output-on-failure | |
| - name: Upload ctest log on failure | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ctest-${{ matrix.compiler.cxx }}-${{ matrix.build_type }} | |
| path: build/Testing/Temporary/LastTest.log | |
| if-no-files-found: ignore | |
| # ---------------------------------------------------- CUDA compile only ------ | |
| # GitHub-hosted runners have no GPU; we compile-check the CUDA backend here and | |
| # run it on a self-hosted GPU runner in the `gpu` job below. | |
| cuda-build: | |
| needs: lint | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 30 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install CUDA toolkit | |
| uses: Jimver/cuda-toolkit@v0.2.19 | |
| with: | |
| cuda: '12.5.0' | |
| method: network | |
| sub-packages: '["nvcc", "cudart", "thrust"]' | |
| - name: Install host toolchain | |
| run: sudo apt-get update && sudo apt-get install -y cmake ninja-build libomp-dev | |
| - name: Configure + compile CUDA backend (no GPU run) | |
| run: | | |
| cmake -B build-cuda -G Ninja -DCMAKE_BUILD_TYPE=Release \ | |
| -DAMR_BUILD_CUDA=ON -DAMR_CUDA_ARCHITECTURES=70 -DBUILD_TESTING=ON | |
| cmake --build build-cuda --target amr_cuda amr_cuda_tests | |
| # --------------------------------------------------------- Python ------------ | |
| python: | |
| needs: lint | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 15 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| cache: pip | |
| - run: pip install -r python/requirements.txt pytest | |
| - name: Python reference tests | |
| working-directory: python | |
| run: pytest -v tests.py test_balance.py | |
| # ------------------------------------------- GPU runtime (self-hosted) ------- | |
| # Optional: runs only if a self-hosted runner with the `gpu` label is online | |
| # (e.g. the project's A2000). Never blocks PRs from forks. | |
| gpu: | |
| needs: cuda-build | |
| if: ${{ github.event_name != 'pull_request' }} | |
| runs-on: [self-hosted, linux, gpu] | |
| timeout-minutes: 30 | |
| continue-on-error: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build + run CUDA tests and balance benchmark | |
| run: | | |
| make -C cuda ARCH=sm_86 | |
| ./cuda/test | |
| ./cuda/bench |