[pre-commit.ci] pre-commit autoupdate #850
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: # yamllint disable-line rule:truthy | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| - develop | |
| - v* | |
| jobs: | |
| unit-tests: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| runs-on: [ubuntu-latest, windows-latest, macos-latest] | |
| python: | |
| - '3.10' | |
| - '3.11' | |
| - '3.12' | |
| - '3.13' | |
| exclude: | |
| # Python 3.10 has issues on macOS M1 runners (missing gettext/libintl) | |
| - runs-on: macos-latest | |
| python: '3.10' | |
| name: "Unit tests • ${{ matrix.python }} • ${{ matrix.runs-on }} • x64 ${{ matrix.args }}" | |
| runs-on: ${{ matrix.runs-on }} | |
| if: >- | |
| (github.event_name != 'pull_request' | |
| || (github.event_name == 'pull_request' && github.event.pull_request.merged != true)) | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get history and tags for SCM versioning to work | |
| run: | | |
| git fetch --prune --unshallow | |
| git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
| - name: Setup Python ${{ matrix.python }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| architecture: 'x64' | |
| cache: 'pip' | |
| cache-dependency-path: '**/pyproject.toml' | |
| - name: Prepare env | |
| run: python -m pip install -U pytest-github-actions-annotate-failures wheel build | |
| - name: Build and install package | |
| run: python -m pip install -e .[test] | |
| - name: Run Python tests | |
| run: python -m pytest -v --cov=cmake_pc_hooks --cov-report=xml --cov-report=term-missing --cov-branch | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Save coverage report | |
| if: matrix.python == '3.11' && runner.os == 'Linux' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage | |
| path: coverage.xml | |
| retention-days: 1 | |
| system-tests: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| runs-on: [ubuntu-latest, windows-latest, macos-latest] | |
| python: | |
| - '3.10' | |
| - '3.11' | |
| - '3.12' | |
| - '3.13' | |
| exclude: | |
| # Python 3.10 has issues on macOS M1 runners (missing gettext/libintl) | |
| - runs-on: macos-latest | |
| python: '3.10' | |
| name: "System tests ${{ matrix.python }} • ${{ matrix.runs-on }} • x64 ${{ matrix.args }}" | |
| runs-on: ${{ matrix.runs-on }} | |
| needs: unit-tests | |
| if: >- | |
| (github.event_name != 'pull_request' | |
| || (github.event_name == 'pull_request' && github.event.pull_request.merged != true)) | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get history and tags for SCM versioning to work | |
| run: | | |
| git fetch --prune --unshallow | |
| git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
| - name: Setup Python ${{ matrix.python }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| architecture: 'x64' | |
| cache: 'pip' | |
| cache-dependency-path: '**/pyproject.toml' | |
| - name: Prepare env | |
| run: python -m pip install -U pytest-github-actions-annotate-failures wheel build | |
| - name: Prepare env (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang clang-tidy cppcheck iwyu | |
| python -m pip install pytest-github-actions-annotate-failures pre-commit cpplint lizard | |
| - name: Prepare env (Mac OS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew install llvm cppcheck cpplint include-what-you-use pre-commit gnu-sed lizard-analyzer | |
| ln -s "$(brew --prefix llvm)/bin/clang-tidy" /usr/local/bin/clang-tidy | |
| # yamllint disable rule:line-length | |
| - name: Prepare env (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| choco install -y llvm ninja | |
| Import-Module "${ENV:ChocolateyInstall}\helpers\chocolateyProfile.psm1" | |
| Update-SessionEnvironment | |
| # Restore Python to PATH after Update-SessionEnvironment (it resets PATH from system) | |
| $env:PATH = "$env:pythonLocation;$env:pythonLocation\Scripts;$env:PATH" | |
| # Install cppcheck via pip (choco package is broken, pip wheel works correctly) | |
| python -m pip install pre-commit cpplint lizard cppcheck | |
| Get-Command @("python", "clang-format", "clang-tidy", "cppcheck", "cpplint", "lizard", "pre-commit") | |
| # Enable MSVC dev command AFTER chocolatey packages are installed to avoid | |
| # Update-SessionEnvironment overwriting MSVC environment variables | |
| - name: Enable Developer Command Prompt | |
| if: runner.os == 'Windows' | |
| uses: ilammy/msvc-dev-cmd@v1.13.0 | |
| # Restore Python to front of PATH after MSVC setup | |
| # (MSVC's vcvarsall.bat prepends paths including VS's bundled Python 3.9, | |
| # which conflicts with our Python 3.10+ requirement) | |
| - name: Restore Python PATH | |
| if: runner.os == 'Windows' | |
| run: | | |
| "$env:pythonLocation" >> $env:GITHUB_PATH | |
| "$env:pythonLocation\Scripts" >> $env:GITHUB_PATH | |
| # Ensure python3 also points to the correct Python (pre-commit looks for python3) | |
| if (-not (Test-Path "$env:pythonLocation\python3.exe")) { | |
| Copy-Item "$env:pythonLocation\python.exe" "$env:pythonLocation\python3.exe" | |
| } | |
| - name: Build and install package | |
| run: python -m pip install -e .[test] | |
| - name: Run test (Unix) | |
| if: runner.os != 'Windows' | |
| env: | |
| LOGLEVEL: DEBUG | |
| run: ./tests/run_tests.sh | |
| - name: Run test (Windows) | |
| if: runner.os == 'Windows' | |
| env: | |
| CC: cl | |
| CXX: cl | |
| LOGLEVEL: DEBUG | |
| # Use a fresh pre-commit cache to avoid Python version mismatch | |
| PRE_COMMIT_HOME: ${{ runner.temp }}/pre-commit-cache | |
| run: ./tests/run_tests.ps1 | |
| sonarcloud: | |
| name: SonarCloud | |
| runs-on: ubuntu-latest | |
| needs: unit-tests | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Fetch coverage report | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: coverage | |
| - name: SonarQube Scan | |
| uses: SonarSource/sonarqube-scan-action@v7 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| codacy: | |
| name: Codacy coverage | |
| runs-on: ubuntu-latest | |
| needs: unit-tests | |
| steps: | |
| - name: Fetch coverage report | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: coverage | |
| - name: Run codacy-coverage-reporter | |
| uses: codacy/codacy-coverage-reporter-action@v1 | |
| with: | |
| project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
| coverage-reports: coverage.xml | |
| finish: | |
| needs: [unit-tests, system-tests, sonarcloud, codacy] | |
| runs-on: ubuntu-latest | |
| name: Finish CI checks | |
| steps: | |
| - name: All tests pass | |
| run: echo 'OK' |