forked from prymitive/karma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
255 lines (234 loc) · 12.7 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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
__defaults_go: &DEFAULTS_GO
language: go
go: "1.14.1"
cache:
directories:
- ui/node_modules
# https://restic.net/blog/2018-09-02/travis-build-cache
- $HOME/.cache/go-build
- $HOME/gopath/pkg/mod
before_cache:
# this log file is updated on every get/set operation
# so it forces new cache archive on every build
# remove it before creating cache archive
- rm -vf $HOME/.cache/go-build/log.txt
env:
- GO111MODULE=on
__defaults_js: &DEFAULTS_JS
language: node_js
# we run make to install everything
install: []
cache:
directories:
- ui/node_modules
env:
- NODE_ENV=test
git:
depth: 100
os: linux
language: shell
jobs:
allow_failures:
- name: Percy UI snapshots
include:
- stage: Test
name: Test Go code
if: (repo = prymitive/karma AND type != pull_request) OR (fork = true AND type = pull_request)
<<: *DEFAULTS_GO
before_script:
- travis_retry make mock-assets
script: make test-go
after_success:
- travis_retry curl -s --connect-timeout 30 --fail https://codecov.io/bash | bash -s -- -F backend
- stage: Test
name: Test JavaScript code
if: (repo = prymitive/karma AND type != pull_request) OR (fork = true AND type = pull_request)
<<: *DEFAULTS_JS
script: make -C ui test-js
after_success:
- travis_retry curl -s --connect-timeout 30 --fail https://codecov.io/bash | bash -s -- -F ui
# duplicate js test but with a different time zone, to ensure that tests/code work with non-UTC time zone
- stage: Test
name: Test JavaScript code with Pacific/Easter time zone
if: (repo = prymitive/karma AND type != pull_request) OR (fork = true AND type = pull_request)
<<: *DEFAULTS_JS
script: env TZ=Pacific/Easter make -C ui test-js
after_success:
- travis_retry curl -s --connect-timeout 30 --fail https://codecov.io/bash | bash -s -- -F ui
- stage: Lint
name: Lint git commit
if: (repo = prymitive/karma AND type != pull_request) OR (fork = true AND type = pull_request)
<<: *DEFAULTS_JS
script: make -C ui lint-git-ci
- stage: Lint
name: Lint Go code
if: (repo = prymitive/karma AND type != pull_request) OR (fork = true AND type = pull_request)
<<: *DEFAULTS_GO
before_script:
- travis_retry make mock-assets
script: travis_retry make lint-go
- stage: Lint
name: Check Go code formatting
if: (repo = prymitive/karma AND type != pull_request) OR (fork = true AND type = pull_request)
<<: *DEFAULTS_GO
before_script:
- travis_retry make mock-assets
script:
- make format-go
- git diff --exit-code
- stage: Lint
name: Verify go.sum
if: (repo = prymitive/karma AND type != pull_request) OR (fork = true AND type = pull_request)
<<: *DEFAULTS_GO
script:
- travis_retry make mock-assets
- travis_retry go get -d -v ./cmd/karma
- travis_retry go mod tidy
- git diff --exit-code
- stage: Lint
name: Lint JavaScript code
if: (repo = prymitive/karma AND type != pull_request) OR (fork = true AND type = pull_request)
<<: *DEFAULTS_JS
script: make -C ui lint-js
- stage: Lint
name: Check JavaScript code formatting
if: (repo = prymitive/karma AND type != pull_request) OR (fork = true AND type = pull_request)
<<: *DEFAULTS_JS
script:
- make -C ui format
- git diff --exit-code
- stage: Lint
name: Lint documentation
if: (repo = prymitive/karma AND type != pull_request) OR (fork = true AND type = pull_request)
<<: *DEFAULTS_JS
script: make -C ui lint-docs
- stage: Lint
name: Verify OpenAPI client code
if: (repo = prymitive/karma AND type != pull_request) OR (fork = true AND type = pull_request)
language: shell
addons:
apt:
packages:
- docker-ce
script:
- travis_retry make openapi-client
- git diff --exit-code
- stage: Lint
name: Lint Golang Version
if: (repo = prymitive/karma AND type != pull_request) OR (fork = true AND type = pull_request)
language: shell
script: make lint-golang-version
- stage: Lint
name: Lint Node Version
if: (repo = prymitive/karma AND type != pull_request) OR (fork = true AND type = pull_request)
language: shell
script: make lint-nodejs-version
- stage: Snapshots
name: Percy UI snapshots
if: (repo = prymitive/karma AND type != pull_request AND type != cron) OR (fork = true AND type = pull_request)
<<: *DEFAULTS_JS
env:
- NODE_ENV=test
- secure: "DTDy4as3DV3QUw6LWNInEh2iFXrsMuMnb+WRNSwORu8OcgyLKVNrQ5SwQLV1lm0RFTCEN+sSxjOJwQp5PXEgLXcT/MP5xfg2p3HDEj7k7GqJLI4OykYpdh7YHGaX+cAGsrjPfuWAf7pdBlYplEDdGHGkK9BLkBIx6owkzvw0Z8Je3+kTxRAae8vIXpzmgiN+NGzP14UF92tky+/ZS2aLrhqVbTpWEP5j0mEhOpy6Ebh31nCTuW2FA+8oD0HVckC/JTLbIGPQgpzLrdEEE/imjZB9Gx4022lkcuZjf8u+hRytgqKp93l01MPxHrGCZ9V18r3QFZCAXGtFh8dg8xSAvk1cvFfJUDHkW1XhaUdsLubGI7zDw111N+5Do9L3MjJ2jd1x7ZPUSJwKUGPeRw/7CsNDPtC2Pcmkdb3D0SNeH4ia/L43A9+e3nuJ6vthAkEd7zBIcp9diVJ2nyry0d5YdFQStezksJgFADOO/OleMyMhLTdqBUE7sFf7QtD6R9nhZuIe//3UGVRuTJJmDU8wZEzK8CUyhPjbnpMTMbyq8bIYIk96E5Nrxp65RDOv9pPpvPfHf0WvALn/fmwa79AUafugYDoAXokv1RqrU0L977MRwEDDkGOuO1civoudfNQ2sAh6SR1eaSp9AygJgvpodLy1lEJZm3VxffjrSNdoejU="
script: ./scripts/percy-skip-deps.sh || make -C ui test-percy
- stage: Build and Deploy
name: Cross compile binaries
if: (repo = prymitive/karma AND type != pull_request) OR (fork = true AND type = pull_request)
<<: *DEFAULTS_GO
env:
# add an extra env so we don't push cross compilation cache into the main archive
# as it slows down other jobs
- JOB=cc
- GO111MODULE=on
before_script:
# this stage needs to build everything including assets file and that
# requires running webpack, so we need nodejs here
- travis_retry nvm install $(< .nvmrc)
script:
- export SOURCE_DATE_EPOCH=$(git show -s --format=%ci ${TRAVIS_TAG:-${TRAVIS_COMMIT}}^{commit})
- travis_retry make crosscompile -j 2
- for i in karma-*; do tar --mtime="${SOURCE_DATE_EPOCH}" --owner=0 --group=0 --numeric-owner -c $i | gzip -n - > $i.tar.gz; done
- shasum -a 512 karma-*.tar.gz | tee sha512sum.txt
# verify that there are no uncommited changes
- git diff --exit-code
# prune GOCACHE if it gets too big
- ./scripts/prune-go-cache.sh
deploy:
provider: releases
api_key:
secure: Wmix2qr1q6BakTWI4Wc6hQEw27OZMb04OeAfPhM84ZUMd30t9BNAdfERsNkuY2VylnJ9KhbBdHmd0XWqqAvI55/lZTLkUW1gD8ZEjly23w735HNm/9vHESjmUUZdZK/bLFLr1cQq3+jgGdO0ZNcAEGJhKZNA1TcdA7t0uNhg0xSejVYRMxOLx3wzVF9oGSq36m8nhLIWG9mlRkZBfE+0Q4pHJK+diqICoTUIZNhZO1Lu8uO6jNpAmgRfhF7q1LGcoa0ZeHV8OsB5OhpLXDExyNw4znxPzWBu5y9+85fjeRKpmGd0KFT2PRnwB9XkSo20Mmk94x+t07+0VR6NtyKXPG5g8i/PxLQr4f1ZwPXNW0xKq5t9KLycnj3Gf/xlaXyk4d5V64EKUTbDP37emodCwPyxaozoRfDvbT7Oyj1jtHoj+6ijYrPBpjc4fnz7xBoydD5R+we/dzcnM/1ZlFnpGckWsCL7QyNuGQQJ9vk2Xo3H5wylL1Ol2BB/aWZYAuBbwXaXZnOg79b/2SQkxHrEveAbDlVovSvqsOtq6DI6oY4VyWsQzjQHvmFMfTp1LPWwh/EL1q2+feDM4vEsx9OMLegFCoAzKPy9xm0teZbYKdMfJammBjvRYZh9h+Hw43/atXktG3zSuR4C/HmXLoswq+c2bjJWlcM8jvB29oo5uA4=
skip_cleanup: true
file_glob: true
file:
- karma-*.tar.gz
- sha512sum.txt
on:
repo: prymitive/karma
tags: true
- stage: Build and Deploy
name: Build docker image
# we build and push docker image on merge and tag, so this should only
# run for new branches, to test that they don't break docker builds
if: (repo = prymitive/karma AND type != pull_request AND branch != master AND tag IS NOT present) OR (fork = true AND type = pull_request)
language: shell
addons:
apt:
packages:
- docker-ce
script: travis_retry make docker-image
- stage: Build and Deploy
name: Build and push docker image
if: repo = prymitive/karma AND ((type = push AND branch = master) OR tag IS present)
language: shell
addons:
apt:
packages:
- docker-ce
env:
# DOCKER_PASSWORD
- secure: "XULRlOHN17A1KUSzST1TKo5UQtSS0/T6y2Rp88gJ/jDOraFKW3IuGHBM3uE3uALBUfrLnB6DGrrtS1x3hvWSvpnBmNmCK94qGYpEppAU2b8+DfUGQqI1D7sa/FXAaxqkA6LDKxcdgbagd8kE/3gRmayjHeisCDPvy3BhVZVEfzSIaKilzXnHrCywEpB2DWRUsYkdZdw2tG674626ZcMwJUajkeW4fxmvWYrskE92+7MSuz9DExxYWLLah12+Ug1URD1UWyFeIdMK0z3S0bN4Bsd+RT0ScDelRMhad5sTTqGWbLC3nr10aMRYzXYhp2pUBPtK2abby4KebY8hToxf6Dr8f7Nz4BRA3nqwp/7Q79hloU7IYdtnvSdvMp3Pc3YDsHiYqAO+G/jfX2j4t8CGIk3hHDUZ+4/PnYddV+OFR8CujH4Wq85FzHPyfRmZuB6MdPQQEtW4B/Mmf3qsTYXZIwDSKU2fnJM6eEnDW7vZIb55Y8nFC4x8b4fVyY7/wSQgDVtd933BmYDUxYo9AjjAfigLBE30zalr/TFibIRWUewoYqvJJ803AJU/M54vzQQ9l9ypoNadGgHa0PuPrnza9WufHGNkm7jRfhKFDUi/RvdFX8u7NtTpB9bAk/Mk+9qcLIkVnm+9SCcA80KR9LLwp8SZChBMHNnNTs47T0cDzNI="
# GITHUB_PACKAGES_TOKEN / personal token for uploading to github docker repo
- secure: "P2d1XVQdlbtXTi5NvGnwejJ1b16XnH4tSw2ZJkI+ETCHf1F77vcsl9DqjqkdQ64nAMwUBTC+vXR3zdKiKfno6NXphMuEBC/fMPSUyuzXgCB4EYWYQ73SnTq63bSEjUoySZz5CqwyQCw1pPSFgDe19NCb1H9gouJhIk83QqqjOz+VgSZonluSMY1KzdRVZqBWDD0/L986SKnYM2JmTGi7I2fUdPGFmhlGh2G6fQGasuF5YyTKAzEOUm4hXK/2a1xURrn0IzdJkAH1vh4ak8wxf0lG31pPJLDzykFz21vLX+Nxc9kYR2P9osHSTbISaAK7URGLD1blNgACCaWe/Ob6X89pJqcG9mVss3hUHqM5G9ZkgIeHhzIbRmbS13olH50IurMPmMc7Jj7C0oyt1bplcTLPBDZbHfk44QdjsBZKKrlUox/kH5QDf+WaVJRmSJKjJ9TR0l8uyzOiZQt36Fezj5UcfKFQKM5i0xMmDZDcnHid8kBqFuDeYeixICcPpGirZdNn0Q0ByQelbaHKYZyJlTdValuXtcyAIyG3//rI21rkvXUZgrgmBnypNn4waqcYFJ7QdHNYKqcGICAsobYaffASVQxK+BVdPwP9NTcZqhoCWOL8gDVw2fmtL0TRLEmcLDQcgEI8ClsEc5/LD1gugaskNJfew9BLTFwJPSMStKs="
script:
- export VERSION=$(make show-version)
- export LOCAL_IMAGE="karma:${VERSION}"
- export DOCKER_USERNAME=lmierzwa
- export DOCKER_IMAGE=karma
- export IMAGE_NAME="${DOCKER_USERNAME}/${DOCKER_IMAGE}"
- travis_retry make docker-image
### Docker Hub
- travis_retry docker login -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}"
- docker tag "${LOCAL_IMAGE}" "${IMAGE_NAME}:latest"
# tag with the version only if we have a git tag (new release was pushed)
- if [ -n "$TRAVIS_TAG" ]; then docker tag "${LOCAL_IMAGE}" "${IMAGE_NAME}:${VERSION}" ; fi
- travis_retry docker push "${IMAGE_NAME}"
### GitHub
# tag with the version only if we have a git tag (new release was pushed)
- if [ -n "$TRAVIS_TAG" ]; then travis_retry docker login docker.pkg.github.com -u prymitive -p "${GITHUB_PACKAGES_TOKEN}" && docker tag "${LOCAL_IMAGE}" "docker.pkg.github.com/prymitive/karma/karma:${VERSION}" && travis_retry docker push "docker.pkg.github.com/prymitive/karma/karma:${VERSION}" ; fi
- stage: Build and Deploy
name: Deploy demo app to Heroku
# deploy on every job that isn't a PR, this way we:
# * don't deploy on PRs send from forks, only internal
# * deploy only once per PR - since we will deploy on branch job
if: repo = prymitive/karma AND type != pull_request
env:
# HEROKU_TOKEN, valid forever, needed to push docker image and release
# it on heroku app
- secure: "zr1fHhSIZQgA7wT8PALNyAhilCZBpvziL2zuC7LJvYy9PSHatV1B+/Tl5Ao1MGlqiD9wHdRXhw/Z7Ol7vR84LlEXIQv/PZvpYtdGrwP/dmwEzRi59puNHW/sDa5fU27U5bgGW9VPYKzQFGBIknRz9yEpGAsDqzWSRwEQofgnuF1Cv0JJXN/tcZs/fcXz4AhFSXRb8Rde2geHRVGlz3UnuECQ9LnzTI/xxIP/+YORvMpTcwJtQwq/NhucYXzms19XM94xz5IE/cwf8yV9YZalm867aR2yQJvkMmOaufSYoFgRrghqnpzEe1wyuZvAXkwwZErw5swBY3Zo1YkGUeU761g3v+Nh+dlVKFaBVYgDt9W9bb1QsK1Lbgix4UYSx8Tz06X83xz2f6hWXS1Yvju7yE7M1VmjAhevWW+ZpTf3vwOH2UeUHyAMOddggMSIRfaxC9W74Trt8zxKlM+8sQiaEE3c6Ea+ZJxq1baDJvHQPdfuj2844uKaAL7qNVuRNRPAa0bp0qkzLyl3f5P3XK54mM4vayBRCQ+qflq+XGXY5G8+LukUNnKMq/KuPZZ1A6pOr3kTj4qKaxAcxOJQq4/xc+zJaiQFkzfMj1//LKMyvrRtqMnPV+P3qtgMGzA4Z3JlHUOgPHgbZ9WTlpV5yi066Onro+j2NFehjY+FV6R2gOI="
language: shell
addons:
apt:
packages:
- docker-ce
before_script:
# a safe and boring version of cat > .netrc < EOF
- echo "machine api.heroku.com" >> $HOME/.netrc
- echo " login [email protected]" >> $HOME/.netrc
- echo " password $HEROKU_TOKEN" >> $HOME/.netrc
script:
- travis_retry docker build --build-arg VERSION=$(make show-version) -t registry.heroku.com/karma-demo/web -f demo/Dockerfile .
- travis_retry docker login -u _ -p "$HEROKU_TOKEN" registry.heroku.com
- travis_retry docker push registry.heroku.com/karma-demo/web
# bundled heroku cli doesn't know anything about containers, update it
- travis_retry curl -s --connect-timeout 30 --fail https://cli-assets.heroku.com/install.sh | sh
- travis_retry /usr/local/bin/heroku container:release web --app karma-demo