Skip to content

Commit d935014

Browse files
committed
Add pre-commit configuration and integration for REUSE.software.
pre-commit.com provides a way to configure pre-commit hooks for multiple tools, including `reuse lint` (configured here), isort, black, and more. In addition to `reuse lint`, enable basic whitespace management and YAML checks. Note that `black` is not usable with this repository because it cannot parse the template `.py` files. Use the pre-commit provided GitHub action as part of the CI, for ease of maintenance.
1 parent a8162b7 commit d935014

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

.github/workflows/pre-commit.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2019 Anthony Sottile
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
name: pre-commit
6+
7+
on:
8+
pull_request:
9+
push:
10+
branches: [master]
11+
12+
jobs:
13+
pre-commit:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v1
17+
- uses: actions/setup-python@v1
18+
- name: set PY
19+
run: echo "::set-env name=PY::$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')"
20+
- uses: actions/cache@v1
21+
with:
22+
path: ~/.cache/pre-commit
23+
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
24+
- uses: pre-commit/[email protected]

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# SPDX-FileCopyrightText: 2020 Diego Elio Pettenò
2+
#
3+
# SPDX-License-Identifier: Unlicense
4+
5+
repos:
6+
- repo: https://github.com/fsfe/reuse-tool
7+
rev: latest
8+
hooks:
9+
- id: reuse
10+
- repo: https://github.com/pre-commit/pre-commit-hooks
11+
rev: v2.3.0
12+
hooks:
13+
- id: check-yaml
14+
- id: end-of-file-fixer
15+
- id: trailing-whitespace

readthedocs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
# SPDX-License-Identifier: Unlicense
44

55
requirements_file: requirements.txt
6-

0 commit comments

Comments
 (0)