proses saluran paip
- Gunakan golangci-lint untuk menyemak kod
- Kompil Kod
- Gunakan Binari
sebelum_skrip Tetapkan Pembolehubah Persekitaran
Tetapan GOPROXY Utama
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"
Salin selepas log masuk
golangci-lint
Default Bersepadu banyak serpihan luar kotak
https://golangci-lint.run/
golangci-lint: image: golangci/golangci-lint:v1.27.0 stage: lint extends: .go-cache allow_failure: true script: - golangci-lint run -v
Salin selepas log masuk
allow_failure bermakna anda boleh terus berlari jika gagal Kerja berikutnya
kompilasi
compile: stage: build extends: .go-cache script: - go mod download - go build -race -o $OUTPUT_NAME artifacts: paths: - $OUTPUT_NAME
Salin selepas log masuk
mod cache go
.go-cache: variables: GOPATH: $CI_PROJECT_DIR/.go cache: paths: - .go/pkg/mod/
Salin selepas log masuk
contoh penuh
# 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"
Salin selepas log masuk