Commit b4a1de7e authored by Nikos Psaromanolakis's avatar Nikos Psaromanolakis
Browse files

fix: Edit .gitlab-ci.yml

parent 13267522
Loading
Loading
Loading
Loading
Loading
+25 −34
Changes for .gitlab-ci.yml: 25 added lines, 34 removed lines.
Original line number Diff line number Diff line
@@ -12,15 +12,12 @@ default:
  image: labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/golang:latest

variables:
  DOCKER_HOST: tcp://localhost:2375
  DOCKER_TLS_CERTDIR: ""
  DOCKER_HOST: unix:///var/run/docker.sock
  DOCKER_DRIVER: overlay2
  #DOCKER_API_VERSION: "1.41"
  
  IMAGE_NAME: "pkg-manager" 
  STAG_DOCKERFILE: "build/Dockerfile"
  
  GOPRIVATE: "${CI_SERVER_HOST}/*"
  GOPRIVATE: "${CI_SERVER_HOST}/rep/*"
  GONOSUMDB: "${CI_SERVER_HOST}/rep/*"
  SONAR_GO_COVERAGE: "${CI_PROJECT_DIR}/sonarQube"

.go-cache:
@@ -40,12 +37,15 @@ lint:
    - mkdir -p ${SONAR_GO_COVERAGE}
    - echo "machine ${CI_SERVER_HOST} login gitlab-ci-token password ${CI_JOB_TOKEN}" > ~/.netrc
    - chmod 600 ~/.netrc
    - export GOPRIVATE="${CI_SERVER_HOST}/*"
    - export GOPRIVATE="${CI_SERVER_HOST}/rep/*"
    - export GONOSUMDB="${CI_SERVER_HOST}/rep/*"
    - git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/rep/".insteadOf "https://${CI_SERVER_HOST}/rep/"

  script:
      - go mod download
      - |
        set -o pipefail
        golangci-lint run ./... --output.text.path=stderr --output.checkstyle.path=stdout | tee ${SONAR_GO_COVERAGE}/golanci-report.xml
        golangci-lint run ./... --fast-only --output.text.path=stderr --output.checkstyle.path=stdout | tee ${SONAR_GO_COVERAGE}/golanci-report.xml
  artifacts:
    paths:
      - ${SONAR_GO_COVERAGE}
@@ -57,22 +57,19 @@ tests_job:
  tags:
    - hypo
  image: labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/golang:latest
  services:
    - name: labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/docker:20.10.16-dind
      command: [ "--tls=false" ]
      alias: docker
  before_script:
    - mkdir -p ${SONAR_GO_COVERAGE}
    - echo "machine ${CI_SERVER_HOST} login gitlab-ci-token password ${CI_JOB_TOKEN}" > ~/.netrc
    - chmod 600 ~/.netrc
    - export GOPRIVATE="${CI_SERVER_HOST}/*"
    
    - export GOPRIVATE="${CI_SERVER_HOST}/rep/*"
    - export GONOSUMDB="${CI_SERVER_HOST}/rep/*"
    - git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/rep/".insteadOf "https://${CI_SERVER_HOST}/rep/"
  script:
    - curl -fsSL https://get.docker.com -o get-docker.sh
    - chmod +x ./get-docker.sh
    - ./get-docker.sh
    - echo "127.0.0.1 $(hostname)" >> /etc/hosts
    - echo "$GROUP_ACCESS_TOKEN" | docker login $HYPO_APPS_REGISTRY -u $GROUP_ACCESS_NAME --password-stdin
  script:
    - go mod download
    - gofmt -e -s -w .
    - go vet ./...
@@ -109,21 +106,20 @@ dev_image_build_job:
  tags:
    - hypo
  image:
    name: labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/docker:20.10.16
  services:
    - name: labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/docker:20.10.16-dind
      command:
        - "--tls=false"
      alias: docker
    name: labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/docker:29.1.3
  before_script:
    - docker info > /dev/null
    - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
    - docker pull labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.core/pkg-manager.helm/golang:1.25
    - docker pull labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.core/pkg-manager.helm/debian:latest
  script:
    - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
    - docker pull $CI_REGISTRY_IMAGE/$IMAGE_NAME:etsi-migration-fix
    - docker tag $CI_REGISTRY_IMAGE/$IMAGE_NAME:etsi-migration-fix $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_SHORT_SHA
    - >
      docker build
      --pull
      --network host
      --build-arg USERNAME="$CI_REGISTRY_USER"
      --build-arg PASSWORD="$CI_JOB_TOKEN"
      --build-arg CI_SERVER_HOST="$CI_SERVER_HOST"
      -t $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_SHORT_SHA
      -f $STAG_DOCKERFILE .
    - docker push $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_SHORT_SHA
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
@@ -234,23 +230,18 @@ image_build_job:
  tags:
    - hypo
  image:
    name: labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/docker:20.10.16
  services:
    - name: labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/docker:20.10.16-dind
      command: [ "--tls=false" ]
      alias: docker
    name: labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/docker:29.1.3
  before_script:
    - docker info > /dev/null
    - RELEASE_VERSION=$(cat release_version.txt)
    - echo  $RELEASE_VERSION
    - if [ "$RELEASE_VERSION" = "no-release" ]; then exit 0; fi
    - echo "$GROUP_ACCESS_TOKEN" | docker login $HYPO_APPS_REGISTRY -u $GROUP_ACCESS_NAME --password-stdin
    - docker pull labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/golang:1.24
    - docker pull labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/debian:latest
  script:
    - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
    - >
      docker build
      --pull
      --network host
      --build-arg USERNAME="$CI_REGISTRY_USER" 
      --build-arg PASSWORD="$CI_JOB_TOKEN" 
      --build-arg CI_SERVER_HOST="$CI_SERVER_HOST"