cmake-pre-commit-hooks 1.9.5__tar.gz → 1.10.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. cmake_pre_commit_hooks-1.10.0/.github/dependabot.yml +13 -0
  2. cmake_pre_commit_hooks-1.10.0/.github/scripts/pre_commit_fragments.py +47 -0
  3. cmake_pre_commit_hooks-1.10.0/.github/scripts/release_version.py +136 -0
  4. cmake_pre_commit_hooks-1.10.0/.github/workflows/ci.yml +263 -0
  5. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/.github/workflows/codeql-analysis.yml +4 -4
  6. cmake_pre_commit_hooks-1.10.0/.github/workflows/draft_release.yml +67 -0
  7. cmake_pre_commit_hooks-1.10.0/.github/workflows/format.yml +32 -0
  8. cmake_pre_commit_hooks-1.10.0/.github/workflows/publish_release.yml +138 -0
  9. cmake_pre_commit_hooks-1.10.0/.github/workflows/pull_request.yml +106 -0
  10. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/.gitignore +2 -0
  11. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/.pre-commit-config.yaml +14 -22
  12. cmake_pre_commit_hooks-1.10.0/AGENTS.md +24 -0
  13. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/CHANGELOG.md +101 -3
  14. cmake_pre_commit_hooks-1.10.0/CLAUDE.md +1 -0
  15. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/PKG-INFO +54 -7
  16. cmake_pre_commit_hooks-1.9.5/cmake_pre_commit_hooks.egg-info/PKG-INFO → cmake_pre_commit_hooks-1.10.0/README.md +45 -41
  17. cmake_pre_commit_hooks-1.10.0/changelog.d/README.md +42 -0
  18. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/cmake_pc_hooks/_argparse.py +42 -27
  19. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/cmake_pc_hooks/_call_process.py +6 -4
  20. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/cmake_pc_hooks/_cmake.py +287 -86
  21. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/cmake_pc_hooks/_utils.py +11 -11
  22. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/cmake_pc_hooks/clang_tidy.py +4 -3
  23. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/cmake_pc_hooks/cppcheck.py +5 -4
  24. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/cmake_pc_hooks/include_what_you_use.py +19 -6
  25. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/cmake_pc_hooks/lizard.py +8 -3
  26. cmake_pre_commit_hooks-1.9.5/README.md → cmake_pre_commit_hooks-1.10.0/cmake_pre_commit_hooks.egg-info/PKG-INFO +88 -1
  27. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/cmake_pre_commit_hooks.egg-info/SOURCES.txt +13 -7
  28. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/cmake_pre_commit_hooks.egg-info/requires.txt +1 -1
  29. cmake_pre_commit_hooks-1.10.0/cmake_pre_commit_hooks.egg-info/scm_file_list.json +66 -0
  30. cmake_pre_commit_hooks-1.10.0/pyproject.toml +282 -0
  31. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/setup.py +15 -7
  32. cmake_pre_commit_hooks-1.10.0/sonar-project.properties +30 -0
  33. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/tests/cmake_bad/CMakeLists.txt +1 -1
  34. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/tests/cmake_good/CMakeLists.txt +1 -1
  35. cmake_pre_commit_hooks-1.10.0/tests/integration/_integration.py +146 -0
  36. cmake_pre_commit_hooks-1.10.0/tests/integration/cmake_options_test.py +416 -0
  37. cmake_pre_commit_hooks-1.10.0/tests/integration/conftest.py +135 -0
  38. cmake_pre_commit_hooks-1.10.0/tests/integration/hooks_test.py +213 -0
  39. cmake_pre_commit_hooks-1.10.0/tests/integration/pre_commit_test.py +143 -0
  40. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/tests/python/_argparse_test.py +1 -1
  41. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/tests/python/_cmake_test.py +308 -78
  42. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/tests/python/_test_utils.py +3 -3
  43. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/tests/python/_utils_test.py +15 -1
  44. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/tests/python/clang_format_test.py +2 -2
  45. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/tests/python/clang_tidy_test.py +1 -1
  46. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/tests/python/conftest.py +8 -6
  47. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/tests/python/cppcheck_test.py +1 -1
  48. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/tests/python/cpplint_test.py +1 -1
  49. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/tests/python/iwyu_test.py +44 -0
  50. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/tests/python/lizard_test.py +39 -0
  51. cmake_pre_commit_hooks-1.10.0/tests/python/release_scripts_test.py +168 -0
  52. cmake_pre_commit_hooks-1.9.5/.github/dependabot.yml +0 -12
  53. cmake_pre_commit_hooks-1.9.5/.github/workflows/ci.yml +0 -210
  54. cmake_pre_commit_hooks-1.9.5/.github/workflows/draft_release.yml +0 -56
  55. cmake_pre_commit_hooks-1.9.5/.github/workflows/format.yml +0 -46
  56. cmake_pre_commit_hooks-1.9.5/.github/workflows/publish_release.yml +0 -114
  57. cmake_pre_commit_hooks-1.9.5/.github/workflows/pull_request.yml +0 -59
  58. cmake_pre_commit_hooks-1.9.5/pyproject.toml +0 -223
  59. cmake_pre_commit_hooks-1.9.5/sonar-project.properties +0 -10
  60. cmake_pre_commit_hooks-1.9.5/tests/cmake_bad/.pre-commit-config.yaml +0 -17
  61. cmake_pre_commit_hooks-1.9.5/tests/cmake_bad/.pre-commit-win.yaml +0 -15
  62. cmake_pre_commit_hooks-1.9.5/tests/cmake_good/.pre-commit-config.yaml +0 -17
  63. cmake_pre_commit_hooks-1.9.5/tests/cmake_good/.pre-commit-win.yaml +0 -15
  64. cmake_pre_commit_hooks-1.9.5/tests/run_tests.ps1 +0 -114
  65. cmake_pre_commit_hooks-1.9.5/tests/run_tests.sh +0 -121
  66. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/.codespell.allow +0 -0
  67. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/.editorconfig +0 -0
  68. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/.pre-commit-hooks.yaml +0 -0
  69. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/.sonarcloud.properties +0 -0
  70. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/.yamllint +0 -0
  71. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/LICENSE +0 -0
  72. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/MANIFEST.in +0 -0
  73. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/cmake_pc_hooks/__init__.py +0 -0
  74. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/cmake_pc_hooks/clang_format.py +0 -0
  75. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/cmake_pc_hooks/cpplint.py +0 -0
  76. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/cmake_pre_commit_hooks.egg-info/dependency_links.txt +0 -0
  77. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/cmake_pre_commit_hooks.egg-info/entry_points.txt +0 -0
  78. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/cmake_pre_commit_hooks.egg-info/top_level.txt +0 -0
  79. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/codecov.yml +0 -0
  80. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/environment.yml +0 -0
  81. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/misc/license_header.txt +0 -0
  82. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/setup.cfg +0 -0
  83. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/tests/cmake_bad/bad.cpp +0 -0
  84. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/tests/cmake_good/good.cpp +0 -0
  85. {cmake_pre_commit_hooks-1.9.5 → cmake_pre_commit_hooks-1.10.0}/tests/python/_call_process_test.py +0 -0
