-
Notifications
You must be signed in to change notification settings - Fork 2
/
.travis.yml
116 lines (109 loc) · 4.79 KB
/
.travis.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
language: nix
os: linux
dist: bionic
stages:
- build
- test
- gen-code
- release
jobs:
include:
# Build the Fencer Docker image
- stage: build
script:
# Build the Docker image and create a list of paths to push to Cachix.
# The secret signing key should not be available to the build process.
- ( set -e;
unset CACHIX_SIGNING_KEY;
nix-env -iA cachix -f https://cachix.org/api/v1/install;
cachix use fencer;
imagepath=$(nix-build docker.nix);
cp $imagepath fencer.tar.gz;
nix-store -qR --include-outputs $(nix-instantiate docker.nix) > paths
)
# Push built paths to Cachix
- cachix push fencer < paths
workspaces:
create:
name: build-docker
paths:
- fencer.tar.gz
env:
# CACHIX_SIGNING_KEY
- secure: "vNNLfNScRuluP7zmlkCv/9uD+haHZ+iNv5FmWbXA757roaUgXBwRHZptM7wkUCUnhWVKiY9TRBJlCg5NAfNtUB1ElDZifLeVnUzaAsF4y7HP/hDYGmg+NnCB4EhBtc8vmATYK323VKzHCGiApKO0EvO7Oc8CRhrk/RFjVA6JoXYn8rM9FXcvT2AAXGzZmbevH5uUSlY61qmCF0YJdQdtjrwzDk1P/NQCKppxOHlJs1j38BF7ax94gKq2sCMXQA3d4V47WxKZgSvG+fBdXeFAwDs+avnTQ9hTFOb08yeCkIfUlx/GzSH6AVZR2tOwg59MVf9rTDIAExe3slNdDnicwWR1iV1ffmeYzztxA/359/YSYbL06ux0Mq8WsC2wg6+QlIo/K7Lc2q9J8Eye3zwfMGPkSNFUQuSkq+dCdN2r3xT3t6qfhdXo90f7GGvSmBwGc63Cao4rPBc7I98q9SLC4OjSXG4ktgqV6zzGG29/Y+sdpq0WN2pcHB2676WF+jyXrmEgm7Fq2SDU2wdxjA3ZviSbw8gUFvF1/tG/O42juYGMjztBg+eLBf+ZcehsFLctu8tRtMn6PouPfd5OwYmG4IsVBLyNa8lK9I/Hl5RGX5X2RWfCbZz98yzvoAU3T+GgDzQ4apODVnquIX0ebQDhM8s+3Av/+pWnqe5fq3iYtbU="
# Build the Go integration test
- stage: build
script:
- imagepath=$(nix-build test_integration_go/docker.nix)
- cp $imagepath test_integration_go.tar.gz
workspaces:
create:
name: build-test
paths:
- test_integration_go.tar.gz
# Run integration tests
- stage: test
services:
- docker
workspaces:
use:
- build-docker
- build-test
env:
# Name of the Docker container running Fencer
- FENCER_SERVER=fencer-server
# Names of Docker images, should correspond to names in .nix files
- FENCER_IMAGE=juspayin/fencer
- FENCER_TEST_IMAGE=test_integration_go
script:
# Create a Docker network for the containers
- docker network create test
# Run Fencer
- docker load -i fencer.tar.gz
- docker run
-v $(pwd)/test_integration_go/config:/srv/runtime_data/current
-e RUNTIME_SUBDIRECTORY=ratelimit
--name $FENCER_SERVER
--network test
--detach
$FENCER_IMAGE
- sleep 5
# Run the test
- docker load -i test_integration_go.tar.gz
- docker run
-e GRPC_HOST=$FENCER_SERVER
--network test
$FENCER_TEST_IMAGE
### Checking checked-in generated code is up to date
- stage: gen-code
script:
- nix-env -iA cachix -iA git -f https://cachix.org/api/v1/install
- cachix use fencer
- nix-shell --run ./scripts/protoGen.sh
- DIFF=$(git diff lib/Fencer/Proto.hs | wc -c)
- if [ "$DIFF" != "0" ]; then exit 1; fi
### Release
- stage: release
services:
- docker
env:
# DockerHub repo to push to
- FENCER_REPO=juspayin/fencer
# Name of Docker image, should correspond to the name in docker.nix
- FENCER_IMAGE=juspayin/fencer
# DOCKERHUB_ACCESS_TOKEN
- secure: "KZD2fp9Jlw0e7QJzivpUIesFByf9I2z5VVIzW2KYJFVaYM/zQFHwJTQ5zLViVn69KZ/S8ofiwnEOh8FGMirrtD26fqnYLYYEYd1N5XnNqVSc56Vj90+p9+1ygN+mJX/WvmkLIuozMXNw2PLh37ZWxhaZJBsidI9NTXRY6qqRDZFV16JpQIzrm8gAto5ndidrm11rfh2e3Sgq6eYNUvTSITQ/HI8MM1x9sd+DU/YSrW+9Ww2CWWmgFphOCz+VVC9vbXLRmFga4tOSReYmS1WLQos7pm4GlNAmBPyBh7TL3arLzr4wjc/tqaSNYqV2m8vtmBMfWYlzgK6ccWfXDK92eFsZ5UEKUuw9vt/2qPkZkBOrCAJ5lYRIT+ZbRr64vuikL1RgIKzN7VsEeq7TmwLDkxV1sBQtywSitAVo47KVJBwhlbp2NjPaDt/uxazpQHgv2y7UyhJweHvpfPnwMcBW053PFAXhsdgcMoT7R3hAMerx0u80ll1k9qeRfwVV06gOYd4qoCFNEG3ddKWvXbh4/KGxo1xw+vQ3J3oOwIAdNrHy4FVA3SzjI5hN5MCQ32+7ma8o4vWFfh6KBltw1pLZsI80ZmqdOo2cpRzvUJSbpjCi2xLfkyxEw2SuZOlGpUIIib0yNm+gDinojg3wjsF69EFf+3dLOtduH3kJ1FMKUvY="
workspaces:
use:
- build-docker
script:
- echo "$DOCKERHUB_ACCESS_TOKEN" | docker login --username juspayin --password-stdin
- docker import fencer.tar.gz $FENCER_IMAGE
# Tag the image with commit hash and push
- HASH=$(git log -1 --pretty=%h)
- docker tag $FENCER_IMAGE $FENCER_REPO:$HASH
- docker push $FENCER_REPO:$HASH
# Tag the same image with "master" and push
- docker tag $FENCER_IMAGE $FENCER_REPO:master
- docker push $FENCER_REPO:master
if: branch = master AND type = push