cmake-pre-commit-hooks 1.9.6__tar.gz → 2.0.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 (110) hide show
  1. cmake_pre_commit_hooks-2.0.0/.codacy.yml +4 -0
  2. cmake_pre_commit_hooks-2.0.0/.github/dependabot.yml +13 -0
  3. cmake_pre_commit_hooks-2.0.0/.github/scripts/pre_commit_fragments.py +47 -0
  4. cmake_pre_commit_hooks-2.0.0/.github/scripts/release_version.py +143 -0
  5. cmake_pre_commit_hooks-2.0.0/.github/workflows/ci.yml +276 -0
  6. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/.github/workflows/codeql-analysis.yml +4 -4
  7. cmake_pre_commit_hooks-2.0.0/.github/workflows/draft_release.yml +67 -0
  8. cmake_pre_commit_hooks-2.0.0/.github/workflows/format.yml +32 -0
  9. cmake_pre_commit_hooks-2.0.0/.github/workflows/publish_release.yml +138 -0
  10. cmake_pre_commit_hooks-2.0.0/.github/workflows/pull_request.yml +106 -0
  11. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/.gitignore +2 -0
  12. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/.pre-commit-config.yaml +22 -29
  13. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/.pre-commit-hooks.yaml +18 -7
  14. cmake_pre_commit_hooks-2.0.0/AGENTS.md +24 -0
  15. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/CHANGELOG.md +115 -3
  16. cmake_pre_commit_hooks-2.0.0/CLAUDE.md +1 -0
  17. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/MANIFEST.in +1 -1
  18. {cmake_pre_commit_hooks-1.9.6/cmake_pre_commit_hooks.egg-info → cmake_pre_commit_hooks-2.0.0}/PKG-INFO +124 -22
  19. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/README.md +113 -14
  20. cmake_pre_commit_hooks-2.0.0/changelog.d/README.md +43 -0
  21. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/cmake_pc_hooks/_call_process.py +7 -5
  22. cmake_pre_commit_hooks-2.0.0/cmake_pc_hooks/_cli.py +133 -0
  23. cmake_pre_commit_hooks-1.9.6/cmake_pc_hooks/cpplint.py → cmake_pre_commit_hooks-2.0.0/cmake_pc_hooks/_cmake/__init__.py +5 -5
  24. cmake_pre_commit_hooks-2.0.0/cmake_pc_hooks/_cmake/configure.py +259 -0
  25. cmake_pre_commit_hooks-2.0.0/cmake_pc_hooks/_cmake/locate.py +138 -0
  26. cmake_pre_commit_hooks-2.0.0/cmake_pc_hooks/_cmake/options.py +174 -0
  27. cmake_pre_commit_hooks-2.0.0/cmake_pc_hooks/_cmake/trace.py +65 -0
  28. cmake_pre_commit_hooks-2.0.0/cmake_pc_hooks/_config.py +127 -0
  29. cmake_pre_commit_hooks-2.0.0/cmake_pc_hooks/_hook.py +82 -0
  30. cmake_pre_commit_hooks-2.0.0/cmake_pc_hooks/_runner.py +264 -0
  31. cmake_pre_commit_hooks-2.0.0/cmake_pc_hooks/clang_format.py +26 -0
  32. cmake_pre_commit_hooks-2.0.0/cmake_pc_hooks/clang_tidy.py +61 -0
  33. cmake_pre_commit_hooks-2.0.0/cmake_pc_hooks/cppcheck.py +61 -0
  34. cmake_pre_commit_hooks-2.0.0/cmake_pc_hooks/cpplint.py +32 -0
  35. cmake_pre_commit_hooks-2.0.0/cmake_pc_hooks/include_what_you_use.py +54 -0
  36. cmake_pre_commit_hooks-1.9.6/tests/python/cpplint_test.py → cmake_pre_commit_hooks-2.0.0/cmake_pc_hooks/lizard.py +12 -1
  37. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0/cmake_pre_commit_hooks.egg-info}/PKG-INFO +124 -22
  38. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/cmake_pre_commit_hooks.egg-info/SOURCES.txt +30 -13
  39. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/cmake_pre_commit_hooks.egg-info/requires.txt +5 -3
  40. cmake_pre_commit_hooks-2.0.0/cmake_pre_commit_hooks.egg-info/scm_file_list.json +77 -0
  41. cmake_pre_commit_hooks-2.0.0/pyproject.toml +287 -0
  42. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/setup.py +16 -8
  43. cmake_pre_commit_hooks-2.0.0/sonar-project.properties +30 -0
  44. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/tests/cmake_bad/CMakeLists.txt +1 -1
  45. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/tests/cmake_good/CMakeLists.txt +1 -1
  46. cmake_pre_commit_hooks-2.0.0/tests/integration/_integration.py +146 -0
  47. cmake_pre_commit_hooks-2.0.0/tests/integration/cmake_options_test.py +441 -0
  48. cmake_pre_commit_hooks-2.0.0/tests/integration/conftest.py +135 -0
  49. cmake_pre_commit_hooks-2.0.0/tests/integration/hooks_test.py +213 -0
  50. cmake_pre_commit_hooks-2.0.0/tests/integration/pre_commit_test.py +143 -0
  51. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/tests/python/_call_process_test.py +2 -2
  52. cmake_pre_commit_hooks-2.0.0/tests/python/_cli_test.py +192 -0
  53. cmake_pre_commit_hooks-2.0.0/tests/python/_cmake_configure_test.py +318 -0
  54. cmake_pre_commit_hooks-2.0.0/tests/python/_cmake_locate_test.py +108 -0
  55. cmake_pre_commit_hooks-2.0.0/tests/python/_cmake_options_test.py +203 -0
  56. cmake_pre_commit_hooks-2.0.0/tests/python/_cmake_trace_test.py +77 -0
  57. cmake_pre_commit_hooks-2.0.0/tests/python/_config_test.py +166 -0
  58. cmake_pre_commit_hooks-2.0.0/tests/python/_runner_test.py +571 -0
  59. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/tests/python/_test_utils.py +29 -44
  60. cmake_pre_commit_hooks-2.0.0/tests/python/clang_format_test.py +43 -0
  61. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/tests/python/clang_tidy_test.py +21 -24
  62. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/tests/python/conftest.py +21 -9
  63. cmake_pre_commit_hooks-2.0.0/tests/python/cppcheck_test.py +57 -0
  64. cmake_pre_commit_hooks-2.0.0/tests/python/cpplint_test.py +48 -0
  65. cmake_pre_commit_hooks-2.0.0/tests/python/iwyu_test.py +78 -0
  66. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/tests/python/lizard_test.py +7 -22
  67. cmake_pre_commit_hooks-2.0.0/tests/python/release_scripts_test.py +186 -0
  68. cmake_pre_commit_hooks-1.9.6/.github/dependabot.yml +0 -12
  69. cmake_pre_commit_hooks-1.9.6/.github/workflows/ci.yml +0 -227
  70. cmake_pre_commit_hooks-1.9.6/.github/workflows/draft_release.yml +0 -56
  71. cmake_pre_commit_hooks-1.9.6/.github/workflows/format.yml +0 -46
  72. cmake_pre_commit_hooks-1.9.6/.github/workflows/publish_release.yml +0 -114
  73. cmake_pre_commit_hooks-1.9.6/.github/workflows/pull_request.yml +0 -59
  74. cmake_pre_commit_hooks-1.9.6/cmake_pc_hooks/_argparse.py +0 -317
  75. cmake_pre_commit_hooks-1.9.6/cmake_pc_hooks/_cmake.py +0 -535
  76. cmake_pre_commit_hooks-1.9.6/cmake_pc_hooks/_utils.py +0 -242
  77. cmake_pre_commit_hooks-1.9.6/cmake_pc_hooks/clang_format.py +0 -59
  78. cmake_pre_commit_hooks-1.9.6/cmake_pc_hooks/clang_tidy.py +0 -81
  79. cmake_pre_commit_hooks-1.9.6/cmake_pc_hooks/cppcheck.py +0 -86
  80. cmake_pre_commit_hooks-1.9.6/cmake_pc_hooks/include_what_you_use.py +0 -128
  81. cmake_pre_commit_hooks-1.9.6/cmake_pc_hooks/lizard.py +0 -67
  82. cmake_pre_commit_hooks-1.9.6/pyproject.toml +0 -224
  83. cmake_pre_commit_hooks-1.9.6/sonar-project.properties +0 -10
  84. cmake_pre_commit_hooks-1.9.6/tests/cmake_bad/.pre-commit-config.yaml +0 -17
  85. cmake_pre_commit_hooks-1.9.6/tests/cmake_bad/.pre-commit-win.yaml +0 -15
  86. cmake_pre_commit_hooks-1.9.6/tests/cmake_good/.pre-commit-config.yaml +0 -17
  87. cmake_pre_commit_hooks-1.9.6/tests/cmake_good/.pre-commit-win.yaml +0 -15
  88. cmake_pre_commit_hooks-1.9.6/tests/python/_argparse_test.py +0 -390
  89. cmake_pre_commit_hooks-1.9.6/tests/python/_cmake_test.py +0 -498
  90. cmake_pre_commit_hooks-1.9.6/tests/python/_utils_test.py +0 -189
  91. cmake_pre_commit_hooks-1.9.6/tests/python/clang_format_test.py +0 -72
  92. cmake_pre_commit_hooks-1.9.6/tests/python/cppcheck_test.py +0 -66
  93. cmake_pre_commit_hooks-1.9.6/tests/python/iwyu_test.py +0 -100
  94. cmake_pre_commit_hooks-1.9.6/tests/run_tests.ps1 +0 -114
  95. cmake_pre_commit_hooks-1.9.6/tests/run_tests.sh +0 -121
  96. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/.codespell.allow +0 -0
  97. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/.editorconfig +0 -0
  98. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/.sonarcloud.properties +0 -0
  99. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/.yamllint +0 -0
  100. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/LICENSE +0 -0
  101. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/cmake_pc_hooks/__init__.py +0 -0
  102. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/cmake_pre_commit_hooks.egg-info/dependency_links.txt +0 -0
  103. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/cmake_pre_commit_hooks.egg-info/entry_points.txt +0 -0
  104. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/cmake_pre_commit_hooks.egg-info/top_level.txt +0 -0
  105. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/codecov.yml +0 -0
  106. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/environment.yml +0 -0
  107. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/misc/license_header.txt +0 -0
  108. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/setup.cfg +0 -0
  109. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/tests/cmake_bad/bad.cpp +0 -0
  110. {cmake_pre_commit_hooks-1.9.6 → cmake_pre_commit_hooks-2.0.0}/tests/cmake_good/good.cpp +0 -0
