build: use lefthook for pre-commit (#5248)
All checks were successful
continuous-integration/drone/push Build is passing

update docs
update nix-shell to auto install
rework custom pre-commit hooks to integrate better
add dockerfile for lefthook and integrate into drone
add some more hooks for formatting and linting some files

Co-authored-by: Darragh Elliott <me@delliott.net>
Reviewed-on: #5248
Co-authored-by: delliott <delliott@fsfe.org>
Co-committed-by: delliott <delliott@fsfe.org>
This commit was merged in pull request #5248.
This commit is contained in:
2025-08-27 15:22:06 +00:00
committed by tobiasd
parent 7290c37397
commit 1a05dee2f6
186 changed files with 9247 additions and 9590 deletions

41
pre-commit.Dockerfile Normal file
View File

@@ -0,0 +1,41 @@
FROM debian:latest
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
# Install deps
RUN apt-get update && apt-get install --yes --no-install-recommends \
coreutils \
curl \
file \
findutils \
git \
grep \
libxml2 \
libxml2-utils \
libxslt1.1 \
mediainfo \
npm \
perl-base \
rsync \
sed \
shfmt
# Install prettier
RUN npm install -g prettier
# Set uv project env, to persist stuff moving dirs
ENV UV_PROJECT_ENVIRONMENT=/root/.cache/uv/venv
# Add vent to path
ENV PATH="$UV_PROJECT_ENVIRONMENT/bin:$PATH"
# Set the workdir
WORKDIR /website-source
# Copy the pyproject and build deps
# Done in a seperate step for optimal docker caching
COPY ./pyproject.toml .
RUN uv sync --no-install-package fsfe_website_build --group dev
# Copy everything else
COPY . .
ENTRYPOINT ["bash", "./pre-commit.entrypoint.sh"]