ci: add pre-commit job

This commit is contained in:
Stéphane Cerveau 2024-01-05 09:48:22 +01:00
parent a25f0499c8
commit 11cf962bfd
3 changed files with 48 additions and 6 deletions

View file

@ -22,7 +22,7 @@ variables:
variables:
FDO_DISTRIBUTION_VERSION: "38"
# Update this to trigger a container rebuild
FDO_DISTRIBUTION_TAG: "2023-08-25.1"
FDO_DISTRIBUTION_TAG: $GST_RS_FDO_IMG_TAG
before_script:
- source ./ci/env.sh
- mkdir .cargo && echo -e "[net]\ngit-fetch-with-cli = true" > .cargo/config
@ -60,7 +60,8 @@ build-fedora-container:
bison
FDO_DISTRIBUTION_EXEC: >-
ci/install-rust.sh stable &&
pip3 install meson
pip3 install meson &&
pip3 install pre-commit
.windows rust docker build:
stage: prepare
@ -120,15 +121,27 @@ windows installer stable:
expire_in: 10 days
when: "manual"
rustfmt-clippy:
pre-commit:
stage: "lint"
extends:
- .fedora
- .fdo.distribution-image@fedora
variables:
PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit
cache:
paths:
- ${PRE_COMMIT_HOME}
script:
- meson setup build
- pre-commit run --all-files
clippy:
extends:
- .fedora
- .fdo.distribution-image@fedora
stage: lint
script:
- meson build
- cargo fmt --version
- cargo fmt -- --color=always --check
- cargo clippy --version
- cargo clippy --color=always --all-targets -- -D warnings

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

@ -0,0 +1,29 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.11
hooks:
# Run the linter.
- id: ruff
# Run the formatter.
- id: ruff-format
- repo: https://github.com/crate-ci/typos
rev: v1.17.0
hooks:
- id: typos
exclude: '^$|\.svg$'
- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: fmt

View file

@ -1,4 +1,4 @@
variables:
GST_RS_WIN_IMG_TAG: "2023-12-22.0"
GST_RS_FDO_IMG_TAG: "2023-08-25.1"
GST_RS_FDO_IMG_TAG: "2024-01-05.0"
GST_RS_STABLE: "1.70.0"