Commit 4e887ab8 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Add Pre-Commit checks

parent a9e5439c
Loading
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
stages:
- check
- build
- deploy

@@ -11,6 +12,33 @@ workflow:
  - when: always


Checks:
  stage: check
  image: docker.kodo.org.uk/ci-images/pre-commit:2.15.0-1
  rules:
  - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
    variables:
      FROM_REF: $CI_COMMIT_BEFORE_SHA
  - if: $CI_PIPELINE_SOURCE == "push"
    variables:
      FETCH: $CI_DEFAULT_BRANCH
      FROM_REF: $CI_DEFAULT_BRANCH
  - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    variables:
      FROM_REF: $CI_MERGE_REQUEST_TARGET_BRANCH_SHA
  variables:
    PRE_COMMIT_HOME: $CI_PROJECT_DIR/pre-commit
  cache:
    key: $CI_JOB_NAME
    paths: [pre-commit]
  script:
  - test -n "${FETCH-}" && git fetch origin $FETCH:$FETCH -f
  - pre-commit run
    --hook-stage=commit
    --from-ref=$FROM_REF
    --to-ref=$CI_COMMIT_SHA


.build:
  stage: build
  image: docker.kodo.org.uk/ci-images/buildkit/buildctl:latest
+38 −0
Original line number Diff line number Diff line
default_stages: [commit]
repos:

- repo: meta
  hooks:
  - id: check-hooks-apply
  - id: check-useless-excludes

- repo: https://github.com/pre-commit/pre-commit-hooks
  rev: v3.4.0
  hooks:
  - id: check-added-large-files
  - id: check-case-conflict
  - id: check-merge-conflict
  - id: check-yaml
    args: [--allow-multiple-documents]
  - id: destroyed-symlinks
  - id: end-of-file-fixer
    stages: [commit, manual]
  - id: fix-byte-order-marker
  - id: mixed-line-ending
    args: [--fix=lf]
    stages: [commit, manual]
  - id: trailing-whitespace
    exclude_types: [markdown, plain-text]
    stages: [commit, manual]

- repo: https://github.com/jorisroovers/gitlint
  rev: v0.15.0
  hooks:
  - id: gitlint

- repo: https://code.kodo.org.uk/dom/pre-commit-hooks
  rev: v0.6
  hooks:
  - id: check-executable-modes
  - id: check-for-squash
  - id: protect-first-parent