diff --git a/.ci-scripts/lint.sh b/.ci-scripts/lint.sh new file mode 100644 index 0000000000000000000000000000000000000000..682abc331750f93baa781513acb21342b65cc181 --- /dev/null +++ b/.ci-scripts/lint.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +jq --null-input --arg yaml "$1" '.content=$yaml' \ + | curl "https://git.ethitter.com/api/v4/ci/lint?include_merged_yaml=true" \ + --silent \ + --header 'Content-Type: application/json' \ + --header "PRIVATE-TOKEN: $GITLAB_API_PAT" \ + --data @- \ + -o result.json + +echo "**********************************************************" +echo "MERGED YAML:" +jq --raw-output '.merged_yaml' < result.json + +echo "**********************************************************" +echo "ERRORS:" +jq '.errors' < result.json + +echo "**********************************************************" +echo "WARNINGS:" +jq '.warnings' < result.json + +echo "**********************************************************" +echo "IS VALID:" +jq '.valid' < result.json + +if [ "$(jq '.valid' < result.json)" = "true" ]; then + exit 0 +else + exit 1 +fi diff --git a/.gitignore b/.gitignore index c38fa4e005685a861be5fdbe8fcbb03f84a216b0..b5d13acb256d175e8272861d347920fd4c1e7736 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .idea *.iml + +result.json diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..111ee665ea9d3356ece5804dd3349aa5d72fa8e0 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,12 @@ +before_script: + - | + apt-get update + apt-get -y --no-install-recommends install jq + apt-get clean + rm -rf /var/lib/apt/lists/* + +lint: + stage: test + image: containers.ethitter.com:443/docker/images/debian:bullseye + script: + - sh ./.ci-scripts/lint.sh "$(<./plugins/default.yml)" diff --git a/files/default.yml b/files/default.yml index 33ac4cc62cf3f5a7bb8b6fc3e24f09c4a7bc61f7..705fe924a4d271be5243cb09687c14dae8820850 100644 --- a/files/default.yml +++ b/files/default.yml @@ -1,7 +1,9 @@ include: + - remote: https://git-cdn.e15r.co/gitlab/ci/golang/-/raw/main/files/templates/stages.yml - remote: https://git-cdn.e15r.co/gitlab/ci/golang/-/raw/main/files/templates/image.yml - remote: https://git-cdn.e15r.co/gitlab/ci/golang/-/raw/main/files/templates/variables.yml - remote: https://git-cdn.e15r.co/gitlab/ci/golang/-/raw/main/files/templates/cache.yml - remote: https://git-cdn.e15r.co/gitlab/ci/golang/-/raw/main/files/templates/stages.yml - remote: https://git-cdn.e15r.co/gitlab/ci/golang/-/raw/main/files/templates/before-script.yml - remote: https://git-cdn.e15r.co/gitlab/ci/golang/-/raw/main/files/templates/matrix.yml + - remote: https://git-cdn.e15r.co/gitlab/ci/golang/-/raw/main/files/templates/gitlab-tools.yml diff --git a/files/templates/gitlab-tools.yml b/files/templates/gitlab-tools.yml new file mode 100644 index 0000000000000000000000000000000000000000..75251e8f6f5c0de20f5352f807c89df947b8bd22 --- /dev/null +++ b/files/templates/gitlab-tools.yml @@ -0,0 +1,21 @@ +include: + - template: Security/Dependency-Scanning.gitlab-ci.yml + - template: Security/License-Scanning.gitlab-ci.yml + - template: Security/SAST.gitlab-ci.yml + - template: Security/Secret-Detection.gitlab-ci.yml + +dependency_scanning: + before_script: echo "" + stage: security + +license_scanning: + before_script: echo "" + stage: security + +sast: + before_script: echo "" + stage: security + +secret_detection: + before_script: echo "" + stage: security diff --git a/files/templates/stages.yml b/files/templates/stages.yml index df24ad8a016d592717f3db40f45466ad650ca623..3ced010eb9b31291091faf664a1174d5214098df 100644 --- a/files/templates/stages.yml +++ b/files/templates/stages.yml @@ -1,3 +1,7 @@ stages: - - test + - .pre - build + - test + - security + - deploy + - .post