Verified Commit 26d7492b authored by Adrian DC's avatar Adrian DC
Browse files

ci(gitlab-ci): isolate 'sonarcloud' job to 'sonarcloud.yml' template

Signed-off-by: default avatarAdrian DC <radian.dc@gmail.com>
parent 9f66e921
Loading
Loading
Loading
Loading
+38
Changes for .gitlab-ci.d/sonarcloud.yml: 38 added lines, 0 removed lines.
Original line number Diff line number Diff line
spec:
  inputs:
    stage:
      default: test
      description: 'Defines the sonarcloud stage (Default: test)'
    image:
      default: undefined:latest
      description: 'Specify the sonarcloud image (Default: undefined:latest)'
---

sonarcloud:
  stage: $[[ inputs.stage ]]
  image:
    name: $[[ inputs.image ]]
    entrypoint: ['']
  variables:
    GIT_DEPTH: 0
    SONAR_USER_HOME: ${CI_PROJECT_DIR}/.sonar
  cache:
    key: '${CI_JOB_NAME}'
    paths:
      - .sonar/cache
  before_script:
    # Configure Git securities
    - git config --global --add safe.directory "${CI_PROJECT_DIR}"
  script:
    # Prevent local usage
    - |
      if [ ! -z "${CI_LOCAL:-}" ] && [ -z "${SONAR_HOST_URL:-}" ]; then
        set +x
        echo ' '
        echo ' [ERROR] SonarCloud quality job is meant for CI executions only...'
        echo ' '
        exit 1
      fi
    # Scan with SonarCloud
    - sonar-scanner -Dsonar.projectVersion=$(git describe --always) -Dsonar.branch.name=${CI_COMMIT_REF_NAME}
  allow_failure: true
+4 −30
Changes for .gitlab-ci.yml: 4 added lines, 30 removed lines.
Original line number Diff line number Diff line
@@ -2,6 +2,10 @@ include:
  - component: gitlab.com/RadianDevCore/tools/pre-commit-crocodile/commits@5.0.0
    inputs:
      stage: prepare
  - local: .gitlab-ci.d/sonarcloud.yml
    inputs:
      stage: quality
      image: registry.gitlab.com/radiandevcore/tools/gitlab-projects-settings/sonarsource/sonar-scanner-cli:latest
  - local: .gitlab-ci.d/deploy.yml
    inputs:
      stage: deploy
@@ -715,42 +719,13 @@ py3.12:
  before_script:
    - !reference [.unit-tests-template, before_script]

# =============================================================================
# Stage: quality

sonarcloud:
  stage: quality
  image:
    name: registry.gitlab.com/radiandevcore/tools/gitlab-projects-settings/sonarsource/sonar-scanner-cli:latest
    entrypoint: ['']
  needs:
    - job: registry:rehost
      artifacts: false
      optional: true
    - job: coverage:linux
    - job: coverage:windows
  variables:
    GIT_DEPTH: 0
    SONAR_USER_HOME: ${CI_PROJECT_DIR}/.sonar
  cache:
    key: '${CI_JOB_NAME}'
    paths:
      - .sonar/cache
  before_script:
    # Configure Git securities
    - git config --global --add safe.directory "${CI_PROJECT_DIR}"
  script:
    # Prevent local usage
    - |
      if [ ! -z "${CI_LOCAL:-}" ] && [ -z "${SONAR_HOST_URL:-}" ]; then
        set +x
        echo ' '
        echo ' [ERROR] SonarCloud quality job is meant for CI executions only...'
        echo ' '
        exit 1
      fi
    # Scan with SonarCloud
    - sonar-scanner -Dsonar.projectVersion=$(git describe --always) -Dsonar.branch.name=${CI_COMMIT_REF_NAME}
  rules:
    - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
      changes:
@@ -765,7 +740,6 @@ sonarcloud:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
      when: always
    - when: never
  allow_failure: true

deploy:release:
  needs: