From c01dbf1461b630af8ee64abf1d68c6de2e95f15b Mon Sep 17 00:00:00 2001 From: Adar Nimrod Date: Sat, 21 Nov 2020 15:36:26 +0200 Subject: [PATCH] pre-commit. Setup pre-commit and add it to CI. Correct a few things as well. --- .gitlab-ci.yml | 14 ++++++++++++++ .pre-commit-config.yaml | 25 +++++++++++++++++++++++++ Dockerfile | 3 ++- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 .pre-commit-config.yaml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ebbc41b..1f5902c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,9 +2,22 @@ image: adarnimrod/ci-images:docker stages: + - test - build - run +pre-commit: + stage: test + tags: ["ns4.shore.co.il"] + image: adarnimrod/ci-images:pre-commit + variables: + XDG_CACHE_HOME: "$CI_PROJECT_DIR/.cache" + script: + - pre-commit run --all-files + cache: + paths: + - .cache/ + build: stage: build tags: ["ns4.shore.co.il"] @@ -17,6 +30,7 @@ run: when: manual script: - docker-compose up --detach --quiet-pull --remove-orphans + # yamllint disable rule:line-length - | for i in $(seq 12) do diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..41f9b1a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,25 @@ +# vim:ff=unix ts=2 sw=2 ai expandtab +--- +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.3.0 + hooks: + - id: check-added-large-files + - id: check-merge-conflict + - id: detect-private-key + - id: trailing-whitespace + - repo: https://github.com/adrienverge/yamllint + rev: v1.25.0 + hooks: + - id: yamllint + - repo: https://github.com/amperser/proselint/ + rev: 0.10.2 + hooks: + - id: proselint + types: [plain-text] + exclude: LICENSE + - repo: https://git.shore.co.il/nimrod/docker-pre-commit.git + rev: v0.3.0 + hooks: + - id: hadolint + - id: docker-compose diff --git a/Dockerfile b/Dockerfile index 1386c21..ab9c492 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM buildpack-deps:bullseye +# hadolint ignore=DL3008 RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y \ + DEBIAN_FRONTEND=noninteractive apt-get install --yes --no-install-recommends \ apache2-utils \ bats \ bundler \ -- GitLab