diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..af7ed1ad9868b1536f3d11b574b219c2ba897ddb --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,64 @@ +include: + # Golang template + - component: "git.code.tecnalia.com/smartdatalab/public/ci-cd-components/golang/gitlab-ci-golang@master" + inputs: + go-build-job-tags: ["docker"] + go-test-job-tags: ["docker"] + go-build-test-job-tags: ["docker"] + test-flags: -mod=readonly -v + go-ci-lint-job-tags: ["docker"] + go-mod-outdated-job-tags: ["docker"] + go-sbom-job-tags: ["docker"] + go-govulncheck-job-tags: ["docker"] + target-os: linux + target-arch: amd64 + ci-lint-disabled: false + ci-lint-args: --timeout 5m -E gosec,goimports ./... + sbom-disabled: false + vulncheck-disabled: false + # semantic-release template + - component: "git.code.tecnalia.com/smartdatalab/public/ci-cd-components/semantic-release/gitlab-ci-semrel@3" + inputs: + auto-release-enabled: true + release-disabled: false + semantic-release-job-tags: ["docker"] + branches-ref: "/^(master|main)$/" + # sonar template + - component: "git.code.tecnalia.com/smartdatalab/public/ci-cd-components/sonar/gitlab-ci-sonar@master" + inputs: + sonar-job-tags: ["docker"] + # gitleaks template + - component: "git.code.tecnalia.com/smartdatalab/public/ci-cd-components/gitleaks/gitlab-ci-gitleaks@master" + inputs: + gitleaks-job-tags: ["docker"] + +variables: + GIT_STRATEGY: clone + + # LOG_LEVEL: debug + +# variables in the GitLab CI/CD variables: + # GITLAB_TOKEN to support the semantic-release: it should have the api scope, read_repository, and write_repository permissions. It should act as maintainer if you have protected branches, and tags as it is the case. + # SONAR_TOKEN to support the sonar + # SONAR_HOST_URL to support the sonar + + +# Pipeline steps +stages: + - build + - test + - package-build + - package-test + - deploy + - acceptance + - publish + - production + +go-build-test: + variables: + CGO_ENABLED: 0 + +semantic-release: + dependencies: + - go-build-test + diff --git a/.releaserc.yaml b/.releaserc.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6b580d4fb1f53e01912d90e5cbbdbd520901f99e --- /dev/null +++ b/.releaserc.yaml @@ -0,0 +1,29 @@ +plugins: + - '@semantic-release/commit-analyzer' + - '@semantic-release/release-notes-generator' + - - '@semantic-release/gitlab' + - assets: + - path: bin/linux/amd64/docker-custom-network-mtu-changer + label: docker-custom-network-mtu-changer (linux/amd64) + # generates the CHANGELOG.md + - '@semantic-release/changelog' + # emulates bumpversion (replaces version in pyproject.toml) + - - semantic-release-replace-plugin + - replacements: + - files: + - cmd/config.yaml + from: + - 'version: *\d+\.\d+\.\d+' + to: 'version: ${nextRelease.version}' + countMatches: true + # git commit/push modified files (CHANGELOG.md & pyproject.toml) + - - '@semantic-release/git' + - assets: + - cmd/config.yaml + # the commit MUST trigger a pipeline on tag (to perform publish jobs) + # can be skipped on prod branch + message: 'chore(semantic-release): release ${nextRelease.version} - [ci skip on prod]' +branches: + - main + - master +tagFormat: '${version}' diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000000000000000000000000000000000000..bf4dbd989e57e641fabc629b0747fc00437896a3 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,22 @@ +# From sonar setup +sonar.projectKey=smartdatalab_public_ci-cd-tools_yajsv_AZGdSUIulLHl6KbDPfWr +sonar.qualitygate.wait=true + +# from golang component setup +# see: https://docs.sonarqube.org/latest/analyzing-source-code/test-coverage/test-execution-parameters/#go +# set your source directory(ies) here (relative to the sonar-project.properties file) +sonar.sources=. +# exclude unwanted directories and files from being analysed +sonar.exclusions=bin/**,**/*_test.go,**/vendor/** + +# set your tests directory(ies) here (relative to the sonar-project.properties file) +sonar.tests=. +sonar.test.inclusions=**/*_test.go +sonar.test.exclusions=**/vendor/** + +# tests report: JSON native format +sonar.go.tests.reportPaths=reports/go-test.native.json +# coverage report: native format +sonar.go.coverage.reportPaths=reports/go-coverage.native.out +# golanci-lint: checkstyle report (if enabled) +sonar.go.golangci-lint.reportPaths=reports/go-ci-lint.checkstyle.xml