ci: bump the actions group with 7 updates #15
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, dev] | |
| 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@v6 | |
| with: | |
| fetch-depth: 0 # need history to diff against the base ref | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.12' | |
| - run: pip install pre-commit | |
| # clang-format / cmake-format come pinned from their pre-commit mirrors, | |
| # so no apt install is needed. Lint only the files this PR/push changed, | |
| # so the existing tree is not retroactively reformatted; new work must | |
| # still satisfy every hook. | |
| - name: pre-commit (changed files) | |
| run: | | |
| set -e | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| git fetch --no-tags origin "${{ github.base_ref }}" | |
| # merge-base, not the base tip: lints exactly this PR's changes even | |
| # if the base branch has moved ahead. | |
| FROM="$(git merge-base "origin/${{ github.base_ref }}" HEAD)" | |
| else | |
| FROM="${{ github.event.before }}" | |
| fi | |
| # Only lint incrementally when FROM is a real ancestor of HEAD. After a | |
| # force-push / history rewrite the old 'before' SHA is orphaned (not an | |
| # ancestor); there's no meaningful incremental base, so skip rather than | |
| # fall back to --all-files (which would reformat the whole existing tree). | |
| if [ -n "$FROM" ] && [ "$FROM" != "0000000000000000000000000000000000000000" ] \ | |
| && git merge-base --is-ancestor "$FROM" HEAD 2>/dev/null; then | |
| echo "Linting files changed in $FROM..HEAD" | |
| pre-commit run --from-ref "$FROM" --to-ref HEAD --show-diff-on-failure | |
| else | |
| echo "No usable incremental base (new branch or force-push) — skipping incremental lint." | |
| echo "Pull requests always lint against their merge-base, so new work is still covered." | |
| fi | |
| # ----------------------------------------------------- CPU build + test ------ | |
| cpu: | |
| needs: lint | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # clang-17 temporarily dropped: its OpenMP runtime isn't discoverable | |
| # with the stock noble libomp on the runner (see issue). gcc-13 with | |
| # sanitizers is the supported CI compiler. Re-add clang once fixed. | |
| compiler: | |
| - { cc: gcc-13, cxx: g++-13 } | |
| 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@v6 | |
| - 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@v5 | |
| 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@v7 | |
| 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@v6 | |
| - name: Install CUDA toolkit | |
| uses: Jimver/cuda-toolkit@v0.2.35 | |
| 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 | |
| # ------------------------------------------- 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@v6 | |
| - name: Build + run CUDA tests and balance benchmark | |
| run: | | |
| make -C cuda ARCH=sm_86 | |
| ./cuda/test | |
| ./cuda/bench |