Commit 0d4283f6 authored by Thomas Boni's avatar Thomas Boni
Browse files

Merge branch '290-ci_linter-step-of-hub-pipeline-doesn-t-work' into 'latest'

Resolve "ci_linter step of hub pipeline doesn't work"

Closes #290

See merge request r2devops/hub!144
parents 9fa2ae47 10a31e79
Loading
Loading
Loading
Loading
+29 −8
Original line number Diff line number Diff line
@@ -9,17 +9,35 @@ include:
  - remote: 'https://jobs.r2devops.io/0.3.0/pages.yml?scope=0.yml'

ci_linter:
  image: golang:1.15.2-alpine3.12
  stage: static_tests
  image:
    name: alpine/httpie:2.4.0
    entrypoint: [""]
  variables:
    GITLAB_CI_LINT_URL: "https://gitlab.com/api/v4/ci/lint?include_merged_yaml=true"
    JOB_FILES_EXTENSION: ".yml"
  script:
    - apk add --no-cache git
    - go get gitlab.com/orobardet/gitlab-ci-linter
    - apk add --no-cache jq
    - mkdir ci_linter_reports
    - for JOB_PATH in jobs/*; do
    -   echo "Start checking ${JOB_PATH}/${JOB} using Gitlab CI linter API"
    -   JOB=$(basename ${JOB_PATH})
    -   gitlab-ci-linter --verbose ${JOB_PATH}/${JOB}.yml
    -   jq --null-input --arg yaml "$(cat ${JOB_PATH}/${JOB}${JOB_FILES_EXTENSION})" '.content=$yaml' | http --print 'b' --check-status "$GITLAB_CI_LINT_URL" Content-Type:"application/json" PRIVATE-TOKEN:${API_TOKEN} > ci_linter_reports/${JOB}.json
    -   if [ $(jq -r '.status' ci_linter_reports/${JOB}.json) == "valid" ]; then
    -     echo "👍 job ${JOB_PATH}/${JOB} is valid"
    -   else
    -     echo "👎 job ${JOB_PATH}/${JOB} is invalid"
    -     jq '.' ci_linter_reports/${JOB}.json
    -     exit 1
    -   fi
    - done
  artifacts:
    expose_as: "job_ci_lint"
    paths:
      - ci_linter_reports/
    when: always

structure:
job_structure:
  image: python:3.9.1-alpine
  stage: static_tests
  variables:
@@ -31,9 +49,9 @@ structure:
  script:
    - pipenv run python3 tools/job_structure/job_structure.py
  artifacts:
    expose_as: "job_structure"
    paths:
      - ${JOB_LOGFILE}
    expire_in: 30 days
    when: always

job_customs:
@@ -48,10 +66,11 @@ job_customs:
  script:
    - pipenv run python3 tools/job_customs/job_customs.py
  artifacts:
    expose_as: "jobs_customs"
    paths:
      - ${JOB_LOGFILE}

scan_images_dep:
job_image_scan:
  image: docker:19.03
  stage: static_tests
  services:
@@ -115,9 +134,10 @@ scan_images_dep:
    paths:
      - "$TRIVY_CACHE_DIR"
  artifacts:
    expose_as: "job_image_scan"
    paths:
      - "${JOB_LOGFILE}"
      - "${OUTPUT_DIR}/*.xml"
      - "${OUTPUT_DIR}"
    reports:
      junit:
        - "${OUTPUT_DIR}/*.xml"
@@ -138,6 +158,7 @@ job_labels:
  script:
    - pipenv run python3 tools/job_labels/job_labels.py
  artifacts:
    expose_as: "job_labels"
    paths:
      - ${JOB_LOGFILE}
    expire_in: 30 days