内容简介:主要 GOPROXY设置默认集成了很多开箱即用的linter
pipeline流程
- 使用golangci-lint 检查代码
- 编译代码
- 部署二进制
before_script 设置环境变量
主要 GOPROXY设置
before_script: - echo "before_script" - git version - go env -w GOPRIVATE=code.haiziwang.com - mkdir -p .go - go version - go env -w GO111MODULE=on - go env -w GOPROXY="https://goproxy.io,direct"
golangci-lint
默认集成了很多开箱即用的linter
golangci-lint:
image: golangci/golangci-lint:v1.27.0
stage: lint
extends: .go-cache
allow_failure: true
script:
- golangci-lint run -v
allow_failure 表示失败了可以继续跑后续的job
编译
compile:
stage: build
extends: .go-cache
script:
- go mod download
- go build -race -o $OUTPUT_NAME
artifacts:
paths:
- $OUTPUT_NAME
缓存 go mod
.go-cache:
variables:
GOPATH: $CI_PROJECT_DIR/.go
cache:
paths:
- .go/pkg/mod/
full example
# This file is a template, and might need editing before it works on your project.
image: hub-mirror.c.163.com/library/golang:latest
.go-cache:
variables:
GOPATH: $CI_PROJECT_DIR/.go
cache:
paths:
- .go/pkg/mod/
variables:
OUTPUT_NAME: helloworld-app
stages:
- lint
- build
- deploy
before_script:
- echo "before_script"
- git version
- go env -w GOPRIVATE=code.haiziwang.com
- mkdir -p .go
- go version
- go env -w GO111MODULE=on
- go env -w GOPROXY="https://goproxy.io,direct"
golangci-lint:
image: golangci/golangci-lint:v1.27.0
stage: lint
extends: .go-cache
allow_failure: true
script:
- golangci-lint run -v
compile:
stage: build
extends: .go-cache
script:
- go mod download
- go build -race -o $OUTPUT_NAME
artifacts:
paths:
- $OUTPUT_NAME
deploy-dev:
stage: deploy
script:
- echo "deploy dev environment"
欢迎关注我们的微信公众号,每天学习 Go 知识
以上所述就是小编给大家介绍的《golang项目 配置Gitlab CI》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
深入浅出React和Redux
程墨 / 机械工业出版社 / 2017-4-28 / 69
本书作者是资深开发人员,有过多年的开发经验,总结了自己使用React和Redux的实战经验,系统分析React和Redux结合的优势,与开发技巧,为开发大型系统提供参考。主要内容包括:React的基础知识、如何设计易于维护的React组件、如何使用Redux控制数据流、React和Redux的相结合的方式、同构的React和Redux架构、React和Redux的性能优化、组件的测试等。一起来看看 《深入浅出React和Redux》 这本书的介绍吧!