forked from l0k18/kcp9
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
145 lines (141 loc) · 6.17 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
###################### Begin Defaults
stages:
- all
variables:
GIT_DEPTH: 0
GIT_STRATEGY: clone
default:
before_script:
- |
# before_script
echo "Starting before_script actions."
echo "Finished before_script actions."
after_script:
- |
# after_script
echo "Starting after_script actions."
echo "Finished after_script actions."
###################### End Defaults
###################### Begin Common Blocks
.scriptCommon: &scriptCommon |
# scriptCommon
echo "Project Name : $CI_PROJECT_TITLE"
echo "Project Git Commit : $CI_COMMIT_SHA"
echo "Project Git Branch : $CI_COMMIT_BRANCH"
echo "GitLab CI User Details : $GITLAB_USER_LOGIN - $GITLAB_USER_NAME ($GITLAB_USER_ID) $GITLAB_USER_EMAIL"
echo "GitLab CI Job Name : $CI_JOB_NAME"
echo "GitLab CI Job ID : $CI_JOB_ID"
echo "GitLab CI Job Stage : $CI_JOB_STAGE"
echo "GitLab CI Runner Details : $CI_RUNNER_VERSION ($CI_RUNNER_REVISION)"
.scriptGoVersion: &scriptGoVersion |
# scriptGoVersion
echo "Go Compiler Version:"
go version
echo "Go Default Environment:"
go env
echo "Go Current Environment:"
go tool dist env -p
.scriptGitPre: &scriptGitPre |
# scriptGitPre
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git --no-pager fetch --tags
git --no-pager fetch --all --recurse-submodules=yes
git --no-pager update-index -q --refresh --really-refresh
git --no-pager for-each-ref --count=1
git --no-pager reset --hard
git --no-pager diff --full-index --exit-code
###################### End Common Blocks
###################### Begin Windows Build + Test
windows job:
tags:
- Windows-x86_64
stage: all
script:
- *scriptCommon
- $env:Path += ";C:\Program Files\Git\cmd;C:\Go\bin"
- $env:GO111MODULE="on"
- $env:GOPROXY="https://proxy.golang.org,direct"
- $env:CGO_ENABLED="0"
- *scriptGoVersion
- go clean -modcache -cache -r
- go mod download
- go mod verify
- *scriptGitPre
- go build -v -a -trimpath .\...
- |
# status
echo "Build completed successfully - running tests; coverage and race detector enabled"
echo "TODO: Port of full coverage tools to PowerShell"
- $env:CGO_ENABLED="1"
- go test -v -cover -covermode="atomic" -race -count="1" -cpu="2" -parallel="2" .\...
###################### End Windows Build + Test
###################### Begin Linux
linux job:
tags:
- Linux-x86_64
stage: all
script:
- *scriptCommon
- |
# upgrade system, install development tools
- yum install dnf -y
- yum clean all -y
- dnf upgrade --refresh -y
- dnf groupinstall "Development Tools" -y
- dnf install epel-release centos-release-scl centos-release-scl-rh -y
- dnf install ccache pv valgrind graphviz clang zsh scl-utils devtoolset-9 -y
- dnf groupupdate base -y
- source /opt/rh/devtoolset-9/enable
- dnf clean all -y
- |
# gimme go 1.15.6
bash --norc --noprofile --posix -o pipefail -c "set -e && mkdir -p /tools/bin && curl -fsSL -o /tools/bin/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gimme && chmod a+x /tools/bin/gimme"
bash --norc --noprofile --posix -o pipefail -c "set -e && mkdir -p /tools/gimme && GIMME_SILENT_ENV=1 GIMME_ENV_PREFIX=/tools/gimme/env GIMME_VERSION_PREFIX=/tools/gimme/ver GIMME_GO_VERSION=1.15.6 GIMME_CGO_ENABLED=1 /tools/bin/gimme" > /tools/genv && source /tools/genv
- source /tools/genv
- go env -w GO111MODULE=on && export GO111MODULE=on
- export GOPROXY="https://proxy.golang.org,direct" && go env -w GOPROXY="${GOPROXY:?}"
- *scriptGoVersion
- go clean -modcache -cache -r -x
- *scriptGitPre
- CGO_ENABLED=0 go build -v -a -trimpath $(go list ./... | grep -v test | sort | uniq)
- |
# status
echo "Build completed successfully - running race-enabled testing."
- CGO_ENABLED=1 go test -v -a -cover -covermode=atomic -race -count=1 -cpu=2 -parallel=2 $(go list ./... | grep -v test | sort | uniq)
###################### End Linux Build + Test
###################### Begin macOS Build + Test
macos job:
tags:
- macOS_X-x86_64
stage: all
script:
- |
# update tools
bash --norc --noprofile --posix -c "brew update || true" || true
bash --norc --noprofile --posix -c "brew upgrade || true" || true
- *scriptCommon
- if type brew >/dev/null 2>&1; then export HOMEBREW_PREFIX=$(brew --prefix 2>/dev/null); for dir in ${HOMEBREW_PREFIX:?}/opt/*/libexec/gnubin; do export PATH="${dir:?}:${PATH:?}"; done; fi
- export PATH="/usr/local/opt/gcc/bin:${PATH:?}"
- go env -w GO111MODULE=on && export GO111MODULE=on
- export GOPROXY="https://proxy.golang.org,direct" && go env -w GOPROXY="${GOPROXY:?}"
- export PRIVPATH=$(mktemp -d "${HOME:?}/.XXXXXXXXXXXXXXXX")
- export NEW_GOPATH=$(mktemp -d "${PRIVPATH:?}/XXXXXXXXXXXXXXXX")
- export NEW_GOCACHE=$(mktemp -d "${PRIVPATH:?}/XXXXXXXXXXXXXXXX")
- export NEW_GOMODCACHE=$(mktemp -d "${PRIVPATH:?}/XXXXXXXXXXXXXXXX")
- export GOPATH="${NEW_GOPATH:?}" && go env -w GOPATH="${NEW_GOPATH:?}"
- export GOCACHE="${NEW_GOCACHE:?}" && go env -w GOCACHE="${NEW_GOCACHE:?}"
- export GOMODCACHE="${NEW_GOMODCACHE:?}" && go env -w GOMODCACHE="${NEW_GOMODCACHE:?}"
- *scriptGoVersion
- go clean -testcache -modcache -cache -r -x
- *scriptGitPre
- GOMAXPROCS=8 CGO_ENABLED=0 go build -v -a -trimpath $(go list ./... | grep -v test | sort | uniq)
- |
# status
echo "Build completed successfully - running race-enabled tests."
- GOMAXPROCS=8 CGO_ENABLED=1 go test -v -a -cover -covermode=atomic -race -count=1 -cpu=2 -parallel=2 $(go list ./... | grep -v test | sort | uniq)
- |
# cleaning up
- chmod -R u+rwx "${GOPATH:?}"/* 2>/dev/null && rm -rf -- "${GOPATH:?}"/* 2>/dev/null || true :;
- chmod -R u+rwx "${GOCACHE:?}"/* 2>/dev/null && rm -rf -- "${GOCACHE:?}"/* 2>/dev/null || true :;
- chmod -R u+rwx "${GOMODCACHE:?}"/* 2>/dev/null && rm -rf -- "${GOMODCACHE:?}"/* 2>/dev/null || true :;
###################### End macOS Build + Test