Update pre-commit hook versions across configurations #18
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
| # Multi-OS dogfood: mb_pre_commit_setup() must configure + install the Git hook everywhere we care about. | |
| name: CI | |
| on: | |
| push: | |
| branches: [main, master] | |
| pull_request: | |
| workflow_dispatch: | |
| inputs: | |
| cmake_preset: | |
| description: Configure / build preset (see CMakePresets.json) | |
| type: choice | |
| options: | |
| - ci | |
| - default | |
| - release | |
| - dev-verbose | |
| default: ci | |
| run_workflow_preset: | |
| description: Also run cmake --workflow (dev | ship | ci) | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ci-${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| PYTHONUTF8: "1" | |
| PYTHONIOENCODING: utf-8 | |
| jobs: | |
| cmake: | |
| name: cmake · ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| defaults: | |
| run: | |
| shell: bash | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-24.04, windows-latest, macos-14] | |
| env: | |
| CMAKE_PRESET: >- | |
| ${{ | |
| github.event_name == 'workflow_dispatch' | |
| && github.event.inputs.cmake_preset | |
| || 'ci' | |
| }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Shipped example config matches repo root | |
| run: cmp -s configs/v4/.pre-commit-config.yaml .pre-commit-config.yaml | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.12" | |
| # Preset schema v10 requires CMake ≥ 4.0 (see CMakePresets.json). mb-pre-commit.cmake needs ≥ 3.21. | |
| - name: Install CMake and Ninja | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install "cmake>=4.0,<5" "ninja>=1.11" | |
| - name: Tool versions | |
| id: versions | |
| run: | | |
| cmake --version | |
| ninja --version | |
| python --version | |
| { | |
| echo "cmake<<EOF" | |
| cmake --version | head -n1 | |
| echo EOF | |
| echo "ninja<<EOF" | |
| ninja --version | |
| echo EOF | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Configure + build (preset) | |
| run: | | |
| cmake --preset "$CMAKE_PRESET" | |
| cmake --build --preset "$CMAKE_PRESET" | |
| - name: Sweep (pre-commit all files via CMake target) | |
| run: cmake --build --preset "$CMAKE_PRESET" --target mb-pre-commit-sweep | |
| - name: Optional workflow preset | |
| if: >- | |
| github.event_name == 'workflow_dispatch' | |
| && github.event.inputs.run_workflow_preset == 'true' | |
| run: | | |
| case "${{ github.event.inputs.cmake_preset }}" in | |
| ci) cmake --workflow --preset ci ;; | |
| default) cmake --workflow --preset dev ;; | |
| dev-verbose) cmake --workflow --preset dev ;; | |
| release) cmake --workflow --preset ship ;; | |
| *) cmake --workflow --preset ci ;; | |
| esac | |
| - name: Verify Git hook was installed | |
| run: | | |
| test -f .git/hooks/pre-commit | |
| if [[ "${{ runner.os }}" != "Windows" ]]; then | |
| test -x .git/hooks/pre-commit | |
| fi | |
| - name: Job summary | |
| if: success() | |
| run: | | |
| { | |
| echo "## CMake CI" | |
| echo "" | |
| echo "| | |" | |
| echo "|---|---|" | |
| echo "| **Runner** | \`${{ matrix.os }}\` |" | |
| echo "| **Preset** | \`$CMAKE_PRESET\` |" | |
| echo "| **CMake** | ${{ steps.versions.outputs.cmake }} |" | |
| echo "| **Ninja** | ${{ steps.versions.outputs.ninja }} |" | |
| echo "" | |
| echo "Hook present at \`.git/hooks/pre-commit\`." | |
| } >> "$GITHUB_STEP_SUMMARY" | |
| unix-makefiles-smoke: | |
| name: CMake (Ubuntu · Unix Makefiles) | |
| runs-on: ubuntu-24.04 | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Shipped example config matches repo root | |
| run: cmp -s configs/v4/.pre-commit-config.yaml .pre-commit-config.yaml | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.12" | |
| - name: Install CMake (no Ninja — exercise Makefiles preset) | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install "cmake>=4.0,<5" | |
| sudo apt-get update | |
| sudo apt-get install -y --no-install-recommends make | |
| - name: Configure + build | |
| run: | | |
| cmake --preset unix-makefiles | |
| cmake --build --preset unix-makefiles | |
| - name: Sweep (pre-commit all files) | |
| run: cmake --build --preset unix-makefiles --target mb-pre-commit-sweep |