-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
66 lines (61 loc) · 1.4 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
default:
image: reg.agarg.me/build/golang:latest-1.18.2-bullseye
tags:
- agarg-public-projects
stages:
- test
- build
- release
.global-vars:
variables:
GOOS: linux
GOARCH: amd64
SCHISM_BIN: schism-lambda-${CI_COMMIT_REF_NAME}
fmt-vet-test:
stage: test
extends:
- .global-vars
before_script:
- go get ./...
- go mod vendor
script:
- fmt_output=$(find -name vendor -prune -o -type f -name '*.go' -print0 | xargs -0 gofmt -l)
- echo "${fmt_output}"
- test -z "${fmt_output}"
- go vet ./...
- go test -cover -coverprofile cover.out ./...
- go tool cover -func cover.out | awk '/total:/ {print $1" "$2" "$3}; /.go/{print $0}'
artifacts:
paths:
- vendor/
expire_in: 1 hour
compile:
stage: build
extends:
- .global-vars
script:
- go build -mod=vendor -ldflags "-extldflags '-static'" -o "${CI_PROJECT_DIR}/${SCHISM_BIN}" ./cmd...
- zip "${SCHISM_BIN}".zip "${SCHISM_BIN}"
artifacts:
name: "compile_to_publish-$CI_COMMIT_REF_SLUG"
expose_as: compile_to_publish
paths:
- ${SCHISM_BIN}.zip
- .ci/publish
expire_in: 1 hour
dependencies:
- fmt-vet-test
release:
stage: release
extends:
- .global-vars
variables:
GIT_STRATEGY: none
script:
- sh .ci/publish
dependencies:
- compile
rules:
- if: $CI_COMMIT_REF_PROTECTED == "true"
when: always
- when: never