httprouter/.gitlab-ci.yml
Martin Riedl fda5e96ceb
increase go version to 1.19
BREAKING CHANGE: requires at least go 1.19 (instead of 1.16 as before)
2024-07-01 23:18:24 +02:00

97 lines
2.3 KiB
YAML

image: golang:1.19
stages:
- test
- sonarcloud
- build
checks:
stage: test
script:
- go fmt $(go list ./...)
- go vet $(go list ./...)
code coverage:
stage: test
script:
- go install honnef.co/go/tools/cmd/staticcheck@latest
- go fmt $(go list ./...)
- go vet $(go list ./...)
- staticcheck ./...
- go test -coverprofile coverage.cov -p 1 $(go list ./...)
- go tool cover -html=coverage.cov -o coverage.html
- go tool cover -func=coverage.cov
coverage: '/\(statements\)\W+\d+\.\d+%/'
artifacts:
paths:
- coverage.cov
- coverage.html
codecov.io:
stage: test
script:
- curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --import
- curl -Os https://uploader.codecov.io/latest/linux/codecov
- curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM
- curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig
- gpg --verify codecov.SHA256SUM.sig codecov.SHA256SUM
- shasum -a 256 -c codecov.SHA256SUM
- chmod +x codecov
- go test -race -coverprofile=coverage.out -covermode=atomic
- ./codecov -t ${CODECOV_TOKEN}
rules:
- if: $CODECOV_TOKEN
when: on_success
# stage "sonarcloud" is only needed because of this issue:
# https://gitlab.com/gitlab-org/gitlab/-/issues/30632
sonarcloud-check:
stage: test
needs:
- checks
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- sonar-scanner
allow_failure: true
# build template
# execute the following command for all os/arch combinations: go tool dist list
.compile:
stage: build
# no dependencies -> no download of artifacts from previous jobs/stages
dependencies: []
script:
- go build .
darwin-amd64:
extends: .compile
variables:
GOOS: "darwin"
GOARCH: "amd64"
linux-amd64:
extends: .compile
variables:
GOOS: "linux"
GOARCH: "amd64"
linux-arm64:
extends: .compile
variables:
GOOS: "linux"
GOARCH: "arm64"
windows-amd64:
extends: .compile
variables:
GOOS: "windows"
GOARCH: "amd64"