-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.yml
167 lines (147 loc) · 5.27 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
version: 2
jobs:
build:
working_directory: /go/src/github.com/sandro-h/prom_rest_exporter
environment:
docker:
- image: circleci/golang:1.11.2-stretch
steps:
- checkout
##############################
# Fetch dependencies
##############################
- restore_cache:
name: Restore dependency cache
keys:
- v2-deps-{{ checksum "Gopkg.lock" }}
- run:
name: Install go dep
command: curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
- run:
name: Get dependencies
command: dep ensure --vendor-only -v
- save_cache:
name: Save dependency cache
paths:
- vendor
key: v2-deps-{{ checksum "Gopkg.lock" }}
##############################
# Build C dependencies
##############################
- run:
name: Install C build tools
command: sudo apt install autoconf make libtool flex bison gcc-mingw-w64-x86-64
- restore_cache:
name: Restore c dependency cache
key: v1-c-deps
- run:
name: Download musl
working_directory: /go/src/github.com/sandro-h/prom_rest_exporter/vendorc
command: |
if [ ! -d musl ]; then
wget https://www.musl-libc.org/releases/musl-1.1.20.tar.gz
tar xf musl-1.1.20.tar.gz
mv musl-1.1.20 musl
fi
- run:
name: Build musl
working_directory: /go/src/github.com/sandro-h/prom_rest_exporter/vendorc/musl
command: |
if [ ! -d build ]; then
./configure --enable-gcc-wrapper --disable-shared --prefix=$PWD/build
make
make install
fi
- run:
name: Download jq master
working_directory: /go/src/github.com/sandro-h/prom_rest_exporter/vendorc
command: |
if [ ! -d jq-master ]; then
git clone https://github.com/stedolan/jq.git jq-master
pushd jq-master
git checkout jq-1.6
popd
fi
- run:
name: Build jq for windows
working_directory: /go/src/github.com/sandro-h/prom_rest_exporter/vendorc/jq-master
command: |
if [ ! -d build/win64 ]; then
git submodule update --init
autoreconf -fi
./configure
make distclean
CPPFLAGS=-I$PWD/src scripts/crosscompile win64 \
--disable-shared \
--enable-static \
--enable-all-static \
--target=win64-x86_64 \
--host=x86_64-w64-mingw32 \
--with-oniguruma=builtin
fi
- run:
name: Build jq for linux
working_directory: /go/src/github.com/sandro-h/prom_rest_exporter/vendorc/jq-master
command: |
if [ ! -d build/linux ]; then
autoreconf -fi
./configure --with-oniguruma=builtin --prefix=$PWD/build/linux/usr/local
sed -i 's/-DHAVE_GAMMA=1//' Makefile
make -j8 LDFLAGS="-all-static" CC=$PWD/../musl/build/bin/musl-gcc
make install
rm -f build/linux/usr/local/lib/*.so*
fi
- save_cache:
name: Save c dependency cache
paths:
- vendorc
key: v1-c-deps
##############################
# Test and build prom_rest_exporter
##############################
- run:
name: Test
command: |
CC=$PWD/vendorc/musl/build/bin/musl-gcc \
go test -v -coverprofile="coverage.out" ./... \
--ldflags '-linkmode external -extldflags "-static"'
- run:
name: Build for linux
command: |
CC=$PWD/vendorc/musl/build/bin/musl-gcc \
go build \
--ldflags '-linkmode external -extldflags "-static"'
- run:
name: Build for windows
command: GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc go build -v
- store_artifacts:
path: prom_rest_exporter
destination: binaries/prom_rest_exporter
- store_artifacts:
path: prom_rest_exporter.exe
destination: binaries/prom_rest_exporter.exe
##############################
# Sonar
##############################
- restore_cache:
name: Restore buildtools cache
key: v3-buildtools
- run:
name: Fetch sonar scanner
command: |
if [ ! -d buildtools/sonar-scanner ]; then
wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.2.0.1227-linux.zip
unzip -d buildtools/ sonar-scanner-cli-3.2.0.1227-linux.zip
mv buildtools/sonar-scanner-3.2.0.1227-linux buildtools/sonar-scanner
fi
- save_cache:
name: Save buildtools cache
paths:
- buildtools
key: v3-buildtools
- run:
name: Run sonar analysis
command: |
buildtools/sonar-scanner/bin/sonar-scanner \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.login=$SONAR_TOKEN