From 4eefa6197468028fa7db7e62b38a96b2760e0b4c Mon Sep 17 00:00:00 2001 From: Mykyta Solomko Date: Thu, 17 Dec 2020 23:13:03 +0200 Subject: [PATCH] More linters (#2) * shellcheck * yamllint * hadolint Co-authored-by: Mykyta Solomko Reviewed-on: https://code.nix.org.ua/NiX/docker-linter/pulls/2 Co-Authored-By: Mykyta Solomko Co-Committed-By: Mykyta Solomko --- {.ci-scripts => .ci}/lint-dockerfile.sh | 0 {.ci-scripts => .ci}/lint-shell.sh | 0 {.ci-scripts => .ci}/lint-yaml.sh | 2 +- {.ci-scripts => .ci}/yamllint.yml | 0 .drone.yml => .woodpecker.yml | 18 ++++----- Dockerfile | 53 +++++++++++++++++++++++-- 6 files changed, 59 insertions(+), 14 deletions(-) rename {.ci-scripts => .ci}/lint-dockerfile.sh (100%) rename {.ci-scripts => .ci}/lint-shell.sh (100%) rename {.ci-scripts => .ci}/lint-yaml.sh (74%) rename {.ci-scripts => .ci}/yamllint.yml (100%) rename .drone.yml => .woodpecker.yml (53%) diff --git a/.ci-scripts/lint-dockerfile.sh b/.ci/lint-dockerfile.sh similarity index 100% rename from .ci-scripts/lint-dockerfile.sh rename to .ci/lint-dockerfile.sh diff --git a/.ci-scripts/lint-shell.sh b/.ci/lint-shell.sh similarity index 100% rename from .ci-scripts/lint-shell.sh rename to .ci/lint-shell.sh diff --git a/.ci-scripts/lint-yaml.sh b/.ci/lint-yaml.sh similarity index 74% rename from .ci-scripts/lint-yaml.sh rename to .ci/lint-yaml.sh index 83f8bed..89af0b4 100755 --- a/.ci-scripts/lint-yaml.sh +++ b/.ci/lint-yaml.sh @@ -6,7 +6,7 @@ CUR_DIR=$(pwd) YAML_FILES=$(find "${CUR_DIR}" -type f \( -iname '*.yml' -or -iname '*.yaml' \)) for YM_F in ${YAML_FILES[*]}; do - yamllint -c "${CUR_DIR}/.ci-scripts/yamllint.yml" "${YM_F}" \ + yamllint -c "${CUR_DIR}/.ci/yamllint.yml" "${YM_F}" \ || RET=${?} done diff --git a/.ci-scripts/yamllint.yml b/.ci/yamllint.yml similarity index 100% rename from .ci-scripts/yamllint.yml rename to .ci/yamllint.yml diff --git a/.drone.yml b/.woodpecker.yml similarity index 53% rename from .drone.yml rename to .woodpecker.yml index 776b6df..9f54a66 100644 --- a/.drone.yml +++ b/.woodpecker.yml @@ -5,31 +5,29 @@ workspace: pipeline: lint-shell: - image: koalaman/shellcheck-alpine:stable + image: sevoid/linter:latest group: lint commands: - - apk add --no-cache bash - - bash ./.ci-scripts/lint-shell.sh + - ./.ci/lint-shell.sh lint-yaml: - image: sdesbure/yamllint:latest + image: sevoid/linter:latest group: lint commands: - - apk add --no-cache bash - - bash ./.ci-scripts/lint-yaml.sh + - ./.ci/lint-yaml.sh lint-dockerfile: - image: hadolint/hadolint:latest-debian + image: sevoid/linter:latest group: lint commands: - - bash ./.ci-scripts/lint-dockerfile.sh + - ./.ci/lint-dockerfile.sh docker-build-and-push: image: plugins/docker:17 secrets: - docker_username - docker_password - repo: sevoid/linter-pylint + repo: sevoid/linter tags: - 'latest' when: @@ -37,6 +35,6 @@ pipeline: - build-* branches: - axlude: [ master ] + exclude: [ master ] # vim:set syntax=yaml ts=2 sw=2 et: diff --git a/Dockerfile b/Dockerfile index f51741e..b93a84f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,19 @@ FROM vbatts/slackware:current +LABEL maintainer="sev@nix.org.ua" + +ENV SHELLCHECK_VER=0.7.1 +ENV YAMLLINT_VER=1.25.0 +ENV HADOLINT_VER=1.19.0 ENV PYLINT_VER=2.6.0 COPY slackpkg.conf /etc/slackpkg/ +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +# +# SYS: configuration and upgrades +# RUN touch /var/lib/slackpkg/current \ && slackpkg update \ && slackpkg install perl ca-certificates dcron \ @@ -11,8 +21,45 @@ RUN touch /var/lib/slackpkg/current \ && slackpkg update gpg \ && slackpkg update \ && slackpkg upgrade-all \ - && slackpkg install python3 python-pip python-setuptools \ - && pip install -q pylint==${PYLINT_VER} + && slackpkg install python3 \ + python-pip \ + python-setuptools -LABEL maintainer="sev@nix.org.ua" +# +# SYS: add user +# +RUN useradd -c 'User for code linters' -s /bin/bash linter + +# +# INST: pylint +# +RUN pip install --no-cache-dir -q yamllint==${YAMLLINT_VER} + +# +# INST: pylint +# +RUN pip install --no-cache-dir -q pylint==${PYLINT_VER} + +# +# INST: shellcheck +# +RUN wget --quiet --no-check-certificate --output-document - \ + https://github.com/koalaman/shellcheck/releases/download/v${SHELLCHECK_VER}/shellcheck-v${SHELLCHECK_VER}.linux.x86_64.tar.xz \ + | tar -C /usr/local/bin \ + --strip-components=1 \ + -Jxf - shellcheck-v${SHELLCHECK_VER}/shellcheck + +# +# INST: hadolint +# +RUN wget --quiet --no-check-certificate --output-document /usr/local/bin/hadolint \ + https://github.com/hadolint/hadolint/releases/download/v${HADOLINT_VER}/hadolint-Linux-x86_64 + +# +# MISK: owner & permissions +# +RUN chown root:root /usr/local/bin/* \ + && chmod 0755 /usr/local/bin/* + +USER linter