-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfig.yml
More file actions
160 lines (152 loc) · 5.73 KB
/
Copy pathconfig.yml
File metadata and controls
160 lines (152 loc) · 5.73 KB
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
version: 2
# https://circleci.com/blog/circleci-hacks-reuse-yaml-in-your-circleci-config-with-yaml/
defaults: &defaults
docker:
- image: weaveworks/service-build:master-8245ec7d
working_directory: /go/src/github.com/weaveworks/service
jobs:
lint:
<<: *defaults
steps:
- checkout
- run: make BUILD_IN_CONTAINER=false lint
build:
<<: *defaults
steps:
- checkout
- setup_remote_docker
- run: make BUILD_IN_CONTAINER=false SUDO=
- run: |
set -e
set -o pipefail
if [ $(./tools/image-tag | grep -e '-WIP$') ]; then
echo "WIP build; exiting with error to mark as a failure"
git --no-pager diff
exit 1
fi
- run:
name: Upload docker images for use later in workflow
command: |
docker login -u "$DOCKER_REGISTRY_USER" -p "$DOCKER_REGISTRY_PASSWORD" quay.io
IMAGE_TAG="$(./tools/image-tag)"
IMAGES=$(make images)
for image in ${IMAGES}; do
if [[ "$image" == *"build"* ]]; then
continue
fi
tagged_image="${image}:${IMAGE_TAG}"
repo_tmp_image="$(echo $tagged_image | sed -E 's|(/weaveworks)/(.*):(.*)|\1/build-tmp:\2-\3|')"
docker tag ${tagged_image} ${repo_tmp_image}
docker push $repo_tmp_image
done
- persist_to_workspace:
root: .
paths:
- users/client/mock_client.go
- gcp-service/grpc/gcp-service.pb.go
- users/users.pb.go
- common/billing/grpc/billing.pb.go
- kubectl-service/grpc/kubectl-service.pb.go
test:
<<: *defaults
steps:
- checkout
- setup_remote_docker
- run: go get github.com/mattn/goveralls
- run: COVERDIR=./coverage make BUILD_IN_CONTAINER=false test
- run: ./tools/cover/gather_coverage.sh ./coverage $CIRCLE_WORKING_DIRECTORY/coverage
- run: goveralls -repotoken $COVERALLS_REPO_TOKEN -coverprofile=$CIRCLE_WORKING_DIRECTORY/profile.cov -service=circleci || true
- run: mkdir /tmp/coverage && cp coverage.* /tmp/coverage
- store_artifacts:
path: /tmp/coverage
integration-test:
<<: *defaults
steps:
- checkout
- setup_remote_docker
- &pull-tmp-images
run:
name: Download docker images build earlier in workflow
command: |
docker login -u "$DOCKER_REGISTRY_USER" -p "$DOCKER_REGISTRY_PASSWORD" quay.io
# Pull our previously built image, retag it
IMAGE_TAG="$(./tools/image-tag)"
IMAGES=$(make images)
for image in ${IMAGES}; do
if [[ "$image" == *"build"* ]]; then
continue
fi
tagged_image="${image}:${IMAGE_TAG}"
repo_tmp_image="$(echo $tagged_image | sed -E 's|(/weaveworks)/(.*):(.*)|\1/build-tmp:\2-\3|')"
docker pull $repo_tmp_image
docker tag ${repo_tmp_image} ${tagged_image}
docker tag ${repo_tmp_image} ${image}:latest
docker image rm ${repo_tmp_image}
done
- attach_workspace:
at: .
- run: go get github.com/nats-io/gnatsd
- run:
command: gnatsd
background: true
- run: |
touch users/client/mock_client.go gcp-service/grpc/gcp-service.pb.go users/users.pb.go common/billing/grpc/billing.pb.go kubectl-service/grpc/kubectl-service.pb.go
make touch-uptodate
make BUILD_IN_CONTAINER=false notification-integration-test
make BUILD_IN_CONTAINER=false notebooks-integration-test
make BUILD_IN_CONTAINER=false users-integration-test
make BUILD_IN_CONTAINER=false billing-integration-test
make BUILD_IN_CONTAINER=false pubsub-integration-test
make BUILD_IN_CONTAINER=false flux-integration-test
make BUILD_IN_CONTAINER=false kubectl-service-integration-test
make BUILD_IN_CONTAINER=false gcp-service-integration-test
upload:
<<: *defaults
steps:
- checkout
- setup_remote_docker
- <<: *pull-tmp-images
- run:
name: Publish docker images to final repository
command: |
set -o pipefail
export LAST_BUILD_COMMIT=$(curl -sS 'https://circleci.com/api/v1/project/weaveworks/service/tree/'$CIRCLE_BRANCH'?circle-token='$CIRCLE_TOKEN'&filter=successful&limit=50' | jq -r 'map(select(.build_parameters.CIRCLE_JOB == "upload")) | .[0].vcs_revision')
echo Last successful build was commit $LAST_BUILD_COMMIT
./push-images --if-changed-since $LAST_BUILD_COMMIT
dry-run-upload:
<<: *defaults
steps:
- checkout
- setup_remote_docker
- <<: *pull-tmp-images
- run:
name: Dry-run of publishing docker images
command: |
set -o pipefail
export LAST_BUILD_COMMIT=$(curl -sS 'https://circleci.com/api/v1/project/weaveworks/service/tree/master?circle-token='$CIRCLE_TOKEN'&filter=successful&limit=50' | jq -r 'map(select(.build_parameters.CIRCLE_JOB == "upload")) | .[0].vcs_revision')
echo Last successful build was commit $LAST_BUILD_COMMIT
./push-images --dry-run --if-changed-since $LAST_BUILD_COMMIT
workflows:
version: 2
build_test_and_upload:
jobs:
- lint
- test
- build
- integration-test:
requires:
- build
- lint
- test
- upload:
requires:
- integration-test
filters:
branches:
only: master
- dry-run-upload:
requires:
- integration-test
filters:
branches:
ignore: master