Skip to content

[pre-commit.ci] pre-commit autoupdate #663

[pre-commit.ci] pre-commit autoupdate

[pre-commit.ci] pre-commit autoupdate #663

Workflow file for this run

---
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.8
- 3.9
- '3.10'
- '3.11'
- '3.12'
exclude:
# macos-latest is now running on M1 macs
- runs-on: macos-latest
python: 3.8
- runs-on: macos-latest
python: 3.9
- 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@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Save coverage report
if: matrix.python == '3.11' && runner.os == 'Linux'
uses: actions/upload-artifact@v3
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.8
- 3.9
- '3.10'
- '3.11'
- '3.12'
exclude:
# macos-latest is now running on M1 macs
- runs-on: macos-latest
python: 3.8
- runs-on: macos-latest
python: 3.9
- 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: 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:
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 cppcheck ninja
if (!(Test-Path -Path $PROFILE)) {
New-Item -ItemType File -Path $PROFILE -Force
}
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
. $PROFILE
Get-Location
Write-Output "CMAKE_PREFIX_PATH=$env:PATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
python -m pip install pre-commit cpplint lizard
Get-Command @("python", "clang-format", "clang-tidy", "cppcheck", "cpplint", "lizard", "pre-commit")
- 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
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@v3
with:
name: coverage
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
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@v3
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'