Skip to content

Commit 2ad3c44

Browse files
authored
Repository maintenance (#123)
* Update GitHub action versions * Update pre-commit hooks * Update pre-commit config for ruff * Fix pre-commit issues
1 parent 098b0f6 commit 2ad3c44

File tree

15 files changed

+244
-162
lines changed

15 files changed

+244
-162
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ jobs:
6363
run: python -m pytest -v --cov=cmake_pc_hooks --cov-report=xml --cov-report=term-missing --cov-branch
6464

6565
- name: Upload coverage reports to Codecov
66-
uses: codecov/codecov-action@v4
66+
uses: codecov/codecov-action@v5
6767
with:
6868
token: ${{ secrets.CODECOV_TOKEN }}
6969

7070
- name: Save coverage report
7171
if: matrix.python == '3.11' && runner.os == 'Linux'
72-
uses: actions/upload-artifact@v3
72+
uses: actions/upload-artifact@v4
7373
with:
7474
name: coverage
7575
path: coverage.xml
@@ -192,12 +192,12 @@ jobs:
192192
fetch-depth: 0
193193

194194
- name: Fetch coverage report
195-
uses: actions/download-artifact@v3
195+
uses: actions/download-artifact@v4
196196
with:
197197
name: coverage
198198

199-
- name: SonarCloud Scan
200-
uses: SonarSource/sonarcloud-github-action@master
199+
- name: SonarQube Scan
200+
uses: SonarSource/sonarqube-scan-action@v5
201201
env:
202202
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
203203
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
@@ -208,7 +208,7 @@ jobs:
208208
needs: unit-tests
209209
steps:
210210
- name: Fetch coverage report
211-
uses: actions/download-artifact@v3
211+
uses: actions/download-artifact@v4
212212
with:
213213
name: coverage
214214

.pre-commit-config.yaml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ repos:
66
- id: check-useless-excludes
77

88
- repo: https://github.com/pre-commit/pre-commit-hooks
9-
rev: v4.6.0
9+
rev: v6.0.0
1010
hooks:
1111
- id: check-added-large-files
1212
- id: check-case-conflict
@@ -25,46 +25,45 @@ repos:
2525
- id: remove-tabs
2626

2727
- repo: https://github.com/PyCQA/doc8/
28-
rev: v1.1.1
28+
rev: v2.0.0
2929
hooks:
3030
- id: doc8
3131
require_serial: false
3232
additional_dependencies: [tomli]
3333

3434
- repo: https://github.com/codespell-project/codespell
35-
rev: v2.3.0
35+
rev: v2.4.1
3636
hooks:
3737
- id: codespell
3838
files: .*\.(py|txt|cmake|md|rst|sh|ps1|hpp|tpp|cpp|cc)$
3939
args: [-I, .codespell.allow]
4040

4141
- repo: https://github.com/shellcheck-py/shellcheck-py
42-
rev: v0.10.0.1
42+
rev: v0.11.0.1
4343
hooks:
4444
- id: shellcheck
4545
require_serial: false
4646
args: [-x, --severity=info]
4747

4848
- repo: https://github.com/adrienverge/yamllint.git
49-
rev: v1.35.1
49+
rev: v1.37.1
5050
hooks:
5151
- id: yamllint
5252

5353
- repo: https://github.com/asottile/blacken-docs
54-
rev: 1.16.0
54+
rev: 1.19.1
5555
hooks:
5656
- id: blacken-docs
5757
args: [-S, -l, '120']
5858
additional_dependencies: [black==22.12.0]
5959

6060
- repo: https://github.com/astral-sh/ruff-pre-commit
61-
rev: v0.4.7
61+
rev: v0.12.9
6262
hooks:
6363
- id: ruff-format
6464
name: ruff (format)
65-
args: [--preview]
6665

67-
- id: ruff
66+
- id: ruff-check
6867
name: ruff (fix)
6968
alias: ruff-fix
7069
args:

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Repository
1111

1212
- Clarify where to put the settings in `pyproject.toml`
13+
- Update GitHub Action `actions/download-artifact` to v4
14+
- Update GitHub Action `actions/upload-artifact` to v4
15+
- Update GitHub Action `codecov/codecov-action` from v4 to v5
16+
- Use GitHub Action `SonarSource/sonarqube-scan-action` v5
17+
- Update `github.com/pre-commit/pre-commit-hooks` hook to v6.0.0
18+
- Update `https://github.com/PyCQA/doc8/` hook to v2.0.0
19+
- Update `github.com/codespell-project/codespell` hook to v2.4.1
20+
- Update `github.com/shellcheck-py/shellcheck-py` hook to v0.11.0.1
21+
- Update `github.com/adrienverge/yamllint.git` hook to v1.37.1
22+
- Update `github.com/asottile/blacken-docs` hook to 1.19.1
23+
- Update `github.com/astral-sh/ruff-pre-commit` hook to v0.12.9
1324

1425
## [v1.9.6] - 2024-06-02
1526

cmake_pc_hooks/_argparse.py

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
import toml
2727

28+
log = logging.getLogger(__name__)
29+
2830
# ==============================================================================
2931

3032

@@ -110,7 +112,11 @@ def executable_path(path: str) -> Path:
110112

111113

112114
def _load_data_from_toml(
113-
path: Path, section: str, *, path_must_exist: bool = True, section_must_exist: bool = True
115+
path: Path,
116+
section: str,
117+
*,
118+
path_must_exist: bool = True,
119+
section_must_exist: bool = True,
114120
) -> dict:
115121
"""
116122
Load a TOML file and return the corresponding config dictionary.
@@ -127,23 +133,23 @@ def _load_data_from_toml(
127133
section_must_exist: Whether a missing section in the TOML file is considered an error or not
128134
"""
129135
try:
130-
with path.open(mode='r') as fd:
136+
with path.open(mode='r', encoding='utf-8') as fd:
131137
config = toml.load(fd)
132138
if section:
133139
for sub_section in section.split('.'):
134140
config = config[sub_section]
135-
logging.debug('Loading data from %s table of %s', section, path)
141+
log.debug('Loading data from %s table of %s', section, path)
136142
else:
137143
config = {key: value for key, value in config.items() if not isinstance(value, dict)}
138-
logging.debug('Loading data from root table of %s', path)
144+
log.debug('Loading data from root table of %s', path)
139145
except FileNotFoundError as err:
140146
if path_must_exist:
141147
raise TOMLFileNotFoundError(path) from err
142-
logging.debug('TOML file %s does not exist (not an error)', str(path))
148+
log.debug('TOML file %s does not exist (not an error)', str(path))
143149
except KeyError as err:
144150
if section_must_exist:
145151
raise TOMLSectionKeyError(section, path) from err
146-
logging.debug('TOML file %s does not have a %s section (not an error)', str(path), section)
152+
log.debug('TOML file %s does not have a %s section (not an error)', str(path), section)
147153
else:
148154
return config
149155
return {}
@@ -245,7 +251,9 @@ def parse_known_args(
245251

246252
if self._default_config_name is not None:
247253
namespace = self._load_from_toml(
248-
namespace=namespace, path=Path(self._default_config_name), path_must_exist=False
254+
namespace=namespace,
255+
path=Path(self._default_config_name),
256+
path_must_exist=False,
249257
)
250258

251259
namespace, args = super().parse_known_args(args=args, namespace=namespace)
@@ -265,11 +273,13 @@ def parse_known_args(
265273
if namespace.dump_toml:
266274
exclude_keys = {'positionals', 'dump_toml'}
267275
print(
268-
toml.dumps({
269-
key: value
270-
for key, value in vars(namespace).items()
271-
if value != self._default_args[key] and key not in exclude_keys
272-
})
276+
toml.dumps(
277+
{
278+
key: value
279+
for key, value in vars(namespace).items()
280+
if value != self._default_args[key] and key not in exclude_keys
281+
}
282+
)
273283
)
274284
sys.exit(0)
275285

@@ -297,7 +307,10 @@ def _load_from_toml( # noqa: PLR0913
297307
overridable_keys: List of keys that can be overridden by values in the TOML file
298308
"""
299309
config = _load_data_from_toml(
300-
path, section, path_must_exist=path_must_exist, section_must_exist=section_must_exist
310+
path,
311+
section,
312+
path_must_exist=path_must_exist,
313+
section_must_exist=section_must_exist,
301314
)
302315

303316
for key, value in config.items():
@@ -309,9 +322,9 @@ def _load_from_toml( # noqa: PLR0913
309322
if default_value is not None and not isinstance(value, type(default_value)):
310323
raise TOMLTypeError(type(value), type(default_value), key)
311324
if overridable_keys is not None and key not in overridable_keys:
312-
logging.debug(' skipping non-overridable key: "%s"', key)
325+
log.debug(' skipping non-overridable key: "%s"', key)
313326
continue
314327

315-
logging.debug(' setting %s = %s', key, value)
328+
log.debug(' setting %s = %s', key, value)
316329
setattr(namespace, key, value)
317330
return namespace

cmake_pc_hooks/_call_process.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
import attrs
2424

25+
log = logging.getLogger(__name__)
26+
2527

2628
@attrs.define(slots=True)
2729
class History: # pylint: disable=too-few-public-methods
@@ -64,9 +66,9 @@ def call_process(args: list, **kwargs: any) -> History:
6466
else:
6567
ret = History(sp_child.stdout.decode(), sp_child.stderr.decode(), sp_child.returncode)
6668

67-
logging.debug('command `%s` exited with %d', ' '.join(args), ret.returncode)
69+
log.debug('command `%s` exited with %d', ' '.join(args), ret.returncode)
6870
for line in ret.stdout.split('\n'):
69-
logging.debug('(stdout) %s', line)
71+
log.debug('(stdout) %s', line)
7072
for line in ret.stderr.split('\n'):
71-
logging.debug('(stderr) %s', line)
73+
log.debug('(stderr) %s', line)
7274
return ret

0 commit comments

Comments
 (0)