Skip to content
Snippets Groups Projects
Unverified Commit 0892c151 authored by Andrew Newdigate's avatar Andrew Newdigate
Browse files

feat: add a golang template

parent ccde3a50
No related branches found
No related tags found
No related merge requests found
Pipeline #13620623 passed
stages:
- validate
- release
- renovate_bot
 
include:
- local: .gitlab-ci-asdf-versions.yml
Loading
Loading
Loading
Loading
@@ -27,18 +27,53 @@ Includes the following tasks:
stages:
- validate
- release
- renovate_bot
 
include:
# - local: .gitlab-ci-asdf-versions.yml
- local: .gitlab-ci-asdf-versions.yml
# This template should be included in all Infrastructure projects.
# It includes standard checks, gitlab-scanners, validations and release processes
# common to all projects using this template library.
# see https://gitlab.com/gitlab-com/gl-infra/common-ci-tasks/-/blob/main/README.md#templatesstandardyml
- project: 'gitlab-com/gl-infra/common-ci-tasks'
ref: v1.15.0 # renovate:managed
ref: v1.16.0 # renovate:managed
file: templates/standard.yml
```
 
### [`templates/golang.yml`](./templates/golang.yml)
This template should be used for Golang projects.
Includes the following tasks:
1. [`go-mod-tidy.yml`](#go-mod-tidy): ensures that [`go mod tidy`](https://go.dev/ref/mod) is up-to-date and `go.mod` and `go.sum` are tidy.
1. [`go-unittests.yml`](#go-unittests): runs unit tests to ensure and emits a JUnit XML report for GitLab.
1. [`golangci-lint.yml`](#golangci-lint): runs [golangci-lint](https://github.com/golangci/golangci-lint) on the project.
1. [`goreleaser.yml`](#goreleaser): builds a binary release of the project using [GoReleaser](https://goreleaser.com/).
```yaml
# Requires stages validate and release
stages:
- validate
- release
# Better to define these through .gitlab-ci-asdf-versions.yml
variables:
GL_ASDF_GOLANG_VERSION: ...
GL_ASDF_GOLANGCI_LINT_VERSION: ...
GL_ASDF_GORELEASER_VERSION: ...
include:
- local: .gitlab-ci-asdf-versions.yml
# This template should be included in all Infrastructure projects.
# It includes standard checks, gitlab-scanners, validations and release processes
# common to all projects using this template library.
# see https://gitlab.com/gitlab-com/gl-infra/common-ci-tasks/-/blob/main/README.md#templatesgolangyml
- project: 'gitlab-com/gl-infra/common-ci-tasks'
ref: v1.16.0 # renovate:managed
file: templates/golang.yml
```
## CI Jobs
 
Alternatively to using the templates above, you can include the following individual jobs.
Loading
Loading
@@ -55,11 +90,13 @@ stages:
 
include:
- project: 'gitlab-com/gl-infra/common-ci-tasks'
ref: v1.15.0 # renovate:managed
ref: v1.16.0 # renovate:managed
file: 'gitlab-scanners.yml'
```
 
