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

Initial public release

parents
Loading
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+6 −0
Changes for .gitignore: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
tmp/
.air.toml
org.etsi.osl.hypo.core.pkg-manager.helm
GEMINI.md
CLAUDE.md
.claude/

.gitlab-ci.yml

0 → 100644
+235 −0
Changes for .gitlab-ci.yml: 235 added lines, 0 removed lines.
Original line number Diff line number Diff line
stages:
  - lint
  - test
  - analyze
  - dev_image_build
  - dev_deploy
  - dev_workflows
  - release
  - image_build

default:
  image: registry.ubitech.eu/nsit/maestro-apps/golang:latest

variables:
  DOCKER_HOST: tcp://docker:2375
  DOCKER_TLS_CERTDIR: ""
  DOCKER_DRIVER: overlay2
  DOCKER_API_VERSION: "1.41"
  
  IMAGE_NAME: "pkg-manager" 
  STAG_DOCKERFILE: "build/Dockerfile"
  
  GOPRIVATE: "${CI_SERVER_HOST}/*"
  SONAR_GO_COVERAGE: "${CI_PROJECT_DIR}/sonarQube"
  
.go-cache:
    variables:
        GOPATH: $CI_PROJECT_DIR/.go
    cache:
      paths:
        - .go/pkg/mod/

lint:
  stage: lint
  image: registry.ubitech.eu/nsit/maestro-apps/golangci/golangci-lint:v1.64
  extends: .go-cache
  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}/*"
  script:
      - go mod download
      - |
        set -o pipefail
        golangci-lint run ./... --out-format checkstyle --print-issued-lines=true --print-linter-name=true | tee ${SONAR_GO_COVERAGE}/golanci-report.xml
  artifacts:
    paths:
      - ${SONAR_GO_COVERAGE}
  rules:
    - if: '$CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != "main"'

tests_job:
  stage: test
  image: registry.ubitech.eu/nsit/maestro-apps/golang:latest
  services:
    - name: registry.ubitech.eu/nsit/maestro-apps/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}/*"
    
    - curl -fsSL https://get.docker.com -o get-docker.sh
    - chmod +x ./get-docker.sh
    - ./get-docker.sh
    - echo -n "$MAESTRO_APPS_TOKEN" | docker login "$MAESTRO_APPS_REGISTRY" -u "$MAESTRO_APPS_USER" --password-stdin
  script:
    - go mod download
    - gofmt -e -s -w .
    - go vet ./...
    - go test -v -cover -coverprofile=${SONAR_GO_COVERAGE}/coverage.out -coverpkg=./... ./... -skip TestOcmScheduler
  artifacts:
    paths:
      - ${SONAR_GO_COVERAGE}
  rules:
    - if: '$CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != "main"'

sonar-analysis:
  stage: analyze
  image: registry.ubitech.eu/nsit/maestro-apps/sonarsource/sonar-scanner-cli:latest
  script:
    - sonar-scanner -Dsonar.projectKey=${CI_PROJECT_TITLE} -Dsonar.coverage.exclusions=**/*_test.go -Dsonar.go.coverage.reportPaths=${SONAR_GO_COVERAGE}/coverage.out -Dsonar.go.govet.reportPaths=${SONAR_GO_COVERAGE}/vet_report.json -Dsonar.go.golangci-lint.reportPaths=${SONAR_GO_COVERAGE}/golanci-report.xml
  allow_failure: true
  needs:
    - job: tests_job
      artifacts: true
  artifacts:
    when: always
    paths:
      - ${SONAR_GO_COVERAGE}
    expire_in: 1 day
  dependencies:
    - tests_job
  rules:
    - if: '$CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != "main"'

dev_image_build_job:
  stage: dev_image_build
  image:
    name: registry.ubitech.eu/nsit/maestro-apps/docker:20.10.16
  services:
    - name: registry.ubitech.eu/nsit/maestro-apps/docker:20.10.16-dind
      command: [ "--tls=false" ]
      alias: docker
  before_script:
    - docker info > /dev/null
    - echo -n "$MAESTRO_APPS_TOKEN" | docker login "$MAESTRO_APPS_REGISTRY" -u "$MAESTRO_APPS_USER" --password-stdin
    - docker pull registry.ubitech.eu/nsit/maestro-apps/golang:1.24
    - docker pull registry.ubitech.eu/nsit/maestro-apps/debian
  script:
    - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
    - >
      docker build 
      --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"'

dev_deploy_job:
  stage: dev_deploy
  image:
    name: registry.ubitech.eu/nsit/maestro-apps/python-argocd:3.9
    pull_policy: [always, if-not-present]
  before_script:
    - git clone --depth 1 --branch gitops-cd https://oauth2:$INSTALLER_TOKEN@$INSTALLER_REPO
    - cd $INSTALLER_PATH
  script: 
    - python3 scripts/helm_update.py $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_SHORT_SHA $DEV_TMF_API_IMAGE $DEV_SONATA_OSS_IMAGE $DEV_SONATA_CORE_IMAGE $DEV_ZTC_CLIENT_IMAGE $DEV_PORTAL_CART_IMAGE $DEV_TELEMETRY_IMAGE $DEV_PEERING_IMAGE $DEV_REGISTRY_IMAGE $DEV_FABRIC_IMAGE $DEV_PORTAL
    - git add .
    - git config --global user.email "$GITLAB_USER_NAME"
    - git config --global user.name "$GITLAB_USER_EMAIL"
    - |
      if git commit -m "Update values.yaml for GitOps CD [skip ci]"; then
        git push origin gitops-cd
      else
        echo "No changes to commit."
      fi
    - |
      set -e
      argocd login "$ARGOCD_SERVER" --username "$ARGOCD_USERNAME" --password "$ARGOCD_PASSWORD" --insecure
      argocd app get hypo --refresh >/dev/null
      argocd app wait hypo --sync --health --timeout 120
      echo "Argo CD application 'hypo' is synced and healthy."
  dependencies:
     - dev_image_build_job
  rules:
     - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'

   

dev_workflows_job:
  stage: dev_workflows
  image: registry.ubitech.eu/nsit/maestro-apps/maven:3.9-eclipse-temurin-17
  before_script:
    # clone the integration tests repo
    - git clone --depth 1 "https://oauth2:$INTEGRATION_TOKEN@$INTEGRATION_REPO"
    - cd org.etsi.osl.hypo.ops.cicd.integration.tests
  script:
    - mvn -B -q test "-Dkarate.env=staging" "-Dkarate.options=--tags @smoke-e2e-workflow-private"
  dependencies:
    - dev_deploy_job
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'


semantic_versioning_job:
  image:
    name: registry.ubitech.eu/nsit/maestro-apps/node:lts
  stage: release
  variables:
    GITLAB_TOKEN: $GROUP_ACCESS_TOKEN
  before_script:
    - git fetch origin main
    - git reset --hard origin/main
  script:
    - npx -y
      -p @semantic-release/commit-analyzer@9.0.2
      -p @semantic-release/git@10.0.1
      -p @semantic-release/gitlab@9.5.0
      -p @semantic-release/release-notes-generator@10.0.3
      -p @semantic-release/exec@6.0.3
      -p @semantic-release/changelog@6.0.2
      -p conventional-changelog-conventionalcommits@5.0.0
      -p semantic-release@19.0.5
      semantic-release
    - RELEASE_VERSION=$(cat .next-release-version 2>/dev/null || echo "no-release")
    - echo "$RELEASE_VERSION" > release_version.txt
    - cat release_version.txt
  artifacts:
    paths:
      - release_version.txt
  rules:
    - if: '$CI_COMMIT_BRANCH == "main"'

image_build_job:
  stage: image_build
  image:
    name: registry.ubitech.eu/nsit/maestro-apps/docker:20.10.16
  services:
    - name: registry.ubitech.eu/nsit/maestro-apps/docker:20.10.16-dind
      command: [ "--tls=false" ]
      alias: docker
  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 -n "$MAESTRO_APPS_TOKEN" | docker login "$MAESTRO_APPS_REGISTRY" -u "$MAESTRO_APPS_USER" --password-stdin
    - docker pull registry.ubitech.eu/nsit/maestro-apps/golang:1.24
    - docker pull registry.ubitech.eu/nsit/maestro-apps/debian
  script:
    - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
    - >
      docker build 
      --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 tag $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE/$IMAGE_NAME:latest
    - docker tag $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE/$IMAGE_NAME:$RELEASE_VERSION
    - docker push $CI_REGISTRY_IMAGE/$IMAGE_NAME:latest
    - docker push $CI_REGISTRY_IMAGE/$IMAGE_NAME:$RELEASE_VERSION
  rules:
    - if: '$CI_COMMIT_BRANCH == "main"'
  dependencies:
    - semantic_versioning_job
 No newline at end of file

.releaserc.json

0 → 100644
+34 −0
Changes for .releaserc.json: 34 added lines, 0 removed lines.
Original line number Diff line number Diff line
{
  "branches": [
    "main"
  ],
  "plugins": [
    ["@semantic-release/commit-analyzer", {
      "preset": "conventionalcommits",
      "presetConfig": {
        "types": [
          {"type": "feat", "section": "Features"},
          {"type": "fix", "section": "Bug Fixes"},
          {"type": "chore", "hidden": true},
          {"type": "docs", "hidden": true},
          {"type": "style", "hidden": true},
          {"type": "refactor", "hidden": true},
          {"type": "perf", "hidden": true},
          {"type": "test", "hidden": true}
        ],
        "issueUrlFormat": "https://gitlab.ubitech.eu/maestro-v2/mdg-hypo/org.etsi.osl.hypo.core/org.etsi.osl.hypo.core.pkg-manager.helm/-/issues/{{id}}"
      }
    }],
    "@semantic-release/release-notes-generator",
    ["@semantic-release/gitlab", {
      "gitlabUrl": "https://gitlab.ubitech.eu"
    }],
    ["@semantic-release/changelog",{
        "changelogFile": "./CHANGELOG.md"
    }],
    ["@semantic-release/exec", {
      "verifyReleaseCmd": "echo ${nextRelease.version} > .next-release-version"
    }],
    "@semantic-release/git"
  ]
}
 No newline at end of file

CHANGELOG.md

0 → 100644
+510 −0

File added.

Preview size limit exceeded, changes collapsed.

README.md

0 → 100644
+429 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading