Merge branch 'pre-commit'

This commit is contained in:
Nick Groenen 2023-09-26 09:13:16 +02:00
commit 8ace49ded3
No known key found for this signature in database
GPG Key ID: 4F0AD019928AE098
14 changed files with 63 additions and 16 deletions

View File

@ -58,6 +58,47 @@ jobs:
- run: cargo check - run: cargo check
- run: cargo clippy -- -D warnings - run: cargo clippy -- -D warnings
pre-commit:
name: Run pre-commit
runs-on: ubuntu-latest
needs: build
env:
# These hooks are expensive and already run as dedicated jobs above
SKIP: "tests,clippy"
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: "cargo-lint-${{ needs.build.outputs.rustc_cache_key }}-${{ hashFiles('**/Cargo.lock') }}"
restore-keys: |
cargo-lint-${{ env.RUSTC_CACHEKEY }}
cargo-base-${{ env.RUSTC_CACHEKEY }}
fail-on-cache-miss: true
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.3
- uses: actions/setup-python@v3
- name: set PYVERSION
run: echo "PYVERSION=$(python --version | tr ' ' '-')" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
# Changes to pre-commit-config.yaml may require the installation of
# new binaries/scripts. When a cache hit occurs, changes to the cache
# aren't persisted at the end of the run, so making the key dependent
# on the configuration file ensures we always persist a complete cache.
key: pre-commit-${{ env.PYVERSION }}-${{ hashFiles('.pre-commit-config.yaml') }}
- run: pip install pre-commit
- run: pre-commit run --all --color=always --show-diff-on-failure
test-linux: test-linux:
name: Test on Linux name: Test on Linux
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -2,9 +2,15 @@
# See https://pre-commit.com/hooks.html for more hooks # See https://pre-commit.com/hooks.html for more hooks
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: 9136088a246768144165fcc3ecc3d31bb686920a # frozen: v3.3.0 rev: 38b88246ccc552bffaaf54259d064beeee434539 # frozen: v4.0.1
hooks: hooks:
- id: check-case-conflict
- id: check-symlinks
- id: check-yaml - id: check-yaml
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
exclude: '^(README.md|tests/testdata/expected/.*)$'
- repo: local - repo: local
hooks: hooks:
- id: rustfmt - id: rustfmt

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
set -euo pipefail set -euo pipefail