Last active
October 13, 2022 11:52
-
-
Save ptflp/83d8bfe50351dbfcd499b760cf6b7138 to your computer and use it in GitHub Desktop.
Kata Golang gitalb CI/CD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is a template, and might need editing before it works on your project. | |
image: golang:latest | |
variables: | |
# Please edit to your GitLab project | |
REPO_NAME: gitlab.com/ptflp/go-kata | |
GIT_DEPTH: 10 | |
stages: | |
- lint | |
- test | |
- build | |
.go-cache: | |
before_script: | |
- mkdir -p $GOPATH/src/$(dirname $REPO_NAME) | |
- ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME | |
- cd $GOPATH/src/$REPO_NAME | |
- go mod download -json | |
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.49.0 | |
- golangci-lint --version | |
cache: | |
key: "$CI_COMMIT_REF_SLUG" | |
paths: | |
- $GOPATH | |
lint: | |
stage: lint | |
extends: .go-cache | |
script: | |
- go fmt $(go list ./... | grep -v /vendor/) | |
- go vet $(go list ./... | grep -v /vendor/) | |
- golangci-lint run --skip-dirs docs | |
test: | |
stage: test | |
extends: .go-cache | |
script: | |
- go test -race $(go list ./... | grep -v /vendor/) | |
compile: | |
stage: build | |
extends: .go-cache | |
script: | |
- go build -race -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/app | |
artifacts: | |
paths: | |
- app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment