-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
config.yml
186 lines (172 loc) · 6.18 KB
/
config.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
version: 2
jobs:
deps:
docker:
- image: circleci/golang:1.13
environment:
GOPATH: /home/circleci/.go_workspace
working_directory: /home/circleci/.go_workspace/src/github.com/loadimpact/k6
steps:
- checkout
- run:
name: Check dependencies
command: |
go version
export PATH="$GOPATH/bin:$PATH"
mkdir -p "$GOPATH/bin"
curl --fail https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep version
dep status
case $(dep ensure 2>&1 | head -n 1) in Warning*) false ;; esac
dep check
test:
docker:
- image: circleci/golang:1.13
environment:
GOPATH: /home/circleci/.go_workspace
working_directory: /home/circleci/.go_workspace/src/github.com/loadimpact/k6
steps:
- checkout
- run:
name: Run tests and code coverage
command: |
go version
export GOMAXPROCS=2
export PATH=$GOPATH/bin:$PATH
echo "mode: set" > coverage.txt
for pkg in $(go list ./... | grep -v vendor); do
list=$(go list -test -f '{{ join .Deps "\n"}}' $pkg | grep github.com/loadimpact/k6 | grep -v vendor || true)
if [ -n "$list" ]; then
list=$(echo "$list" | cut -f1 -d ' ' | sort -u | paste -sd,)
fi
go test -race -timeout 800s --coverpkg="$list" -coverprofile=$(echo $pkg | tr / -).coverage $pkg
done
grep -h -v "^mode:" *.coverage >> coverage.txt
rm -f *.coverage
bash <(curl --fail -s https://codecov.io/bash)
test-prev-golang:
docker:
- image: circleci/golang:1.12
environment:
GOPATH: /home/circleci/.go_workspace
working_directory: /home/circleci/.go_workspace/src/github.com/loadimpact/k6
steps:
- checkout
- run:
name: Run tests with previous Go version
command: |
go version
export GOMAXPROCS=2
export PATH=$GOPATH/bin:$PATH
go test -p 2 -race -timeout 800s ./...
build-docker-images:
docker:
- image: circleci/golang:1.13
environment:
GOPATH: /home/circleci/.go_workspace
working_directory: /home/circleci/.go_workspace/src/github.com/loadimpact/k6
steps:
- checkout
- setup_remote_docker:
version: 17.11.0-ce
- run:
name: Setup repo and docker
command: |
git submodule update --init
docker info
echo "{\"https://index.docker.io/v1/\":{\"auth\":\"$DOCKER_AUTH\",\"email\":\"$DOCKER_EMAIL\"}}" >~/.dockercfg
- run:
name: Build application Docker image
command: |
docker build -t loadimpact/k6 .
- run:
name: Run tests on generated Docker image
command: |
docker run loadimpact/k6 --help
docker run loadimpact/k6 help
docker run loadimpact/k6 run --help
docker run loadimpact/k6 inspect --help
docker run loadimpact/k6 status --help
docker run loadimpact/k6 stats --help
docker run loadimpact/k6 scale --help
docker run loadimpact/k6 pause --help
docker run loadimpact/k6 resume --help
- deploy:
name: Push application Docker image
command: |
if [ "${CIRCLE_BRANCH}" == "master" ]; then
docker tag loadimpact/k6 loadimpact/k6:master
docker push loadimpact/k6:master
elif [[ "${CIRCLE_TAG}" =~ ^v[0-9]+(\.[0-9]+)*$ ]]; then
docker tag loadimpact/k6 loadimpact/k6:${CIRCLE_TAG:1}
docker push loadimpact/k6:latest
docker push loadimpact/k6:${CIRCLE_TAG:1}
fi
build-linux-packages:
docker:
- image: circleci/golang:1.13
environment:
GOPATH: /home/circleci/.go_workspace
working_directory: /home/circleci/.go_workspace/src/github.com/loadimpact/k6
steps:
- checkout
- run:
name: Build linux packages
command: |
export PATH=$GOPATH/bin:$PATH
go get github.com/Masterminds/glide
go get github.com/mh-cbon/go-bin-deb \
&& cd $GOPATH/src/github.com/mh-cbon/go-bin-deb \
&& glide install \
&& go install
go get github.com/mh-cbon/go-bin-rpm \
&& cd $GOPATHsrc/github.com/mh-cbon/go-bin-rpm \
&& glide install \
&& go install
sudo apt-get update -y
sudo apt-get install -y fakeroot rpm
cd $GOPATH/src/github.com/loadimpact/k6
echo "Building k6..."
CGO_ENABLED=0 GOARCH=$ARCH go build -a -ldflags '-s -w' -o /tmp/k6
echo "Done!"
VERSION=${CIRCLE_TAG:1} ./packaging/gen-packages.sh
- deploy:
name: Publish packages in Bintray
command: |
export VERSION=${CIRCLE_TAG:1}
# Publishing deb
curl --fail -H "X-GPG-PASSPHRASE: $GPG_PASSPHRASE" -T dist/k6-v$VERSION-amd64.deb "https://$BINTRAY_USER:[email protected]/content/loadimpact/deb/k6/$VERSION/k6-v$VERSION-amd64.deb;deb_distribution=stable;deb_component=main;deb_architecture=amd64;publish=1;override=1"
# Publishing rpm
curl --fail -H "X-GPG-PASSPHRASE: $GPG_PASSPHRASE" -T dist/k6-v$VERSION-amd64.rpm "https://$BINTRAY_USER:[email protected]/content/loadimpact/rpm/k6/$VERSION/k6-v$VERSION-amd64.rpm?publish=1&override=1"
workflows:
version: 2
test_and_build:
jobs:
- deps:
filters:
tags:
only: /.*/
- test:
filters:
tags:
only: /.*/
- test-prev-golang:
filters:
tags:
only: /.*/
- build-docker-images:
requires:
- deps
- test
filters:
tags:
only: /.*/
- build-linux-packages:
requires:
- deps
- test
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/