From 5517facd37d31e21bb8717835ff17dd054755bd5 Mon Sep 17 00:00:00 2001 From: Erick Hitter <git-contrib@ethitter.com> Date: Sat, 16 Jul 2022 13:39:42 -0700 Subject: [PATCH] DRY --- .ci-scripts/lint.sh | 17 +++++++++++++++++ .gitignore | 2 ++ .gitlab-ci.yml | 15 ++++++++------- 3 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 .ci-scripts/lint.sh diff --git a/.ci-scripts/lint.sh b/.ci-scripts/lint.sh new file mode 100644 index 0000000..7c875b0 --- /dev/null +++ b/.ci-scripts/lint.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +jq --null-input --arg yaml "$1" '.content=$yaml' \ + | curl -vvv "https://git.ethitter.com/api/v4/ci/lint?include_merged_yaml=true" \ + --header 'Content-Type: application/json' \ + --header "PRIVATE-TOKEN: $GITLAB_API_PAT" \ + --data @- -o result.json + +jq --raw-output '.merged_yaml' < result.json +jq '.errors' < result.json +jq '.warnings' < result.json + +if [[ true == $(jq '.valid' < result.json) ]]; then + exit 0 +else + exit 1 +fi diff --git a/.gitignore b/.gitignore index c38fa4e..b5d13ac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .idea *.iml + +result.json diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8b5d1e7..838bbf3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,13 +5,14 @@ before_script: apt-get clean rm -rf /var/lib/apt/lists/* -Lint:plugins:default: +lint:plugins:default: stage: test image: containers.ethitter.com:443/docker/images/debian:bullseye script: - - | - jq --null-input --arg yaml "$(<./plugins/default.yml)" '.content=$yaml' \ - | curl "https://git.ethitter.com/api/v4/ci/lint?include_merged_yaml=true" \ - --header 'Content-Type: application/json' \ - --header "PRIVATE-TOKEN: $GITLAB_API_PAT" \ - --data @- + - sh ./.ci-scripts/lint.sh "$(<./plugins/default.yml)" + +lint:plugins:default-redis: + stage: test + image: containers.ethitter.com:443/docker/images/debian:bullseye + script: + - sh ./.ci-scripts/lint.sh "$(<./plugins/default-redis.yml)" -- GitLab