### `golangci_lint`
### [`golangci-lint`](./golangci-lint.yml)
Runs [golangci-lint](https://github.com/golangci/golangci-lint) on the project.
 
* Default Stage: `validate`
 
Loading
Loading
@@ -69,7 +106,7 @@ stages:
 
include:
- project: 'gitlab-com/gl-infra/common-ci-tasks'
ref: v1.15.0 # renovate:managed
ref: v1.16.0 # renovate:managed
file: 'golangci-lint.yml'
```
 
Loading
Loading
@@ -86,7 +123,7 @@ stages:
 
include:
- project: 'gitlab-com/gl-infra/common-ci-tasks'
ref: v1.15.0 # renovate:managed
ref: v1.16.0 # renovate:managed
file: 'editorconfig-check.yml'
```
 
Loading
Loading
@@ -127,13 +164,11 @@ stages:
 
include:
- project: 'gitlab-com/gl-infra/common-ci-tasks'
ref: v1.15.0 # renovate:managed
ref: v1.16.0 # renovate:managed
file: 'semantic-release.yml'
```
 
### `goreleaser`
* Default Stages: `validate`, `release`
### [`goreleaser`](./goreleaser.yml)
 
Including this template will build a binary release of the project using [GoReleaser](https://goreleaser.com/).
 
Loading
Loading
@@ -141,6 +176,8 @@ It runs on tag pipelines.
 
It requires a `.goreleaser.yml` file in the root of the project, which looks something like this:
 
* Default Stages: `validate`, `release`
```
before:
hooks:
Loading
Loading
@@ -209,7 +246,7 @@ variables:
include:
# build binary release artifacts with goreleaser
- project: 'gitlab-com/gl-infra/common-ci-tasks'
ref: v1.15.0 # renovate:managed
ref: v1.16.0 # renovate:managed
file: goreleaser.yml
```
 
Loading
Loading
@@ -238,7 +275,7 @@ include:
# and that ASDF is generally working
# see https://gitlab.com/gitlab-com/gl-infra/common-ci-tasks/-/blob/main/README.md#asdf-tool-versions
- project: 'gitlab-com/gl-infra/common-ci-tasks'
ref: v1.15.0 # renovate:managed
ref: v1.16.0 # renovate:managed
file: asdf-tool-versions.yml
```
 
Loading
Loading
@@ -272,7 +309,7 @@ include:
 
# Runs tflint on all terraform module directories
- project: 'gitlab-com/gl-infra/common-ci-tasks'
ref: v1.15.0 # renovate:managed
ref: v1.16.0 # renovate:managed
file: tflint.yml
```
 
Loading
Loading
@@ -296,7 +333,7 @@ include:
 
# Ensures that all terraform files are correctly formatted
- project: 'gitlab-com/gl-infra/common-ci-tasks'
ref: v1.15.0 # renovate:managed
ref: v1.16.0 # renovate:managed
file: terraform-format.yml
```
 
Loading
Loading
@@ -323,7 +360,7 @@ include:
 
# Ensures that all terraform files are syntactically valid
- project: 'gitlab-com/gl-infra/common-ci-tasks'
ref: v1.15.0 # renovate:managed
ref: v1.16.0 # renovate:managed
file: terraform-validate.yml
```
 
Loading
Loading
@@ -358,7 +395,7 @@ include:
# Upgrades dependencies on a schedule
# see https://gitlab.com/gitlab-com/gl-infra/common-ci-tasks/-/blob/main/README.md#renovate-bot
- project: 'gitlab-com/gl-infra/common-ci-tasks'
ref: v1.15.0 # renovate:managed
ref: v1.16.0 # renovate:managed
file: renovate-bot.yml
```
 
Loading
Loading
@@ -383,7 +420,7 @@ include:
# Runs Go unit tests
# see https://gitlab.com/gitlab-com/gl-infra/common-ci-tasks/-/blob/main/README.md#go-unittests
- project: 'gitlab-com/gl-infra/common-ci-tasks'
ref: v1.15.0 # renovate:managed
ref: v1.16.0 # renovate:managed
file: go-unittests.yml
```
 
Loading
Loading
@@ -408,7 +445,7 @@ include:
# Perform `go mod tidy` and ensure that go.mod and go.sum are tidy.
# see https://gitlab.com/gitlab-com/gl-infra/common-ci-tasks/-/blob/main/README.md#go-mod-tidy
- project: 'gitlab-com/gl-infra/common-ci-tasks'
ref: v1.15.0 # renovate:managed
ref: v1.16.0 # renovate:managed
file: go-mod-tidy.yml
```
 
Loading
Loading
include:
- local: go-mod-tidy.yml
- local: go-unittests.yml
- local: golangci-lint.yml
- local: goreleaser.yml
Loading
Loading
@@ -5,3 +5,4 @@ include:
- local: semantic-release.yml
- local: asdf-tool-versions.yml
- local: shfmt.yml
- local: renovate-bot.yml
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment