Skip to content

Commit 0600f08

Browse files
committed
Switch to pre-commit workflow
1 parent e919996 commit 0600f08

File tree

14 files changed

+360
-302
lines changed

14 files changed

+360
-302
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3-
41
name: CI
52

63
on:
@@ -28,9 +25,30 @@ jobs:
2825
pip install poetry
2926
poetry export --with dev -f requirements.txt --output /tmp/requirements.txt
3027
pip install -r /tmp/requirements.txt
31-
- name: Lint
32-
run: |
33-
source scripts/lint.sh
3428
- name: Test
3529
run: |
3630
source scripts/test.sh
31+
pre-commit:
32+
name: "pre-commit"
33+
runs-on: ubuntu-latest
34+
timeout-minutes: 10
35+
steps:
36+
- name: Checkout the repository
37+
uses: actions/checkout@v4
38+
- uses: actions/setup-python@v5
39+
- name: "Install pre-commit"
40+
run: python -m pip install pre-commit
41+
- name: "Cache pre-commit"
42+
uses: actions/cache@v4
43+
with:
44+
path: ~/.cache/pre-commit
45+
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
46+
- name: "Run pre-commit"
47+
run: |
48+
echo '```console' > "$GITHUB_STEP_SUMMARY"
49+
# Enable colour output for pre-commit and remove it for the summary.
50+
pre-commit run --all-files --show-diff-on-failure --color=always | \
51+
tee >(sed -E 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})*)?[mGK]//g' >> "$GITHUB_STEP_SUMMARY") >&1
52+
exit_code="${PIPESTATUS[0]}"
53+
echo '```' >> "$GITHUB_STEP_SUMMARY"
54+
exit "$exit_code"

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ dmypy.json
6767
.idea/
6868

6969
# Ruff
70-
.ruff_cache/
70+
.ruff_cache/

.pre-commit-config.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.6.0
4+
hooks:
5+
- id: check-added-large-files
6+
- id: check-case-conflict
7+
- id: check-merge-conflict
8+
- id: check-symlinks
9+
- id: check-toml
10+
- id: check-vcs-permalinks
11+
- id: check-yaml
12+
- id: destroyed-symlinks
13+
- id: end-of-file-fixer
14+
- id: mixed-line-ending
15+
- id: trailing-whitespace
16+
- repo: https://github.com/astral-sh/ruff-pre-commit
17+
rev: v0.6.7
18+
hooks:
19+
- id: ruff-format
20+
- id: ruff
21+
args: [--fix, --exit-non-zero-on-fix]
22+
types_or: [python, pyi]
23+
require_serial: true
24+
- repo: https://github.com/abravalheri/validate-pyproject
25+
rev: v0.19
26+
hooks:
27+
- id: validate-pyproject
28+
- repo: https://github.com/jackdewinter/pymarkdown
29+
rev: v0.9.23
30+
hooks:
31+
- id: pymarkdown
32+
- repo: https://github.com/crate-ci/typos
33+
rev: v1.24.6
34+
hooks:
35+
- id: typos
36+
- repo: https://github.com/rhysd/actionlint
37+
rev: v1.7.2
38+
hooks:
39+
- id: actionlint
40+
- repo: https://github.com/sirwart/ripsecrets
41+
rev: v0.1.8
42+
hooks:
43+
- id: ripsecrets

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ Check e-book files for security and privacy issues.
77

88
## Motivation
99

10-
E-books are great, but the common file formats have security and privacy issues. Most use web browser technologies like HTML, CSS, and JavaScript. Therefore, e-books are vulnerable to security and privacy issues that already exist on the web.
10+
E-books are great, but the common file formats have security and privacy issues.
11+
Most use web browser technologies like HTML, CSS, and JavaScript. Therefore,
12+
e-books are vulnerable to security and privacy issues that already exist on the
13+
web.
1114

12-
Screener aims to check e-book files for these issues so that you can read with peace of mind!
15+
Screener aims to check e-book files for these issues so that you can read with
16+
peace of mind!
1317

1418
## Features
1519

@@ -25,15 +29,17 @@ Screener requires [Python](https://www.python.org/about/gettingstarted/).
2529

2630
### Installing
2731

28-
Screener is available on [PyPI](https://pypi.org/project/screener/). To install, run:
32+
Screener is available on [PyPI](https://pypi.org/project/screener/). To install,
33+
run
2934

3035
```bash
3136
pip install screener
3237
```
3338

3439
#### Development installation
3540

36-
To install Screener for development, ensure you have [Poetry](https://python-poetry.org/) clone the repository and run:
41+
To install Screener for development, ensure you have [Poetry](https://python-poetry.org/)
42+
clone the repository and run:
3743

3844
```bash
3945
poetry install
@@ -55,7 +61,9 @@ screener --help
5561

5662
## Contributing
5763

58-
Pull requests are welcome and appreciated. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.
64+
Pull requests are welcome and appreciated. For major changes, please open an
65+
issue first to discuss what you would like to change. Please make sure to update
66+
tests as appropriate.
5967

6068
If you have found a bug or have a feature request, please open an issue.
6169

0 commit comments

Comments
 (0)