ci: Run additional sanity checks on repository

This commit is contained in:
Jade Ellis 2025-06-21 17:58:28 +01:00
parent 70df8364b3
commit 93719018a8
No known key found for this signature in database
GPG key ID: 8705A2A3EBF77BD2
5 changed files with 89 additions and 2 deletions

View file

@ -23,6 +23,6 @@ indent_size = 2
indent_style = tab indent_style = tab
max_line_length = 98 max_line_length = 98
[{.forgejo/**/*.yml,.github/**/*.yml}] [{**/*.yml}]
indent_size = 2 indent_size = 2
indent_style = space indent_style = space

View file

@ -0,0 +1,22 @@
name: reflighit
description: |
Runs reflighit, pre-commit reimplemented in Rust.
inputs:
extra_args:
description: options to pass to pre-commit run
required: false
default: '--all-files'
runs:
using: composite
steps:
- name: Install Prefligit
shell: bash
run: |
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/j178/prefligit/releases/download/v0.0.10/prefligit-installer.sh | sh
- uses: actions/cache@v3
with:
path: ~/.cache/prefligit
key: prefligit-0|${{ hashFiles('.pre-commit-config.yaml') }}
- run: prefligit run --show-diff-on-failure --color=always ${{ inputs.extra_args }}
shell: bash

View file

@ -0,0 +1,15 @@
name: Checks / Prefligit
on:
push:
jobs:
prefligit:
runs-on: ubuntu-latest
env:
FROM_REF: ${{ github.event.pull_request.base.sha || (!github.event.forced && ( github.event.before != '0000000000000000000000000000000000000000' && github.event.before || github.sha )) || format('{0}~', github.sha) }}
TO_REF: ${{ github.sha }}
steps:
- uses: ./.forgejo/actions/prefligit
with:
extra_args: --from-ref ${{ env.FROM_REF }} --to-ref ${{ env.TO_REF }} --hook-stage manual

View file

@ -1,4 +1,4 @@
name: Rust Checks name: Checks / Rust
on: on:
push: push:

50
.pre-commit-config.yaml Normal file
View file

@ -0,0 +1,50 @@
default_install_hook_types:
- pre-commit
- commit-msg
default_stages:
- pre-commit
- manual
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-byte-order-marker
- id: check-case-conflict
- id: check-symlinks
- id: destroyed-symlinks
- id: check-yaml
- id: check-json
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
- id: check-merge-conflict
- id: check-added-large-files
- repo: https://github.com/crate-ci/typos
rev: v1.26.0
hooks:
- id: typos
- repo: local
hooks:
- id: cargo-fmt
name: cargo fmt
entry: cargo +nightly fmt --
language: system
types: [rust]
pass_filenames: false
stages:
- pre-commit
- repo: local
hooks:
- id: cargo-clippy
name: cargo clippy
language: system
types: [rust]
pass_filenames: false
entry: cargo clippy --workspace --locked --no-deps --profile test -- -D warnings
stages:
- pre-commit