-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
73 lines (64 loc) · 2.35 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
image: $CI_REGISTRY/autowp/runner-base-image
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: tcp://docker:2375
GIT_DEPTH: 0
stages:
- test
- publish
test:
stage: test
services:
- name: docker:dind
alias: docker
before_script:
- export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin
- export GOPATH=$HOME/go
script:
- go mod verify
- go mod download
- golangci-lint run ./... -v --timeout 10m
- waitforit -address=tcp://docker:2375 -timeout=30
- echo "$CI_REGISTRY_PASSWORD" | docker login "$CI_REGISTRY" -u="$CI_REGISTRY_USER" --password-stdin
- docker-compose up -d --quiet-pull
- ./tools/wait.sh
- go test -run TestAutowpMigrations
- go test -run TestPostgresMigrations
- docker exec -t goautowp_mysql_test sh -c "mysql -uroot --host=127.0.0.1 --port=3306 -ppassword autowp < /dump.sql"
- gotestsum --junitfile report.xml --format testname -- -coverpkg=./... -coverprofile=cov.out -covermode count ./...
- gocover-cobertura < cov.out > coverage.xml
- sonar-scanner -Dsonar.token="$SONAR_TOKEN"
- npx semantic-release
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
junit: report.xml
interruptible: true
rules:
- if: $CI_COMMIT_TAG !~ /^v\d.*/
publish:
stage: publish
before_script:
- git config --global user.email "$GITLAB_USER_EMAIL"
- git config --global user.name "$GITLAB_USER_NAME"
- echo "$CI_REGISTRY_PASSWORD" | buildah login "$CI_REGISTRY" -u="$CI_REGISTRY_USER" --password-stdin
- echo "$DOCKER_PASSWORD" | buildah login -u="$DOCKER_USERNAME" --password-stdin docker.io
script:
- buildah pull "$CI_REGISTRY_IMAGE" || true
- buildah build -f build/package/Dockerfile -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" -t autowp/goautowp:$CI_COMMIT_TAG .
- buildah push "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG"
- buildah push autowp/goautowp:$CI_COMMIT_TAG
- git clone -b master https://gitpush:${GITPUSH_TOKEN}@gitlab.pereslegin.ru/autowp/helm.git
- cd helm
- yq -i '.goautowp.image.tag = strenv(CI_COMMIT_TAG)' values.yaml
- git add values.yaml
- 'git commit -m "feat: Update go-backend to $CI_COMMIT_TAG"'
- git push origin master
rules:
- if: $CI_COMMIT_TAG =~ /^v\d.*/
environment:
name: production
url: https://www.wheelsage.org/