Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 33 additions & 37 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,14 @@ jobs:
matrix:
runs-on: [ubuntu-latest, windows-latest, macos-latest]
python:
- 3.8
- 3.9
- '3.10'
- '3.11'
- '3.12'
- '3.13'
exclude:
# macos-latest is now running on M1 macs
# Python 3.10 has issues on macOS M1 runners (missing gettext/libintl)
- runs-on: macos-latest
python: 3.8
- runs-on: macos-latest
python: 3.9
- runs-on: macos-latest
python: 3.10
python: '3.10'

name: "Unit tests • ${{ matrix.python }} • ${{ matrix.runs-on }} • x64 ${{ matrix.args }}"
runs-on: ${{ matrix.runs-on }}
Expand Down Expand Up @@ -81,19 +76,14 @@ jobs:
matrix:
runs-on: [ubuntu-latest, windows-latest, macos-latest]
python:
- 3.8
- 3.9
- '3.10'
- '3.11'
- '3.12'
- '3.13'
exclude:
# macos-latest is now running on M1 macs
- runs-on: macos-latest
python: 3.8
# Python 3.10 has issues on macOS M1 runners (missing gettext/libintl)
- runs-on: macos-latest
python: 3.9
- runs-on: macos-latest
python: 3.10
python: '3.10'

name: "System tests ${{ matrix.python }} • ${{ matrix.runs-on }} • x64 ${{ matrix.args }}"
runs-on: ${{ matrix.runs-on }}
Expand All @@ -110,10 +100,6 @@ jobs:
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- name: Enable Developer Command Prompt
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1.13.0

- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
Expand Down Expand Up @@ -142,28 +128,36 @@ jobs:
- name: Prepare env (Windows)
if: runner.os == 'Windows'
run: |
choco install -y llvm cppcheck ninja
if (!(Test-Path -Path $PROFILE)) {
New-Item -ItemType File -Path $PROFILE -Force
}
choco install -y llvm ninja
Import-Module "${ENV:ChocolateyInstall}\helpers\chocolateyProfile.psm1"
Update-SessionEnvironment

Write-Output 'Import-Module "${ENV:ChocolateyInstall}\helpers\chocolateyProfile.psm1"' | Out-File -FilePath $PROFILE -Append -Encoding utf8
Write-Output 'Update-SessionEnvironment' | Out-File -FilePath $PROFILE -Append -Encoding utf8
Write-Output '$id = vswhere -property instanceId' | Out-File -FilePath $PROFILE -Append -Encoding utf8
Write-Output 'Import-Module "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"' `
| Out-File -FilePath $PROFILE -Append -Encoding utf8
Write-Output 'Enter-VsDevShell -InstanceId $id' | Out-File -FilePath $PROFILE -Append -Encoding utf8
Write-Output 'Set-Location -Path "${ENV:GITHUB_WORKSPACE}"' | Out-File -FilePath $PROFILE -Append -Encoding utf8
Get-Content -Path $PROFILE
# Restore Python to PATH after Update-SessionEnvironment (it resets PATH from system)
$env:PATH = "$env:pythonLocation;$env:pythonLocation\Scripts;$env:PATH"

. $PROFILE
Get-Location
# Install cppcheck via pip (choco package is broken, pip wheel works correctly)
python -m pip install pre-commit cpplint lizard cppcheck

Write-Output "CMAKE_PREFIX_PATH=$env:PATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Get-Command @("python", "clang-format", "clang-tidy", "cppcheck", "cpplint", "lizard", "pre-commit")

python -m pip install pre-commit cpplint lizard
# 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

Get-Command @("python", "clang-format", "clang-tidy", "cppcheck", "cpplint", "lizard", "pre-commit")
# 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]
Expand All @@ -180,6 +174,8 @@ jobs:
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:
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Drop support for Python 3.8 and 3.9 (end-of-life)
- Add support for Python 3.13
- Minimum required Python version is now 3.10

### Fixed

- Fixed PowerShell system test script using `$?` instead of `$LASTEXITCODE` for exit code handling

### Repository

- Fixed Windows CI by using pip to install cppcheck (Chocolatey package is broken)

- Clarify where to put the settings in `pyproject.toml`
- Update GitHub Action `actions/download-artifact` to v4
- Update GitHub Action `actions/upload-artifact` to v4
Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ authors = [
]
description = 'pre-commit hooks for CMake-based projects'
readme = 'README.md'
requires-python = '>=3.8'
requires-python = '>=3.10'
keywords = [
]
license = {text = 'Apache2'}
classifiers = [
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
]
dependencies = [
'toml',
Expand Down Expand Up @@ -66,7 +65,7 @@ namespaces = false

[tool.ruff]
line-length = 120
target-version = 'py38'
target-version = 'py310'

[tool.ruff.lint]

Expand Down
10 changes: 5 additions & 5 deletions tests/run_tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ cp .pre-commit-win.yaml .pre-commit-win.yaml.bak
git add *.txt *.cpp .pre-commit*.yaml
git commit -m 'Initial commit'
pre-commit run -c .pre-commit-win.yaml --all-files
$ret=$?
$ret=$LASTEXITCODE
mv -Force .pre-commit-win.yaml.bak .pre-commit-win.yaml
rm -Force -Recurse .git
if ($ret -eq 0) {
echo "Pre-commit on tests/cmake_good failed!"
if ($ret -ne 0) {
echo "Pre-commit on tests/cmake_good failed with exit code $ret!"
Exit 1
}
cd ../..
Expand All @@ -102,10 +102,10 @@ cp .pre-commit-win.yaml .pre-commit-win.yaml.bak
git add *.txt *.cpp .pre-commit*.yaml
git commit -m 'Initial commit'
pre-commit run -c .pre-commit-win.yaml --all-files
$ret=$?
$ret=$LASTEXITCODE
mv -Force .pre-commit-win.yaml.bak .pre-commit-win.yaml
rm -Force -Recurse .git
if ($ret -eq 1) {
if ($ret -eq 0) {
echo "Pre-commit on tests/cmake_bad unexpectedly passed!"
Exit 1
}
Expand Down
Loading