@@ -0,0 +1,13 @@
1
+ ---
2
+
3
+ version: 2
4
+ updates:
5
+ - package-ecosystem: "github-actions"
6
+ directory: "/"
7
+ schedule:
8
+ interval: "weekly"
9
+ # Gather all updates into a single pull request
10
+ groups:
11
+ github-actions:
12
+ patterns:
13
+ - "*"
@@ -0,0 +1,47 @@
1
+ # Copyright 2021 Damien Nguyen
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Create changelog fragments from the body of a pull request generated by pre-commit.ci."""
16
+
17
+ from __future__ import annotations
18
+
19
+ import os
20
+ import re
21
+ from pathlib import Path
22
+
23
+ FRAGMENTS_DIR = Path('changelog.d')
24
+
25
+ # Matches lines such as
26
+ # - [github.com/astral-sh/ruff-pre-commit: v0.4.7 → v0.17.5](https://github.com/...)
27
+ # - https://github.com/PyCQA/doc8/: v1.1.1 → v2.0.0
28
+ HOOK_UPDATE = re.compile(
29
+ r'^-\s+\[?(?:https?://)?[^/\s]+/(?P<name>[^\s:]+?)(?:\.git)?/?:\s+\S+\s+→\s+[vV]?(?P<version>[^\s\]]+)'
30
+ )
31
+
32
+
33
+ def main() -> None:
34
+ """Write one fragment per updated hook (a later update of the same hook overwrites the fragment)."""
35
+ for line in os.environ['PR_BODY'].splitlines():
36
+ match = HOOK_UPDATE.match(line.strip())
37
+ if not match:
38
+ continue
39
+ name, version = match['name'], match['version']
40
+ slug = re.sub(r'[^a-z0-9]+', '-', name.lower()).strip('-')
41
+ fragment = FRAGMENTS_DIR / f'+pre-commit-{slug}.repository.md'
42
+ fragment.write_text(f'Update `{name}` hook to v{version}\n', encoding='utf-8')
43
+ print(f'{fragment}: {name} -> v{version}')
44
+
45
+
46
+ if __name__ == '__main__':
47
+ main()
@@ -0,0 +1,136 @@
1
+ # Copyright 2021 Damien Nguyen
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Determine the version of the next release from the changelog fragments."""
16
+
17
+ # Usage: release_version.py [auto|scheduled|patch|minor|major|<version>]
18
+ #
19
+ # The version (without leading "v") is printed and written to the `version` output of the GitHub Actions step. Nothing
20
+ # is written if a scheduled run finds nothing worth releasing.
21
+
22
+ from __future__ import annotations
23
+
24
+ import os
25
+ import re
26
+ import subprocess
27
+ import sys
28
+ from pathlib import Path
29
+
30
+ FRAGMENTS_DIR = Path('changelog.d')
31
+ CHANGELOG = Path('CHANGELOG.md')
32
+
33
+ # Fragment types (see [tool.towncrier] in pyproject.toml) that users notice, and the version bump they call for
34
+ BUMPS = {
35
+ 'added': 'minor',
36
+ 'changed': 'minor',
37
+ 'deprecated': 'minor',
38
+ 'removed': 'minor',
39
+ 'fixed': 'patch',
40
+ 'security': 'patch',
41
+ }
42
+
43
+ VERSION = re.compile(r'\d+\.\d+\.\d+(-[0-9a-z.]+)?')
44
+
45
+
46
+ def fragment_types(directory: Path) -> set[str]:
47
+ """Return the types of the fragments found in a directory (`<name>.<type>.md` or `<name>.<type>.<n>.md`)."""
48
+ types = set()
49
+ for fragment in directory.glob('*.*.md'):
50
+ parts = fragment.name.split('.')
51
+ types.add(parts[-3] if parts[-2].isdigit() else parts[-2])
52
+ return types
53
+
54
+
55
+ def latest_version(changelog: str) -> tuple[int, int, int]:
56
+ """Return the latest stable version listed in a changelog."""
57
+ match = re.search(r'^## \[v?(\d+)\.(\d+)\.(\d+)\]', changelog, flags=re.MULTILINE)
58
+ if not match:
59
+ msg = 'unable to find the latest release in the changelog: please give an explicit version'
60
+ raise ValueError(msg)
61
+ major, minor, patch = (int(number) for number in match.groups())
62
+ return major, minor, patch
63
+
64
+
65
+ def next_version(request: str, types: set[str], latest: tuple[int, int, int]) -> str | None:
66
+ """Return the version to release, or None if a scheduled run has nothing worth releasing."""
67
+ # The request is `auto`, `scheduled`, `patch`, `minor`, `major` or an explicit version. The bump for `auto` and
68
+ # `scheduled` is deduced from the types of the changelog fragments waiting to be released, starting from the
69
+ # latest released version.
70
+ request = request.strip().lower()
71
+ scheduled = request == 'scheduled'
72
+
73
+ if not types:
74
+ if scheduled:
75
+ return None
76
+ msg = 'no changelog fragment: nothing to release'
77
+ raise ValueError(msg)
78
+
79
+ if request in {'auto', 'scheduled'}:
80
+ bumps = {BUMPS[kind] for kind in types if kind in BUMPS}
81
+ if scheduled and not bumps:
82
+ return None # only repository maintenance: not worth a release
83
+ request = 'minor' if 'minor' in bumps else 'patch'
84
+
85
+ major, minor, patch = latest
86
+ if request == 'major':
87
+ return f'{major + 1}.0.0'
88
+ if request == 'minor':
89
+ return f'{major}.{minor + 1}.0'
90
+ if request == 'patch':
91
+ return f'{major}.{minor}.{patch + 1}'
92
+
93
+ version = request.removeprefix('v')
94
+ if not VERSION.fullmatch(version):
95
+ msg = f"'{request}' is not valid: expected auto, patch, minor, major or a version such as v1.2.3 or v1.2.3-rc.1"
96
+ raise ValueError(msg)
97
+ return version
98
+
99
+
100
+ def tag_exists(tag: str) -> bool:
101
+ """Check whether a tag exists on the remote repository."""
102
+ result = subprocess.run(
103
+ ['git', 'ls-remote', '--exit-code', '--tags', 'origin', f'refs/tags/{tag}'], # ruff: ignore[start-process-with-partial-path]
104
+ capture_output=True,
105
+ check=False,
106
+ )
107
+ return result.returncode == 0
108
+
109
+
110
+ def main(argv: list[str]) -> int:
111
+ """Print the next version and pass it on to the following workflow steps."""
112
+ request = argv[1] if len(argv) > 1 else 'auto'
113
+ try:
114
+ version = next_version(
115
+ request, fragment_types(FRAGMENTS_DIR), latest_version(CHANGELOG.read_text(encoding='utf-8'))
116
+ )
117
+ if version and tag_exists(f'v{version}'):
118
+ msg = f'tag v{version} already exists'
119
+ raise ValueError(msg) # ruff: ignore[raise-within-try]
120
+ except ValueError as error:
121
+ print(f'::error::{error}')
122
+ return 1
123
+
124
+ if version is None:
125
+ print('::notice::No user-facing change waiting to be released')
126
+ return 0
127
+
128
+ print(f'Next release: v{version}')
129
+ if 'GITHUB_OUTPUT' in os.environ:
130
+ with Path(os.environ['GITHUB_OUTPUT']).open('a', encoding='utf-8') as output:
131
+ output.write(f'version={version}\n')
132
+ return 0
133
+
134
+
135
+ if __name__ == '__main__':
136
+ sys.exit(main(sys.argv))
@@ -0,0 +1,263 @@
1
+ ---
2
+
3
+ name: CI
4
+
5
+ on: # yamllint disable-line rule:truthy
6
+ pull_request:
7
+ push:
8
+ branches:
9
+ - main
10
+ - develop
11
+ - v*
12
+
13
+ permissions:
14
+ contents: read
15
+
16
+ concurrency:
17
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
18
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
19
+
20
+ jobs:
21
+ unit-tests:
22
+ strategy:
23
+ fail-fast: false
24
+ matrix:
25
+ runs-on: [ubuntu-latest, windows-latest, macos-latest]
26
+ python:
27
+ - '3.10'
28
+ - '3.11'
29
+ - '3.12'
30
+ - '3.13'
31
+ - '3.14'
32
+ - '3.15'
33
+ exclude:
34
+ # Python 3.10 has issues on macOS M1 runners (missing gettext/libintl)
35
+ - runs-on: macos-latest
36
+ python: '3.10'
37
+
38
+ name: "Unit tests • ${{ matrix.python }} • ${{ matrix.runs-on }} • x64"
39
+ runs-on: ${{ matrix.runs-on }}
40
+ if: >-
41
+ (github.event_name != 'pull_request'
42
+ || (github.event_name == 'pull_request' && github.event.pull_request.merged != true))
43
+
44
+ steps:
45
+ - uses: actions/checkout@v7
46
+ with:
47
+ fetch-depth: 0 # full history and tags for SCM versioning to work
48
+
49
+ - name: Setup Python ${{ matrix.python }}
50
+ uses: actions/setup-python@v7
51
+ with:
52
+ python-version: ${{ matrix.python }}
53
+ architecture: 'x64'
54
+ cache: 'pip'
55
+ cache-dependency-path: '**/pyproject.toml'
56
+
57
+ - name: Prepare env
58
+ run: python -m pip install -U pytest-github-actions-annotate-failures wheel build
59
+
60
+ - name: Build and install package
61
+ run: python -m pip install -e .[test]
62
+
63
+ - name: Run Python tests
64
+ run: python -m pytest -v --cov=cmake_pc_hooks --cov-report=xml --cov-report=term-missing --cov-branch
65
+
66
+ - name: Upload coverage reports to Codecov
67
+ uses: codecov/codecov-action@v7
68
+ with:
69
+ token: ${{ secrets.CODECOV_TOKEN }}
70
+
71
+ - name: Save coverage report
72
+ if: matrix.python == '3.11' && runner.os == 'Linux'
73
+ uses: actions/upload-artifact@v7
74
+ with:
75
+ name: coverage
76
+ path: coverage.xml
77
+ retention-days: 1
78
+
79
+ system-tests:
80
+ strategy:
81
+ fail-fast: false
82
+ matrix:
83
+ runs-on: [ubuntu-latest, windows-latest, macos-latest]
84
+ python:
85
+ - '3.10'
86
+ - '3.11'
87
+ - '3.12'
88
+ - '3.13'
89
+ - '3.14'
90
+ - '3.15'
91
+ exclude:
92
+ # Python 3.10 has issues on macOS M1 runners (missing gettext/libintl)
93
+ - runs-on: macos-latest
94
+ python: '3.10'
95
+
96
+ name: "System tests ${{ matrix.python }} • ${{ matrix.runs-on }} • x64"
97
+ runs-on: ${{ matrix.runs-on }}
98
+ needs: unit-tests
99
+ if: >-
100
+ (github.event_name != 'pull_request'
101
+ || (github.event_name == 'pull_request' && github.event.pull_request.merged != true))
102
+
103
+ steps:
104
+ - uses: actions/checkout@v7
105
+ with:
106
+ fetch-depth: 0 # full history and tags for SCM versioning to work
107
+
108
+ - name: Setup Python ${{ matrix.python }}
109
+ uses: actions/setup-python@v7
110
+ with:
111
+ python-version: ${{ matrix.python }}
112
+ architecture: 'x64'
113
+ cache: 'pip'
114
+ cache-dependency-path: '**/pyproject.toml'
115
+
116
+ - name: Prepare env
117
+ run: python -m pip install -U pytest-github-actions-annotate-failures wheel build
118
+
119
+ - name: Prepare env (Linux)
120
+ if: runner.os == 'Linux'
121
+ run: |
122
+ sudo apt-get update
123
+ sudo apt-get install -y clang clang-tidy cppcheck iwyu
124
+ python -m pip install pytest-github-actions-annotate-failures pre-commit cpplint lizard
125
+
126
+ - name: Prepare env (Mac OS)
127
+ if: runner.os == 'macOS'
128
+ run: |
129
+ brew install llvm cppcheck cpplint include-what-you-use pre-commit gnu-sed lizard-analyzer
130
+ ln -s "$(brew --prefix llvm)/bin/clang-tidy" /usr/local/bin/clang-tidy
131
+
132
+ # yamllint disable rule:line-length
133
+ - name: Prepare env (Windows)
134
+ if: runner.os == 'Windows'
135
+ run: |
136
+ choco install -y llvm ninja
137
+ Import-Module "${ENV:ChocolateyInstall}\helpers\chocolateyProfile.psm1"
138
+ Update-SessionEnvironment
139
+
140
+ # Restore Python to PATH after Update-SessionEnvironment (it resets PATH from system)
141
+ $env:PATH = "$env:pythonLocation;$env:pythonLocation\Scripts;$env:PATH"
142
+
143
+ # Install cppcheck via pip (choco package is broken, pip wheel works correctly)
144
+ python -m pip install pre-commit cpplint lizard cppcheck
145
+
146
+ Get-Command @("python", "clang-format", "clang-tidy", "cppcheck", "cpplint", "lizard", "pre-commit")
147
+
148
+ # Enable MSVC dev command AFTER chocolatey packages are installed to avoid
149
+ # Update-SessionEnvironment overwriting MSVC environment variables
150
+ - name: Enable Developer Command Prompt
151
+ if: runner.os == 'Windows'
152
+ uses: ilammy/msvc-dev-cmd@v1
153
+
154
+ # Restore Python to front of PATH after MSVC setup
155
+ # (MSVC's vcvarsall.bat prepends paths including VS's bundled Python 3.9,
156
+ # which conflicts with our Python 3.10+ requirement)
157
+ - name: Restore Python PATH
158
+ if: runner.os == 'Windows'
159
+ run: |
160
+ "$env:pythonLocation" >> $env:GITHUB_PATH
161
+ "$env:pythonLocation\Scripts" >> $env:GITHUB_PATH
162
+ # Ensure python3 also points to the correct Python (pre-commit looks for python3)
163
+ if (-not (Test-Path "$env:pythonLocation\python3.exe")) {
164
+ Copy-Item "$env:pythonLocation\python.exe" "$env:pythonLocation\python3.exe"
165
+ }
166
+
167
+ - name: Build and install package
168
+ run: python -m pip install -e .[test]
169
+
170
+ # NB: tests requiring a tool that is not listed in --required-tools are skipped if that tool cannot be found
171
+ - name: Run integration tests (Unix)
172
+ if: runner.os != 'Windows'
173
+ env:
174
+ LOGLEVEL: DEBUG
175
+ run: python -m pytest tests/integration -v -ra -n auto --required-tools=all
176
+
177
+ - name: Run integration tests (Windows)
178
+ if: runner.os == 'Windows'
179
+ env:
180
+ CC: cl
181
+ CXX: cl
182
+ LOGLEVEL: DEBUG
183
+ run: >-
184
+ python -m pytest tests/integration -v -ra -n auto
185
+ --required-tools=clang-format,clang-tidy,cppcheck,cpplint,lizard,cmake,git,pre-commit
186
+
187
+ # NB: secrets are not available for pull requests coming from Dependabot or from forks. In those cases the
188
+ # coverage upload jobs below skip their steps instead of failing.
189
+ sonarcloud:
190
+ name: SonarCloud
191
+ runs-on: ubuntu-latest
192
+ needs: unit-tests
193
+ permissions:
194
+ contents: read
195
+ pull-requests: read
196
+ env:
197
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
198
+ steps:
199
+ - name: Check for SonarCloud token
200
+ if: env.SONAR_TOKEN == ''
201
+ run: echo "::notice::SONAR_TOKEN is not available (Dependabot or fork pull request); skipping SonarCloud scan"
202
+
203
+ - uses: actions/checkout@v7
204
+ if: env.SONAR_TOKEN != ''
205
+ with:
206
+ fetch-depth: 0
207
+
208
+ - name: Fetch coverage report
209
+ if: env.SONAR_TOKEN != ''
210
+ uses: actions/download-artifact@v8
211
+ with:
212
+ name: coverage
213
+
214
+ - name: SonarQube Scan
215
+ if: env.SONAR_TOKEN != ''
216
+ uses: SonarSource/sonarqube-scan-action@v8
217
+ env:
218
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
219
+
220
+ codacy:
221
+ name: Codacy coverage
222
+ runs-on: ubuntu-latest
223
+ needs: unit-tests
224
+ env:
225
+ CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
226
+ steps:
227
+ - name: Check for Codacy token
228
+ if: env.CODACY_PROJECT_TOKEN == ''
229
+ run: echo "::notice::CODACY_PROJECT_TOKEN is not available (Dependabot or fork pull request); skipping upload"
230
+
231
+ - name: Fetch coverage report
232
+ if: env.CODACY_PROJECT_TOKEN != ''
233
+ uses: actions/download-artifact@v8
234
+ with:
235
+ name: coverage
236
+
237
+ - name: Run codacy-coverage-reporter
238
+ if: env.CODACY_PROJECT_TOKEN != ''
239
+ uses: codacy/codacy-coverage-reporter-action@v1
240
+ with:
241
+ project-token: ${{ env.CODACY_PROJECT_TOKEN }}
242
+ coverage-reports: coverage.xml
243
+
244
+ finish:
245
+ needs: [unit-tests, system-tests, sonarcloud, codacy]
246
+ runs-on: ubuntu-latest
247
+ name: Finish CI checks
248
+ # Run even if a dependency failed so that this job fails instead of being skipped (a skipped required check counts
249
+ # as passing), but not when the run was cancelled, e.g. when superseded by a newer commit
250
+ if: ${{ !cancelled() }}
251
+ steps:
252
+ - name: All tests pass
253
+ env:
254
+ NEEDS_RESULTS: ${{ join(needs.*.result, ' ') }}
255
+ run: |
256
+ echo "Job results: ${NEEDS_RESULTS}"
257
+ for result in ${NEEDS_RESULTS}; do
258
+ if [[ "${result}" != "success" ]]; then
259
+ echo "::error::At least one required job did not succeed"
260
+ exit 1
261
+ fi
262
+ done
263
+ echo 'OK'
@@ -38,11 +38,11 @@ jobs:
38
38
 
