forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcircle.yml
64 lines (60 loc) · 3.5 KB
/
circle.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
machine:
services:
- docker
checkout:
post:
- git fetch --unshallow 2>/dev/null || true
- git fetch --tags
# Nasty hack: Because we get a freshly restored repo, timestamps do not
# correspond any more to when the file was last changed. To rectify this,
# first set everything to a timestamp in the past and then update the
# timestamp for all git-tracked files based on their last committed change.
- find . -exec touch -t 201401010000 {} \;
- for x in $(git ls-tree --full-tree --name-only -r HEAD); do touch -t $(date -d "$(git log -1 --format=%ci "${x}")" +%y%m%d%H%M.%S) "${x}"; done
dependencies:
cache_directories:
- "~/docker"
override:
# If there's a base image cached, load it. A click on CircleCI's "Clear
# Cache" will make sure we start with a clean slate.
- mkdir -p ~/docker
- if [[ -e ~/docker/base.tar ]]; then docker load -i ~/docker/base.tar; fi
- ./build/build-docker-dev.sh
- docker save "cockroachdb/cockroach-devbase" > ~/docker/base.tar
- if [[ ! -e ~/docker/dnsmasq.tar ]]; then docker pull "cockroachdb/dnsmasq" && docker save "cockroachdb/dnsmasq" > ~/docker/dnsmasq.tar; else docker load -i ~/docker/dnsmasq.tar; fi
# Print the history so that we can investigate potential steps which fatten
# the image needlessly.
- docker history "cockroachdb/cockroach-dev"
test:
override:
# Check whether the committer forgot to run `go generate`.
# Either `go generate` does not change any files or it does, in which case we print the diff and fail.
- docker run cockroachdb/cockroach-dev shell "(go generate ./... && git ls-files --modified --deleted --others --exclude-standard | diff /dev/null -) || (git add -A && git diff -u HEAD && false)" | tee "${CIRCLE_ARTIFACTS}/generate.log"; test ${PIPESTATUS[0]} -eq 0
- docker run "cockroachdb/cockroach-dev" test TESTFLAGS='-logtostderr -timeout 30s -vmodule=multiraft=5' | tee "${CIRCLE_ARTIFACTS}/test.log"; test ${PIPESTATUS[0]} -eq 0
- docker run "cockroachdb/cockroach-dev" testrace RACEFLAGS='-logtostderr -timeout 5m -vmodule=multiraft=5' | tee "${CIRCLE_ARTIFACTS}/testrace.log"; test ${PIPESTATUS[0]} -eq 0
# Kill off the previous images since we don't care for them any more,
# but we do want to save the logs for the following ones.
# `docker rm` actually errors on CircleCI but still works, hence the ';'.
- docker rm $(docker ps -aq) || true
- make acceptance
post:
# Write the container's log output to artifacts.
- i=0; for cid in $(docker ps -aq); do i=$((i+1)); docker logs $cid &> "${CIRCLE_ARTIFACTS}/${i}_${cid}.log"; done
deployment:
docker:
branch: master
commands:
- sed "s/<EMAIL>/$DOCKER_EMAIL/;s/<AUTH>/$DOCKER_AUTH/" < "resource/deploy_templates/.dockercfg.template" > ~/.dockercfg
- |
VERSION=$(git describe 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
echo "Deploying ${VERSION}..."
if [ -n "$DOCKER_EMAIL" ]; then
./build/build-docker-deploy.sh && \
make COCKROACH_IMAGE="cockroachdb/cockroach" acceptance && \
docker tag cockroachdb/cockroach:latest cockroachdb/cockroach:${VERSION} && \
docker tag cockroachdb/cockroach-dev:latest cockroachdb/cockroach-dev:${VERSION} && \
docker push cockroachdb/cockroach:latest && \
docker push cockroachdb/cockroach:${VERSION} && \
docker push cockroachdb/cockroach-dev:latest && \
docker push cockroachdb/cockroach-dev:${VERSION}
fi