Skip to content
Commits on Source (11)
include:
- project: 'to-be-continuous/tools/gitlab-ci'
ref: 'master'
file: '/templates/extract.yml'
- project: 'to-be-continuous/tools/gitlab-ci'
ref: 'master'
file: '/templates/validation.yml'
- project: 'to-be-continuous/kicker'
ref: 'master'
file: '/templates/validation.yml'
- project: 'to-be-continuous/bash'
ref: '3.4'
file: '/templates/gitlab-ci-bash.yml'
- project: 'to-be-continuous/semantic-release'
ref: '3.8'
file: '/templates/gitlab-ci-semrel.yml'
- component: git.code.tecnalia.com/smartdatalab/public/ci-cd-components/gitlab-ci/extract@master
inputs:
extract-script-job-tags: ["docker"]
- component: git.code.tecnalia.com/smartdatalab/public/ci-cd-components/gitlab-ci/validation@master
inputs:
check-links-job-tags: ["docker"]
tbc-check-job-tags: ["docker"]
tbc-check-image: cicd-docker-dev.artifact.tecnalia.com/tbc-check:master
gitlab-ci-lint-job-tags: ["docker"]
- component: git.code.tecnalia.com/smartdatalab/public/ci-cd-components/kicker/validation@master
inputs:
kicker-validation-job-tags: ["docker"]
schema-base-url: "https://git.code.tecnalia.com/api/v4/projects/smartdatalab%2Fpublic%2Fci-cd-components%2Fkicker/repository/files"
- component: git.code.tecnalia.com/smartdatalab/public/ci-cd-components/bash/gitlab-ci-bash@master
inputs:
bash-shellcheck-job-tags: ["docker"]
- component: git.code.tecnalia.com/smartdatalab/public/ci-cd-components/semantic-release/gitlab-ci-semrel@master
inputs:
semantic-release-job-tags: ["docker"]
stages:
- build
......@@ -22,6 +26,7 @@ stages:
variables:
GITLAB_CI_FILES: "templates/gitlab-ci-golang.yml"
BASH_SHELLCHECK_FILES: "*.sh"
GIT_STRATEGY: clone
semantic-release:
rules:
......
## [4.9.1](https://git.code.tecnalia.com/smartdatalab/public/ci-cd-components/golang/compare/4.9.0...4.9.1) (2024-07-02)
### Bug Fixes
* **workflow:** disable MR pipeline from prod & integ branches ([de9419c](https://git.code.tecnalia.com/smartdatalab/public/ci-cd-components/golang/commit/de9419ce66b9dcbc10a8cdcb6b15e52f8aae43e2))
## [4.9.1](https://gitlab.com/to-be-continuous/golang/compare/4.9.0...4.9.1) (2024-05-05)
### Bug Fixes
* **workflow:** disable MR pipeline from prod & integ branches ([de9419c](https://gitlab.com/to-be-continuous/golang/commit/de9419ce66b9dcbc10a8cdcb6b15e52f8aae43e2))
# [4.9.0](https://gitlab.com/to-be-continuous/golang/compare/4.8.3...4.9.0) (2024-04-09)
......
......@@ -14,7 +14,7 @@ Add the following to your `gitlab-ci.yml`:
```yaml
include:
# 1: include the component
- component: gitlab.com/to-be-continuous/golang/gitlab-ci-golang@4.9.0
- component: gitlab.com/to-be-continuous/golang/gitlab-ci-golang@4.9.1
# 2: set/override component inputs
inputs:
image: "registry.hub.docker.com/library/golang:buster" # ⚠ this is only an example
......@@ -28,7 +28,7 @@ Add the following to your `gitlab-ci.yml`:
include:
# 1: include the template
- project: 'to-be-continuous/golang'
ref: '4.9.0'
ref: '4.9.1'
file: '/templates/gitlab-ci-golang.yml'
variables:
......@@ -57,6 +57,7 @@ It is disable by default and can be enabled by setting the `GO_GENERATE_MODULES`
| Input / Variable | Description | Default value |
|------------------|------------------------------------------------------------------------------------------------------------|-----------------|
| `generate-modules` / `GO_GENERATE_MODULES` | Space separated list of Go code generator modules (ex: `stringer mockery`) | _none_ (disabled) |
| `go-generate-job-tags` / `GO_GENERATE_JOB_TAGS` | Tags to be used for selecting runners for the job | `[]` |
#### Capture generated files as job artifacts
......@@ -144,6 +145,9 @@ These jobs use the following variable:
| `target-os` / `GO_TARGET_OS` | The `GOOS` target [see available values](https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63) | _none_ (fallback to go docker image `GOOS`) |
| `target-arch` / `GO_TARGET_ARCH` | The `GOARCH` target [see available values](https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63) | _none_ (fallback to go docker image `GOARCH`) |
| `cobertura-flags` / `GO_COBERTURA_FLAGS` | The `GOFLAGS` to use with `gocover-cobertura` if needed | _none_ |
| `go-build-job-tags` / `GO_BUILD_JOB_TAGS` | Tags to be used for selecting runners for the job | `[]` |
| `go-test-job-tags` / `GO_TEST_JOB_TAGS` | Tags to be used for selecting runners for the job | `[]` |
| `go-build-test-job-tags` / `GO_BUILD_TEST_JOB_TAGS` | Tags to be used for selecting runners for the job | `[]` |
In addition to a textual report in the console, the test jobs produce the following reports, kept for one day:
......@@ -166,6 +170,7 @@ It is bound to the `build` stage, and uses the following variables:
| `ci-lint-image` / `GO_CI_LINT_IMAGE` | The Docker image used to run `golangci-lint` | `registry.hub.docker.com/golangci/golangci-lint:latest-alpine` |
| `ci-lint-args` / `GO_CI_LINT_ARGS` | `golangci-lint` [command line arguments](https://github.com/golangci/golangci-lint#command-line-options) | `-E gosec,goimports ./...` |
| `ci-lint-disabled` / `GO_CI_LINT_DISABLED` | Set to `true` to disable this job | _none_ (enabled) |
| `go-ci-lint-job-tags` / `GO_CI_LINT_JOB_TAGS` | Tags to be used for selecting runners for the job | `[]` |
In addition to a textual report in the console, this job produces the following reports, kept for one day:
......@@ -183,6 +188,7 @@ It is bound to the `test` stage, and uses the following variables:
| Input / Variable | Description | Default value |
|------------------------|-----------------------------------------------------------------------------------------------|-------------------|
| `mod-outdated-args` / `GO_MOD_OUTDATED_ARGS` | `god-mod-outdated` [command line arguments](https://github.com/psampaz/go-mod-outdated#usage) | `-update -direct` |
| `go-mod-outdated-job-tags` / `GO_MOD_OUTDATED_JOB_TAGS` | Tags to be used for selecting runners for the job | `[]` |
Checking outdated modules can be a long operation and therefore the job is configured to be ran **manually** by default (overridable).
......@@ -230,6 +236,7 @@ It is bound to the `test` stage, and uses the following variables:
| `sbom-disabled` / `GO_SBOM_DISABLED` | Set to `true` to disable this job | _none_ |
| `sbom-image` / `GO_SBOM_IMAGE` | Image of cyclonedx-gomod used for SBOM analysis | `registry.hub.docker.com/cyclonedx/cyclonedx-gomod:latest` |
| `sbom-opts` / `GO_SBOM_OPTS` | [@cyclonedx/cyclonedx-gomod options](https://github.com/CycloneDX/cyclonedx-gomod#usage) used for SBOM analysis | `-main .` |
| `go-sbom-job-tags` / `GO_SBOM_JOB_TAGS` | Tags to be used for selecting runners for the job | `[]` |
:warning: if you don't have your main class located at the root of your `GO_PROJECT_DIR`, then you will need to override the `-main` option in `GO_SBOM_OPTS` and define your real main class location.
......@@ -249,4 +256,5 @@ It is bound to the `test` stage, and uses the following variables:
| Input / Variable | Description | Default value |
| --------------------- | -------------------------------------- | ----------------- |
| `vulncheck-disabled` / `GO_VULNCHECK_DISABLED` | Set to `true` to disable this job | _none_
| `vulncheck-args` / `GO_VULNCHECK_ARGS` | `govulncheck` [command line arguments](https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck#hdr-Flags) | `./...` |
\ No newline at end of file
| `vulncheck-args` / `GO_VULNCHECK_ARGS` | `govulncheck` [command line arguments](https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck#hdr-Flags) | `./...` |
| `go-govulncheck-job-tags` / `GO_GOVULNCHECK_JOB_TAGS` | Tags to be used for selecting runners for the job | `[]` |
\ No newline at end of file
......@@ -33,7 +33,7 @@ if [[ "$curVer" ]]; then
# replace in template and variants
for tmpl in templates/*.yml
do
sed -e "s/command: *\[\"--service\", \"\(.*\)\", \"$curVer\"\]/command: [\"--service\", \"\1\", \"$nextVer\"]/" "$tmpl" > "$tmpl.next"
sed -e "s/command: *\[ *\"--service\", *\"\(.*\)\", *\"$curVer\" *\]/command: [\"--service\", \"\1\", \"$nextVer\"]/" "$tmpl" > "$tmpl.next"
mv -f "$tmpl.next" "$tmpl"
done
else
......
......@@ -87,6 +87,27 @@
"name": "GO_COBERTURA_FLAGS",
"description": "Build flags to add to use gocover-cobertura, leave blank if not needed",
"advanced": true
},
{
"name": "GO_GO_BUILD_JOB_TAGS",
"description": "Tags to be used for selecting runners for the job",
"type": "array",
"default": [],
"advanced": true
},
{
"name": "GO_GO_TEST_JOB_TAGS",
"description": "Tags to be used for selecting runners for the job",
"type": "array",
"default": [],
"advanced": true
},
{
"name": "GO_GO_BUILD_TEST_JOB_TAGS",
"description": "Tags to be used for selecting runners for the job",
"type": "array",
"default": [],
"advanced": true
}
],
"features": [
......@@ -99,6 +120,13 @@
"name": "GO_GENERATE_MODULES",
"description": "Space separated list of Go code generator modules (ex: `stringer mockery`)",
"mandatory": true
},
{
"name": "GO_GO_GENERATE_JOB_TAGS",
"description": "Tags to be used for selecting runners for the job",
"type": "array",
"default": [],
"advanced": true
}
]
},
......@@ -118,6 +146,13 @@
"description": "`golangci-lint` [command line arguments](https://github.com/golangci/golangci-lint#command-line-options)",
"default": "-E gosec,goimports ./...",
"advanced": true
},
{
"name": "GO_GO_CI_LINT_JOB_TAGS",
"description": "Tags to be used for selecting runners for the job",
"type": "array",
"default": [],
"advanced": true
}
]
},
......@@ -131,6 +166,13 @@
"description": "`god-mod-outdated` [command line arguments](https://github.com/psampaz/go-mod-outdated#usage",
"default": "-update -direct",
"advanced": true
},
{
"name": "GO_GO_MOD_OUTDATED_JOB_TAGS",
"description": "Tags to be used for selecting runners for the job",
"type": "array",
"default": [],
"advanced": true
}
]
},
......@@ -149,6 +191,13 @@
"description": "[@cyclonedx/cyclonedx-gomod options](https://github.com/CycloneDX/cyclonedx-gomod#usage) used for SBOM analysis",
"default": "-main .",
"advanced": true
},
{
"name": "GO_GO_SBOM_JOB_TAGS",
"description": "Tags to be used for selecting runners for the job",
"type": "array",
"default": [],
"advanced": true
}
]
},
......@@ -163,6 +212,13 @@
"description": "`govulncheck` [command line arguments](https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck#hdr-Flags)",
"default": "./...",
"advanced": true
},
{
"name": "GO_GO_GOVULNCHECK_JOB_TAGS",
"description": "Tags to be used for selecting runners for the job",
"type": "array",
"default": [],
"advanced": true
}
]
}
......
......@@ -100,11 +100,47 @@ spec:
vulncheck-args:
description: '`govulncheck` [command line arguments](https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck#hdr-Flags)'
default: ./...
go-generate-job-tags:
description: tags to filter applicable runners for go-generate job
type: array
default: []
go-build-job-tags:
description: tags to filter applicable runners for go-build job
type: array
default: []
go-test-job-tags:
description: tags to filter applicable runners for go-test job
type: array
default: []
go-build-test-job-tags:
description: tags to filter applicable runners for go-build-test job
type: array
default: []
go-ci-lint-job-tags:
description: tags to filter applicable runners for go-ci-lint job
type: array
default: []
go-mod-outdated-job-tags:
description: tags to filter applicable runners for go-mod-outdated job
type: array
default: []
go-sbom-job-tags:
description: tags to filter applicable runners for go-sbom job
type: array
default: []
go-govulncheck-job-tags:
description: tags to filter applicable runners for go-govulncheck job
type: array
default: []
---
workflow:
rules:
# prevent branch pipeline when an MR is open (prefer MR pipeline)
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
# prevent MR pipeline originating from production or integration branch(es)
- if: '$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME =~ $PROD_REF || $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME =~ $INTEG_REF'
when: never
# on non-prod, non-integration branches: prefer MR pipeline over branch pipeline
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_COMMIT_REF_NAME !~ $PROD_REF && $CI_COMMIT_REF_NAME !~ $INTEG_REF'
when: never
- if: '$CI_COMMIT_MESSAGE =~ "/\[(ci skip|skip ci) on ([^],]*,)*tag(,[^],]*)*\]/" && $CI_COMMIT_TAG'
when: never
......@@ -459,7 +495,7 @@ stages:
image: $GO_IMAGE
services:
- name: "$TBC_TRACKING_IMAGE"
command: ["--service", "golang", "4.7.0" ]
command: ["--service", "golang", "4.9.1"]
variables:
# The directory where 'go install' will install a command.
GOBIN: "$CI_PROJECT_DIR/$GO_PROJECT_DIR/bin"
......@@ -498,6 +534,7 @@ go-generate:
- "${GO_PROJECT_DIR}/**/mock/"
- "${GO_PROJECT_DIR}/**/mocks/"
- "${GO_PROJECT_DIR}/**/*mock*.go"
tags: $[[ inputs.go-generate-job-tags ]]
go-build:
extends: .go-base
......@@ -512,6 +549,7 @@ go-build:
rules:
# if $GO_TEST_IMAGE set
- if: '$GO_TEST_IMAGE'
tags: $[[ inputs.go-build-job-tags ]]
go-test:
extends: .go-base
......@@ -538,6 +576,7 @@ go-test:
- if: '$GO_TEST_IMAGE == ""'
when: never
- !reference [.test-policy, rules]
tags: $[[ inputs.go-test-job-tags ]]
go-build-test:
extends: .go-base
......@@ -564,6 +603,7 @@ go-build-test:
rules:
# if $GO_TEST_IMAGE not set
- if: '$GO_TEST_IMAGE == ""'
tags: $[[ inputs.go-build-test-job-tags ]]
go-ci-lint:
extends: .go-base
......@@ -587,6 +627,7 @@ go-ci-lint:
- if: '$GO_CI_LINT_DISABLED == "true"'
when: never
- !reference [.test-policy, rules]
tags: $[[ inputs.go-ci-lint-job-tags ]]
go-mod-outdated:
extends: .go-base
......@@ -615,6 +656,7 @@ go-mod-outdated:
# else manual & non-blocking
- when: manual
allow_failure: true
tags: $[[ inputs.go-mod-outdated-job-tags ]]
go-sbom:
extends: .go-base
......@@ -651,6 +693,7 @@ go-sbom:
- if: '$GO_SBOM_DISABLED == "true"'
when: never
- !reference [.test-policy, rules]
tags: $[[ inputs.go-sbom-job-tags ]]
go-govulncheck:
extends: .go-base
......@@ -665,3 +708,4 @@ go-govulncheck:
- if: '$GO_VULNCHECK_DISABLED == "true"'
when: never
- !reference [.test-policy, rules]
tags: $[[ inputs.go-govulncheck-job-tags ]]