Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to pre-commit workflow #132

Merged
merged 1 commit into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: CI

on:
Expand Down Expand Up @@ -28,9 +25,30 @@ jobs:
pip install poetry
poetry export --with dev -f requirements.txt --output /tmp/requirements.txt
pip install -r /tmp/requirements.txt
- name: Lint
run: |
source scripts/lint.sh
- name: Test
run: |
source scripts/test.sh
pre-commit:
name: "pre-commit"
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: "Install pre-commit"
run: python -m pip install pre-commit
- name: "Cache pre-commit"
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: "Run pre-commit"
run: |
echo '```console' > "$GITHUB_STEP_SUMMARY"
# Enable colour output for pre-commit and remove it for the summary.
pre-commit run --all-files --show-diff-on-failure --color=always | \
tee >(sed -E 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})*)?[mGK]//g' >> "$GITHUB_STEP_SUMMARY") >&1
exit_code="${PIPESTATUS[0]}"
echo '```' >> "$GITHUB_STEP_SUMMARY"
exit "$exit_code"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ dmypy.json
.idea/

# Ruff
.ruff_cache/
.ruff_cache/
43 changes: 43 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-vcs-permalinks
- id: check-yaml
- id: destroyed-symlinks
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.7
hooks:
- id: ruff-format
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
types_or: [python, pyi]
require_serial: true
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.19
hooks:
- id: validate-pyproject
- repo: https://github.com/jackdewinter/pymarkdown
rev: v0.9.23
hooks:
- id: pymarkdown
- repo: https://github.com/crate-ci/typos
rev: v1.24.6
hooks:
- id: typos
- repo: https://github.com/rhysd/actionlint
rev: v1.7.2
hooks:
- id: actionlint
- repo: https://github.com/sirwart/ripsecrets
rev: v0.1.8
hooks:
- id: ripsecrets
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ Check e-book files for security and privacy issues.

## Motivation

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.
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.

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

## Features

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

### Installing

Screener is available on [PyPI](https://pypi.org/project/screener/). To install, run:
Screener is available on [PyPI](https://pypi.org/project/screener/). To install,
run

```bash
pip install screener
```

#### Development installation

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

```bash
poetry install
Expand All @@ -55,7 +61,9 @@ screener --help

## Contributing

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.
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.

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

Expand Down
Loading
Loading