39
39
  steps:
40
40
  - name: Checkout repository
41
- uses: actions/checkout@v3
41
+ uses: actions/checkout@v7
42
42
 
43
43
  # Initializes the CodeQL tools for scanning.
44
44
  - name: Initialize CodeQL
45
- uses: github/codeql-action/init@v2
45
+ uses: github/codeql-action/init@v4
46
46
  with:
47
47
  languages: ${{ matrix.language }}
48
48
  # If you wish to specify custom queries, you can do so here or in a config file.
@@ -51,7 +51,7 @@ jobs:
51
51
  # queries: ./path/to/local/query, your-org/your-repo/queries@main
52
52
 
53
53
  - name: Autobuild
54
- uses: github/codeql-action/autobuild@v2
54
+ uses: github/codeql-action/autobuild@v4
55
55
 
56
56
  - name: Perform CodeQL Analysis
57
- uses: github/codeql-action/analyze@v2
57
+ uses: github/codeql-action/analyze@v4
@@ -0,0 +1,67 @@
1
+ ---
2
+
3
+ name: "Draft new release"
4
+
5
+ on: # yamllint disable-line rule:truthy
6
+ workflow_dispatch:
7
+ inputs:
8
+ tag:
9
+ description: >-
10
+ Version to release: "auto" (deduced from the changelog fragments), "patch", "minor", "major"
11
+ or an explicit version such as v1.2.3
12
+ required: true
13
+ default: auto
14
+ schedule:
15
+ # Every Monday: open a release pull request if user-facing changes are waiting to be released
16
+ - cron: '23 5 * * 1'
17
+
18
+ permissions:
19
+ contents: write # required to push the release branch
20
+ pull-requests: write # required to open the release pull request
21
+
22
+ jobs:
23
+ new-release:
24
+ name: "Draft a new release"
25
+ runs-on: ubuntu-latest
26
+ steps:
27
+ - uses: actions/checkout@v7
28
+
29
+ - name: Setup Python
30
+ uses: actions/setup-python@v7
31
+ with:
32
+ python-version: '3.x'
33
+
34
+ # NB: sets no version if a scheduled run finds nothing worth releasing, which skips the next steps
35
+ - name: Determine release version
36
+ id: version
37
+ env:
38
+ REQUEST: ${{ github.event.inputs.tag || 'scheduled' }}
39
+ run: python3 .github/scripts/release_version.py "${REQUEST}"
40
+
41
+ - name: Collect the changelog fragments into CHANGELOG.md
42
+ if: steps.version.outputs.version
43
+ env:
44
+ VERSION: ${{ steps.version.outputs.version }}
45
+ run: |
46
+ python3 -m pip install towncrier mdformat-gfm
47
+ python3 -m towncrier build --yes --version "${VERSION}"
48
+ python3 -m mdformat CHANGELOG.md
49
+
50
+ # yamllint disable rule:line-length
51
+ - name: Create pull request
52
+ if: steps.version.outputs.version
53
+ uses: peter-evans/create-pull-request@v8
54
+ with:
55
+ branch: release/v${{ steps.version.outputs.version }}
56
+ base: main
57
+ commit-message: Preparing release v${{ steps.version.outputs.version }}
58
+ title: Release version v${{ steps.version.outputs.version }}
59
+ reviewers: ${{ github.event_name == 'schedule' && github.repository_owner || github.actor }}
60
+ body: |
61
+ This PR was created by the release workflow here: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}.
62
+
63
+ The changelog fragments of `changelog.d/` were collected into a new `v${{ steps.version.outputs.version }}` section of the CHANGELOG.
64
+ The package version itself is derived from the Git tag, so there is nothing else to update.
65
+
66
+ Merging this PR will build the package, upload it to PyPI and then create the `v${{ steps.version.outputs.version }}` tag and GitHub release.
67
+ Not the right time or the right version number? Close this PR and delete its branch.
@@ -0,0 +1,32 @@
1
+ ---
2
+
3
+ name: Format
4
+
5
+ on: # yamllint disable-line rule:truthy
6
+ pull_request:
7
+ push:
8
+ branches:
9
+ - main
10
+ - "v*"
11
+
12
+ jobs:
13
+ parse-changelog:
14
+ name: Parse CHANGELOG
15
+ runs-on: ubuntu-latest
16
+ if: >-
17
+ github.event_name == 'pull_request'
18
+ && (startsWith(github.event.pull_request.head.ref, 'release/')
19
+ || startsWith(github.event.pull_request.head.ref, 'hotfix/'))
20
+ steps:
21
+ - uses: actions/checkout@v7
22
+ - uses: taiki-e/install-action@v2
23
+ with:
24
+ tool: parse-changelog
25
+
26
+ - name: Check that the release notes can be extracted from the CHANGELOG
27
+ env:
28
+ BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
29
+ run: |
30
+ # CHANGELOG headings are parsed without the leading "v"
31
+ VERSION="${BRANCH_NAME##*/}"
32
+ parse-changelog CHANGELOG.md "${VERSION#v}"