From 1a9f8c451ff873edbff404a0444ed028b20a2e18 Mon Sep 17 00:00:00 2001 From: Nicolas Richart <networms@gmail.ch> Date: Wed, 12 Mar 2025 23:40:10 +0100 Subject: [PATCH] Adding linters (should make components for this) --- .gitlab-ci.yml | 38 ++++++++++++++++++++++++++++++++++++++ .hadolint.yaml | 9 +++++++++ .yamllint.yml | 8 ++++++++ 3 files changed, 55 insertions(+) create mode 100644 .hadolint.yaml create mode 100644 .yamllint.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 121f450..45c547c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,6 +8,7 @@ stages: - install - release - deploy + - linters workflow: rules: @@ -257,3 +258,40 @@ post_cleaning: - ${environment} script: - ./ci/cleaning_fs.sh + +.code-quality: &code-climate + stage: linters + image: + name: registry.hpc.epfl.ch/scitas/linters-collection:latest + pull_policy: always + allow_failure: true + after_script: + - | + if [ ! -s gl-codequality.json ]; then + echo [] | tee gl-codequality.json | jq -C .; + fi + artifacts: + reports: + codequality: [gl-codequality.json] + paths: + - gl-codequality.json + +cq:hadolint: + <<: *code-climate + script: + - hadolint --format codeclimate dockerfiles/**/Dockerfile | tee gl-codequality.json | jq -C . + +cq:shellcheck: + <<: *code-climate + script: + - | + git ls-files . \ + | xargs -r -n1 file \ + | awk -F: '/shell script/{print $1}' \ + | xargs -r -n1 shellcheck -f json \ + | tee -a gl-codequality.json | jq -C . + +cq:yamllint: + <<: *code-climate + script: + - yamllint_codeclimate --standalone | tee gl-codequality.json | jq -C . diff --git a/.hadolint.yaml b/.hadolint.yaml new file mode 100644 index 0000000..440d70d --- /dev/null +++ b/.hadolint.yaml @@ -0,0 +1,9 @@ +--- +failure-threshold: "style" # name of threshold level (error | warning | info | style | ignore | none) +format: "codeclimate" # Output format (tty | json | checkstyle | codeclimate | gitlab_codeclimate | gnu | codacy) +ignored: ["DL3041"] # list of rules +no-color: false # true | false +strict-labels: true # true | false +trustedRegistries: + - "registry.hpc.epfl.ch" # registry or list of registries + - "docker.io" diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 0000000..45efdb5 --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,8 @@ +--- +extends: default + +rules: + line-length: + ignore: + - .hadolint.yaml + - .gitlab-ci.yml -- GitLab