From 8fb7485c4c760237948bcc6bbf2c6f64f84b81ab Mon Sep 17 00:00:00 2001 From: Adar Nimrod <nimrod@shore.co.il> Date: Fri, 8 Jan 2021 21:48:26 +0200 Subject: [PATCH] Pre-commit. - Use a common pre-commit config snippet for Ansible projects. - Use a template for pre-commit GitLab CI job. - Address some issues raised now by pre-commit. --- .gitlab-ci.yml | 18 ++---------- .pre-commit-config.yaml | 40 ++++++++++++++------------ README.md | 12 ++++---- renew-certs.yml | 2 +- roles/debian_bootstrap/tasks/main.yaml | 14 ++++----- roles/kodi/tasks/main.yml | 2 +- 6 files changed, 40 insertions(+), 48 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d1dedd5..f92da7b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,16 +1,4 @@ --- -image: adarnimrod/ci-images:docker - -stages: - - test - -pre-commit: - stage: test - image: adarnimrod/ci-images:pre-commit - variables: - XDG_CACHE_HOME: "$CI_PROJECT_DIR/.cache" - script: - - pre-commit run --all-files - cache: - paths: - - .cache/ +include: + - project: shore/ci-templates + file: templates/pre-commit.yml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dacf4d3..0bd3a64 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,28 +1,18 @@ --- repos: - - repo: https://github.com/pre-commit/pre-commit-hooks + - repo: https://github.com/pre-commit/pre-commit-hooks.git rev: v3.4.0 hooks: - id: check-added-large-files - id: check-executables-have-shebangs - id: check-merge-conflict - id: check-symlinks - - id: check-yaml - - id: detect-private-key - id: trailing-whitespace - - repo: https://git.shore.co.il/ansible/ansible-pre-commit.git - rev: v0.10.0 - hooks: - - id: ansible-syntax-check - # yamllint disable-line rule:line-length - files: bootstrap\.yaml|update\.yaml|renew-certs\.yaml|debian_server\.yaml - types: [yaml] - - - repo: https://github.com/ansible/ansible-lint - rev: v4.3.7 + - repo: https://github.com/Yelp/detect-secrets + rev: v0.14.3 hooks: - - id: ansible-lint + - id: detect-secrets - repo: https://github.com/adrienverge/yamllint rev: v1.25.0 @@ -35,14 +25,28 @@ repos: - id: proselint types: [markdown] - - repo: https://github.com/Yelp/detect-secrets - rev: v0.14.3 + - repo: https://github.com/executablebooks/mdformat.git + rev: 0.5.3 hooks: - - id: detect-secrets - exclude: Pipfile\.lock + - id: mdformat - repo: https://git.shore.co.il/nimrod/shell-pre-commit.git rev: v0.6.0 hooks: - id: shell-lint + + - repo: https://github.com/shellcheck-py/shellcheck-py.git + rev: v0.7.1.1 + hooks: - id: shellcheck + + - repo: https://git.shore.co.il/ansible/ansible-pre-commit.git + rev: v0.10.0 + hooks: + - id: ansible-syntax-check + files: (bootstrap|update|renew-certs|debian_server|kodi)\.yaml + + - repo: https://github.com/ansible/ansible-lint + rev: v4.3.7 + hooks: + - id: ansible-lint diff --git a/README.md b/README.md index 06b2eff..81f311d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# - Homelab +# Homelab + [](https://git.shore.co.il/shore/homelab/-/commits/master) > My homelab setup using Ansible. @@ -29,7 +29,7 @@ This software is licensed under the MIT license (see `LICENSE.txt`). ## Author Information -Nimrod Adar, [contact me](mailto:nimrod@shore.co.il) or visit my [website]( -https://www.shore.co.il/). Patches are welcome via [`git send-email`]( -http://git-scm.com/book/en/v2/Git-Commands-Email). The repository is located -at: <https://git.shore.co.il/explore/>. +Nimrod Adar, [contact me](mailto:nimrod@shore.co.il) or visit my +[website](https://www.shore.co.il/). Patches are welcome via +[`git send-email`](http://git-scm.com/book/en/v2/Git-Commands-Email). The repository +is located at: <https://git.shore.co.il/expore/>. diff --git a/renew-certs.yml b/renew-certs.yml index 0cc0320..b1dd319 100644 --- a/renew-certs.yml +++ b/renew-certs.yml @@ -8,7 +8,7 @@ vars: email: nimrod@shore.co.il acme_directory: https://acme-v02.api.letsencrypt.org/directory - #acme_directory: https://acme-staging-v02.api.letsencrypt.org/directory + # acme_directory: https://acme-staging-v02.api.letsencrypt.org/directory acme_version: 2 handlers: diff --git a/roles/debian_bootstrap/tasks/main.yaml b/roles/debian_bootstrap/tasks/main.yaml index c83e108..2254a85 100644 --- a/roles/debian_bootstrap/tasks/main.yaml +++ b/roles/debian_bootstrap/tasks/main.yaml @@ -1,7 +1,7 @@ --- - name: Update APT sources raw: apt-get update - changed_when: False + changed_when: false - name: APT install Python raw: DEBIAN_FRONTEND=noninteractive apt-get install -qy python3 @@ -10,12 +10,12 @@ - name: Install requirements for more complete facts apt: - name: - - iproute2 - - lsb-release - state: present - update_cache: yes - cache_valid_time: 3600 + name: + - iproute2 + - lsb-release + state: present + update_cache: true + cache_valid_time: 3600 - name: Gather facts setup: diff --git a/roles/kodi/tasks/main.yml b/roles/kodi/tasks/main.yml index cd4bea2..2c050d5 100644 --- a/roles/kodi/tasks/main.yml +++ b/roles/kodi/tasks/main.yml @@ -6,7 +6,7 @@ - avahi-daemon - desktop-base - flatpak - #- plymouth-themes + # - plymouth-themes - firmware-linux - udisks2 - unison -- GitLab