@@ -0,0 +1,4 @@
1
+ ---
2
+
3
+ exclude_paths:
4
+ - 'changelog.d/**'
@@ -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,143 @@
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
+ 'breaking': 'major',
36
+ 'added': 'minor',
37
+ 'changed': 'minor',
38
+ 'deprecated': 'minor',
39
+ 'removed': 'minor',
40
+ 'fixed': 'patch',
41
+ 'security': 'patch',
42
+ }
43
+
44
+ VERSION = re.compile(r'\d+\.\d+\.\d+(-[0-9a-z.]+)?')
45
+
46
+
47
+ def fragment_types(directory: Path) -> set[str]:
48
+ """Return the types of the fragments found in a directory (`<name>.<type>.md` or `<name>.<type>.<n>.md`)."""
49
+ types = set()
50
+ for fragment in directory.glob('*.*.md'):
51
+ parts = fragment.name.split('.')
52
+ types.add(parts[-3] if parts[-2].isdigit() else parts[-2])
53
+ return types
54
+
55
+
56
+ def latest_version(changelog: str) -> tuple[int, int, int]:
57
+ """Return the latest stable version listed in a changelog."""
58
+ match = re.search(r'^## \[v?(\d+)\.(\d+)\.(\d+)\]', changelog, flags=re.MULTILINE)
59
+ if not match:
60
+ msg = 'unable to find the latest release in the changelog: please give an explicit version'
61
+ raise ValueError(msg)
62
+ major, minor, patch = (int(number) for number in match.groups())
63
+ return major, minor, patch
64
+
65
+
66
+ def largest_bump(types: set[str]) -> str | None:
67
+ """Return the largest version bump that some fragment types call for, or None if they call for none."""
68
+ bumps = {BUMPS[kind] for kind in types if kind in BUMPS}
69
+ return next((bump for bump in ('major', 'minor', 'patch') if bump in bumps), None)
70
+
71
+
72
+ def next_version(request: str, types: set[str], latest: tuple[int, int, int]) -> str | None:
73
+ """Return the version to release, or None if a scheduled run has nothing worth releasing."""
74
+ # The request is `auto`, `scheduled`, `patch`, `minor`, `major` or an explicit version. The bump for `auto` and
75
+ # `scheduled` is deduced from the types of the changelog fragments waiting to be released, starting from the
76
+ # latest released version.
77
+ request = request.strip().lower()
78
+ scheduled = request == 'scheduled'
79
+
80
+ if not types:
81
+ if scheduled:
82
+ return None
83
+ msg = 'no changelog fragment: nothing to release'
84
+ raise ValueError(msg)
85
+
86
+ if request in {'auto', 'scheduled'}:
87
+ bump = largest_bump(types)
88
+ if scheduled and bump is None:
89
+ return None # only repository maintenance: not worth a release
90
+ request = bump or 'patch'
91
+
92
+ major, minor, patch = latest
93
+ if request == 'major':
94
+ return f'{major + 1}.0.0'
95
+ if request == 'minor':
96
+ return f'{major}.{minor + 1}.0'
97
+ if request == 'patch':
98
+ return f'{major}.{minor}.{patch + 1}'
99
+
100
+ version = request.removeprefix('v')
101
+ if not VERSION.fullmatch(version):
102
+ 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"
103
+ raise ValueError(msg)
104
+ return version
105
+
106
+
107
+ def tag_exists(tag: str) -> bool:
108
+ """Check whether a tag exists on the remote repository."""
109
+ result = subprocess.run(
110
+ ['git', 'ls-remote', '--exit-code', '--tags', 'origin', f'refs/tags/{tag}'], # ruff: ignore[start-process-with-partial-path]
111
+ capture_output=True,
112
+ check=False,
113
+ )
114
+ return result.returncode == 0
115
+
116
+
117
+ def main(argv: list[str]) -> int:
118
+ """Print the next version and pass it on to the following workflow steps."""
119
+ request = argv[1] if len(argv) > 1 else 'auto'
120
+ try:
121
+ version = next_version(
122
+ request, fragment_types(FRAGMENTS_DIR), latest_version(CHANGELOG.read_text(encoding='utf-8'))
123
+ )
124
+ if version and tag_exists(f'v{version}'):
125
+ msg = f'tag v{version} already exists'
126
+ raise ValueError(msg) # ruff: ignore[raise-within-try]
127
+ except ValueError as error:
128
+ print(f'::error::{error}')
129
+ return 1
130
+
131
+ if version is None:
132
+ print('::notice::No user-facing change waiting to be released')
133
+ return 0
134
+
135
+ print(f'Next release: v{version}')
136
+ if 'GITHUB_OUTPUT' in os.environ:
137
+ with Path(os.environ['GITHUB_OUTPUT']).open('a', encoding='utf-8') as output:
138
+ output.write(f'version={version}\n')
139
+ return 0
140
+
141
+
142
+ if __name__ == '__main__':
143
+ sys.exit(main(sys.argv))
@@ -0,0 +1,276 @@
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
+ id: windows-tests
179
+ if: runner.os == 'Windows'
180
+ continue-on-error: ${{ matrix.python == '3.10' }}
181
+ env:
182
+ CC: cl
183
+ CXX: cl
184
+ LOGLEVEL: DEBUG
185
+ run: >-
186
+ python -m pytest tests/integration -v -ra -n auto
187
+ --required-tools=clang-format,clang-tidy,cppcheck,cpplint,lizard,cmake,git,pre-commit
188
+
189
+ # Python 3.10 sometimes crashes at exit on Windows (issue #156)
190
+ - name: Retry failed integration tests (Windows, Python 3.10)
191
+ if: runner.os == 'Windows' && matrix.python == '3.10' && steps.windows-tests.outcome == 'failure'
192
+ env:
193
+ CC: cl
194
+ CXX: cl
195
+ LOGLEVEL: DEBUG
196
+ run: >-
197
+ python -m pytest tests/integration -v -ra -n auto --last-failed
198
+ --required-tools=clang-format,clang-tidy,cppcheck,cpplint,lizard,cmake,git,pre-commit
199
+
200
+ # NB: secrets are not available for pull requests coming from Dependabot or from forks. In those cases the
201
+ # coverage upload jobs below skip their steps instead of failing.
202
+ sonarcloud:
203
+ name: SonarCloud
204
+ runs-on: ubuntu-latest
205
+ needs: unit-tests
206
+ permissions:
207
+ contents: read
208
+ pull-requests: read
209
+ env:
210
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
211
+ steps:
212
+ - name: Check for SonarCloud token
213
+ if: env.SONAR_TOKEN == ''
214
+ run: echo "::notice::SONAR_TOKEN is not available (Dependabot or fork pull request); skipping SonarCloud scan"
215
+
216
+ - uses: actions/checkout@v7
217
+ if: env.SONAR_TOKEN != ''
218
+ with:
219
+ fetch-depth: 0
220
+
221
+ - name: Fetch coverage report
222
+ if: env.SONAR_TOKEN != ''
223
+ uses: actions/download-artifact@v8
224
+ with:
225
+ name: coverage
226
+
227
+ - name: SonarQube Scan
228
+ if: env.SONAR_TOKEN != ''
229
+ uses: SonarSource/sonarqube-scan-action@v8
230
+ env:
231
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
232
+
233
+ codacy:
234
+ name: Codacy coverage
235
+ runs-on: ubuntu-latest
236
+ needs: unit-tests
237
+ env:
238
+ CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
239
+ steps:
240
+ - name: Check for Codacy token
241
+ if: env.CODACY_PROJECT_TOKEN == ''
242
+ run: echo "::notice::CODACY_PROJECT_TOKEN is not available (Dependabot or fork pull request); skipping upload"
243
+
244
+ - name: Fetch coverage report
245
+ if: env.CODACY_PROJECT_TOKEN != ''
246
+ uses: actions/download-artifact@v8
247
+ with:
248
+ name: coverage
249
+
250
+ - name: Run codacy-coverage-reporter
251
+ if: env.CODACY_PROJECT_TOKEN != ''
252
+ uses: codacy/codacy-coverage-reporter-action@v1
253
+ with:
254
+ project-token: ${{ env.CODACY_PROJECT_TOKEN }}
255
+ coverage-reports: coverage.xml
256
+
257
+ finish:
258
+ needs: [unit-tests, system-tests, sonarcloud, codacy]
259
+ runs-on: ubuntu-latest
260
+ name: Finish CI checks
261
+ # Run even if a dependency failed so that this job fails instead of being skipped (a skipped required check counts
262
+ # as passing), but not when the run was cancelled, e.g. when superseded by a newer commit
263
+ if: ${{ !cancelled() }}
264
+ steps:
265
+ - name: All tests pass
266
+ env:
267
+ NEEDS_RESULTS: ${{ join(needs.*.result, ' ') }}
268
+ run: |
269
+ echo "Job results: ${NEEDS_RESULTS}"
270
+ for result in ${NEEDS_RESULTS}; do
271
+ if [[ "${result}" != "success" ]]; then
272
+ echo "::error::At least one required job did not succeed"
273
+ exit 1
274
+ fi
275
+ done
276
+ echo 'OK'
@@ -38,11 +38,11 @@ jobs:
38
38
 
39
39
  steps:
40
40
  - name: Checkout repository
41
- uses: actions/checkout@v4
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@v3
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@v3
54
+ uses: github/codeql-action/autobuild@v4
55
55
 
56
56
  - name: Perform CodeQL Analysis
57
- uses: github/codeql-action/analyze@v3
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}"