Add build via Gitlab CI
This commit is contained in:
parent
85c7109a85
commit
473071b929
51
.gitlab-ci.yml
Normal file
51
.gitlab-ci.yml
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
image: lab.wtfteam.pro:4567/containers/golangci-lint
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- test
|
||||||
|
- build
|
||||||
|
- deploy
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- go version
|
||||||
|
- mkdir -p $GOPATH/src/lab.wtfteam.pro/fat0troll/
|
||||||
|
- ln -s $(pwd) $GOPATH/src/lab.wtfteam.pro/fat0troll/fw_zookeeper
|
||||||
|
- cd $GOPATH/src/lab.wtfteam.pro/fat0troll/fw_zookeeper
|
||||||
|
- apk add --no-cache gcc libc-dev
|
||||||
|
|
||||||
|
lint:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- pwd
|
||||||
|
- golangci-lint run
|
||||||
|
|
||||||
|
test:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- pwd
|
||||||
|
- go test -test.v -cover `go list ./... | grep -v examples | grep -v internal`
|
||||||
|
|
||||||
|
build:
|
||||||
|
stage: build
|
||||||
|
script:
|
||||||
|
- pwd
|
||||||
|
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags netgo -ldflags '-w -extldflags "-static"'
|
||||||
|
artifacts:
|
||||||
|
untracked: true
|
||||||
|
expire_in: 4 hours
|
||||||
|
paths:
|
||||||
|
- fw_zookeeper
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
stage: deploy
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
before_script:
|
||||||
|
- apk add --no-cache openssh-client
|
||||||
|
- mkdir -p ~/.ssh
|
||||||
|
- echo "$DEPLOY_KEY" | tr -d '\r' > ~/.ssh/id_rsa
|
||||||
|
- chmod 600 ~/.ssh/id_rsa
|
||||||
|
- eval "$(ssh-agent -s)"
|
||||||
|
- ssh-add ~/.ssh/id_rsa
|
||||||
|
- ssh-keyscan -H $DEPLOY_HOST >> ~/.ssh/known_hosts
|
||||||
|
script:
|
||||||
|
- scp fw_zookeeper $DEPLOY_USER@$DEPLOY_HOST:/usr/local/bin/
|
4
golangci.yaml
Normal file
4
golangci.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
run:
|
||||||
|
deadline: 5m
|
||||||
|
linters:
|
||||||
|
enable-all: true
|
Reference in New Issue
Block a user