This repository has been archived by the owner on Jan 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
.travis.yml
132 lines (120 loc) · 4.47 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
sudo: required
dist: xenial
language: generic
services:
- mongodb
stages:
- build
- tag
env:
- PRIVATE_IMAGE="$PRIVATE_DOCKER_REGISTRY/dsw-server" \
IMAGE="$PUBLIC_DOCKER_USER/server" \
IMAGE_TAG="$PRIVATE_IMAGE:$TRAVIS_COMMIT" \
IMAGE_TAG_BRANCH="$PRIVATE_IMAGE:"`echo $TRAVIS_BRANCH | sed 's#/#-#g'` \
IMAGE_TAG_DEVELOP="$IMAGE:develop" \
IMAGE_TAG_LATEST="$IMAGE:latest"
cache:
timeout: 600
directories:
- $HOME/.stack
- .stack-work
- vendor/bson-generic/.stack-work
- vendor/mongoDB-migration/.stack-work
- dsw-metamodel-migrator/.stack-work
- dsw-server/.stack-work
install:
# 1. Download, unpack, and check the stack executable
- mkdir -p ~/.local/bin
- export PATH=$HOME/.local/bin:$PATH
- travis_retry curl -L https://github.com/commercialhaskell/stack/releases/download/v2.1.3/stack-2.1.3-linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
# 2. Init Application Config
- cp dsw-server/config/application.yml.example dsw-server/config/application.yml
- cp dsw-server/config/application-test.yml.example dsw-server/config/application-test.yml
- cp dsw-server/config/integration.yml.example dsw-server/config/integration.yml
- cp dsw-server/config/integration-test.yml.example dsw-server/config/integration-test.yml
# 3. Update file timestamps
- ./scripts/update-file-timestamps.sh
# 3. Install app dependencies
- stack --no-terminal --install-ghc test --only-dependencies
before_script:
# 1. Log to public Docker Hub
- docker login -u "$PUBLIC_DOCKER_USER" -p "$PUBLIC_DOCKER_PASSWORD"
# 2. Log to private Docker Registry
- docker login -u "$PRIVATE_DOCKER_USER" -p "$PRIVATE_DOCKER_PASSWORD" "$PRIVATE_DOCKER_REGISTRY"
jobs:
include:
- stage: build
script:
# 1. Init and check testing Mongo Database
- mongo dsw-server-test --eval 'db.collection.find()'
# 2. Create build info inside application
- cd dsw-server/scripts
- ./build-info.sh
- cd ../..
# 3. Build and Test Application
- stack build --no-terminal --skip-ghc-check --test
- cp $(stack path --local-install-root)/bin/dsw-server dsw-server/dsw-server-bin
# 4. Build Docker Image
- cd dsw-server
- docker pull $IMAGE_TAG_DEVELOP
- docker build --cache-from $IMAGE_TAG_DEVELOP -t $IMAGE_TAG .
- docker push $IMAGE_TAG
- stage: tag
if: (branch = develop) AND (NOT (type IN (pull_request)))
addons: false
services: false
cache: false
before_install: false
install: false
script:
- docker pull $IMAGE_TAG
- docker image tag $IMAGE_TAG $IMAGE_TAG_DEVELOP
- docker push $IMAGE_TAG_DEVELOP
- stage: tag
if: (branch = master) AND (NOT (type IN (pull_request)))
addons: false
services: false
cache: false
before_install: false
install: false
script:
- docker pull $IMAGE_TAG
- docker image tag $IMAGE_TAG $IMAGE_TAG_LATEST
- docker push $IMAGE_TAG_LATEST
- stage: tag
if: (type = push)
install: false
script:
- docker pull $IMAGE_TAG
- docker image tag $IMAGE_TAG $IMAGE_TAG_BRANCH
- docker push $IMAGE_TAG_BRANCH
- stage: tag
if: (tag =~ ^v\d+\.\d+\.\d+$)
install: false
env:
- PRIVATE_IMAGE="$PRIVATE_DOCKER_REGISTRY/dsw-server"
- IMAGE="$PUBLIC_DOCKER_USER/server"
- IMAGE_TAG="$PRIVATE_IMAGE:$TRAVIS_COMMIT"
- IMAGE_TAG_MAJOR="$IMAGE:"`echo $TRAVIS_TAG | sed -E "s/v(.*)\..*\..*/\1/g"`
- IMAGE_TAG_MINOR="$IMAGE:"`echo $TRAVIS_TAG | sed -E "s/v(.*)\..*/\1/g"`
- IMAGE_TAG_PATCH="$IMAGE:"`echo $TRAVIS_TAG | sed -E "s/v//g"`
script:
- docker pull $IMAGE_TAG
- docker image tag $IMAGE_TAG $IMAGE_TAG_MAJOR
- docker push $IMAGE_TAG_MAJOR
- docker image tag $IMAGE_TAG $IMAGE_TAG_MINOR
- docker push $IMAGE_TAG_MINOR
- docker image tag $IMAGE_TAG $IMAGE_TAG_PATCH
- docker push $IMAGE_TAG_PATCH
- stage: tag
if: (tag =~ ^v\d+\.\d+\.\d+-rc\.\d+$)
install: false
env:
- PRIVATE_IMAGE="$PRIVATE_DOCKER_REGISTRY/dsw-server"
- IMAGE="$PUBLIC_DOCKER_USER/server"
- IMAGE_TAG="$PRIVATE_IMAGE:$TRAVIS_COMMIT"
- IMAGE_TAG_RC="$IMAGE:"`echo $TRAVIS_TAG | sed -E "s/v//g"`
script:
- docker pull $IMAGE_TAG
- docker image tag $IMAGE_TAG $IMAGE_TAG_RC
- docker push $IMAGE_TAG_RC