-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy path.travis.yml
More file actions
311 lines (249 loc) · 12.8 KB
/
Copy path.travis.yml
File metadata and controls
311 lines (249 loc) · 12.8 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
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
os: linux
dist: xenial
language: shell
env:
global:
# GO VERSION is set here with GIMME_GO_VERSION see: https://github.com/travis-ci/gimme
# may also want to run `go mod edit -go=1.13` to fix go.mod as well
- GIMME_GO_VERSION=1.13.x GIMME_OS=linux GIMME_ARCH=amd64
branches:
only:
- master
# https://docs.travis-ci.com/user/customizing-the-build/#safelisting-or-blocklisting-branches
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/
stages:
- 'Tests'
- 'Trigger FSC Tests'
- 'Test Build using latest tag (no upload)'
- 'Build, Upload and Publish (draft)'
- 'Test github release assets'
- 'Publish (real)'
- 'Readme-sync-preview'
- 'Readme-sync'
jobs:
include:
- stage: Tests
name: hadolint
os: linux
dist: xenial
script:
- make -e lint
- for f in `find scripts/dockerfiles -type f`; do echo $f; docker run --rm -i hadolint/hadolint:v2.1.0 < $f; done
- stage: Tests
name: coveralls
os: linux
dist: xenial
script:
- make -e cover COVER_FILE=coverage.txt
after_success:
- go get github.com/mattn/goveralls
- $GOPATH/bin/goveralls -coverprofile=coverage.txt -service=travis-ci
- stage: Tests
name: sourceclear
os: linux
dist: xenial
addons:
srcclr: true
script:
- go get -v -d ./...
- stage: Tests
name: windows build.ps1 test
os: windows
language: shell
before_script: skip
script:
- PowerShell -Command Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
- PowerShell -File "scripts\build.ps1" noninteractive
- PowerShell -File "scripts\check_exe.ps1"
after_success:
- ( [ ${TRAVIS_EVENT_TYPE} = "push" ] && [ ! -z ${TRAVIS_TAG} ] ) && scripts/upload_artifacts.sh
- stage: Tests
name: acceptance
os: linux
dist: xenial
language: python
python: "3.7"
install:
- pip install -r tests/acceptance/requirements.txt
script:
- MYHOST="http://localhost:8080" make test-acceptance
- stage: 'Trigger FSC Tests'
if: (branch = master AND type = push) OR type = pull_request OR tag IS present
env:
SDK=agent
SDK_BRANCH=$(if [ -z "$TRAVIS_PULL_REQUEST_BRANCH" ]; then echo ${TRAVIS_BRANCH}; else echo "$TRAVIS_PULL_REQUEST_BRANCH"; fi)
cache: false
before_install:
./scripts/pull_travis_ci_tools.sh
install: skip
script:
- "$HOME/travisci-tools/trigger-script-with-status-update.sh"
- stage: 'Test Build using latest tag (no upload)'
name: linux
os: linux
dist: xenial
script:
- export APP_VERSION=$(git describe --abbrev=0 --tags | tr -d '^v')
- $TRAVIS_BUILD_DIR/scripts/ci_create_packages.sh
- $TRAVIS_BUILD_DIR/scripts/ci_build_generate_secret.sh
- stage: 'Build, Upload and Publish (draft)'
if: type = push AND tag IS present AND tag =~ /^v[0-9]+\.[0-9]+\.[0-9]+(\-beta)?[0-9]*$/
name: linux
os: linux
dist: xenial
# The version of the app is set via git tag (below). This is picked up in the Makefile and compiled into the binary via LDFLAGS.
# It is also picked up in scripts/Makefile.ci to be used in the package name when they are built.
env: APP_VERSION=${TRAVIS_TAG#v}
before_install:
- ./scripts/pull_travis_ci_tools.sh
install:
# installs hub to ~/bin
- $HOME/travisci-tools/release_github/install_hub.sh
- export PATH=$HOME/bin:$HOME/travisci-tools/release_github:$PATH
script:
# now we're going to create packages & upload packages
- $TRAVIS_BUILD_DIR/scripts/ci_create_packages.sh && $TRAVIS_BUILD_DIR/scripts/ci_upload_packages.sh
# create the github release (draft)
- release_github_v2.sh "$TRAVIS_TAG"
# attach generate_secret to the github release
- $TRAVIS_BUILD_DIR/scripts/ci_build_generate_secret.sh && $TRAVIS_BUILD_DIR/scripts/ci_attach_generate_secret.sh
- stage: 'Test github release assets'
if: type = push AND tag IS present AND tag =~ /^v[0-9]+\.[0-9]+\.[0-9]+(\-beta)?[0-9]*$/
name: linux
os: linux
env: APP_VERSION=${TRAVIS_TAG#v}
before_install:
- ./scripts/pull_travis_ci_tools.sh
install:
# installs hub to ~/bin
- $HOME/travisci-tools/release_github/install_hub.sh
- export PATH=$HOME/bin:$HOME/travisci-tools/slack:$PATH
before_script: skip
script:
- hub release download $(git describe --abbrev=0 --tags) -i '*-linux-amd64-*'
- tar xvfz generate_secret-linux-amd64-${APP_VERSION}.tar.gz -C /tmp
- /tmp/generate_secret
after_failure:
- SLACK_TEXT="${APP_VERSION} $TRAVIS_OS_NAME assets failed verification." send_to_slack.sh
- stage: 'Test github release assets'
if: type = push AND tag IS present AND tag =~ /^v[0-9]+\.[0-9]+\.[0-9]+(\-beta)?[0-9]*$/
name: darwin
os: osx
env: APP_VERSION=${TRAVIS_TAG#v}
before_install:
- ./scripts/pull_travis_ci_tools.sh
- HOMEBREW_NO_AUTO_UPDATE=1 brew install jq
install:
# installs hub to ~/bin
- $HOME/travisci-tools/release_github/install_hub.sh
- export PATH=$HOME/bin:$HOME/travisci-tools/slack:$PATH
before_script: skip
script:
- hub release download $(git describe --abbrev=0 --tags) -i '*-darwin-amd64-*'
- tar xvfz generate_secret-darwin-amd64-${APP_VERSION}.tar.gz -C /tmp
- /tmp/generate_secret
after_failure:
- SLACK_TEXT="${APP_VERSION} $TRAVIS_OS_NAME assets failed verification." send_to_slack.sh
- stage: 'Test github release assets'
if: type = push AND tag IS present AND tag =~ /^v[0-9]+\.[0-9]+\.[0-9]+(\-beta)?[0-9]*$/
name: windows
os: windows
env: APP_VERSION=${TRAVIS_TAG#v}
before_install:
- ./scripts/pull_travis_ci_tools.sh
install:
# installs hub to ~/bin
- $HOME/travisci-tools/release_github/install_hub.sh
- export PATH=$HOME/bin:$HOME/travisci-tools/slack:$PATH
before_script: skip
script:
- hub release download $(git describe --abbrev=0 --tags) -i '*-windows-amd64-*'
- tar xvfz generate_secret-windows-amd64-${APP_VERSION}.tar.gz -C /tmp
- /tmp/generate_secret.exe
after_failure:
- SLACK_TEXT="${APP_VERSION} $TRAVIS_OS_NAME assets failed verification." send_to_slack.sh
- stage: 'Publish (real)'
if: type = push AND tag IS present AND tag =~ /^v[0-9]+\.[0-9]+\.[0-9]+(\-beta)?[0-9]*$/
name: publish and notify in slack
os: linux
env: APP_VERSION=${TRAVIS_TAG#v}
before_install:
- ./scripts/pull_travis_ci_tools.sh
install:
# installs hub to ~/bin
- $HOME/travisci-tools/release_github/install_hub.sh
- export PATH=$HOME/bin:$HOME/travisci-tools/slack:$PATH
before_script: skip
script:
- SLACK_TEXT="${APP_VERSION} all assets verified. Publishing https://github.com/optimizely/agent/releases/tag/${TRAVIS_TAG}" send_to_slack.sh
# how to use hub: https://hub.github.com/hub.1.html
- hub release edit --draft=false -m "" ${TRAVIS_TAG}
- stage: 'Readme-sync-preview'
# publishes changes in your docs pull request (ie, contains changes to /docs/readme-sync directory) to https://rollouts-sandbox-doc-test.readme.io/ for previewing before
# committing to master
before_script: skip
cache: false
# translation: if we're committing to a pull request...
if: type = pull_request
language: node_js
install:
# make dir $HOME/readme-sync2 & clone readme-sync2 repo to it; install dependencies
- mkdir $HOME/readme-sync2 && pushd $HOME/readme-sync2 && git init && git pull https://$CI_USER_TOKEN@github.com/optimizely/readme-sync2.git && popd
- source ~/.nvm/nvm.sh && cd $HOME/readme-sync2 && nvm install && npm install
script:
# we need to be in $TRAVIS_BUILD_DIR in order to run the following git diff properly
- cd $TRAVIS_BUILD_DIR
# print which docs changed in this Pull Request (and which therefore we expect to be updated by readme-sync-2 tool):
- CHANGED_DOCS_FILES=($(git diff --name-only $TRAVIS_COMMIT_RANGE -- docs/readme-sync))
- echo $CHANGED_DOCS_FILES
# only if changes were made in the docs/readme-sync repo, trigger this readme-sync stage and sync the docs
# to staging readme project at https://rollouts-sandbox-doc-test.readme.io/docs
# build v3.1 docs to v 1.0 of readme staging project
- git diff --quiet $TRAVIS_COMMIT_RANGE -- docs/readme-sync/v3.1 || ( cd $HOME/readme-sync2 && npx ts-node sync/index.ts --apiKey $README_SYNC_API_KEY_PREVIEW --version 1.0 --docs $TRAVIS_BUILD_DIR/docs/readme-sync/v3.1)
# build v4.0 docs to v 1.5 of staging project
- git diff --quiet $TRAVIS_COMMIT_RANGE -- docs/readme-sync/v4.0 || ( cd $HOME/readme-sync2 && npx ts-node sync/index.ts --apiKey $README_SYNC_API_KEY_PREVIEW --version 1.5 --docs $TRAVIS_BUILD_DIR/docs/readme-sync/v4.0)
- stage: 'Readme-sync'
before_script: skip
cache: false
# translation: if we're merging into a master branch...
if: type = push AND branch = master
language: node_js
install:
# make dir $HOME/readme-sync2 & clone readme-sync2 repo to it; install dependencies
- mkdir $HOME/readme-sync2 && pushd $HOME/readme-sync2 && git init && git pull https://$CI_USER_TOKEN@github.com/optimizely/readme-sync2.git && popd
- source ~/.nvm/nvm.sh && cd $HOME/readme-sync2 && nvm install && npm install
script:
# we need to be in $TRAVIS_BUILD_DIR in order to run the following git diff properly
- cd $TRAVIS_BUILD_DIR
#print which docs changed in this Pull Request (and which therefore we expect to be updated by readme-sync-2 tool):
- CHANGED_DOCS_FILES=($(git diff --name-only $TRAVIS_COMMIT_RANGE -- docs/readme-sync))
- echo $CHANGED_DOCS_FILES
#only if changes were made in the docs/readme-sync repo, trigger this readme-sync stage and sync the docs to full stack readme project (https://dash.readme.com/project/full-stack/v4.0/docs/welcome)
# sync v3.1 docs folder to readme project v 3.1
- git diff --quiet $TRAVIS_COMMIT_RANGE -- docs/readme-sync/v3.1 || ( cd $HOME/readme-sync2 && npx ts-node sync/index.ts --apiKey $README_SYNC_API_KEY --version 3.1 --docs $TRAVIS_BUILD_DIR/docs/readme-sync/v3.1
# sync v4.0 docs folder to readme project v 4.0
- git diff --quiet $TRAVIS_COMMIT_RANGE -- docs/readme-sync/v4.0 || ( cd $HOME/readme-sync2 && npx ts-node sync/index.ts --apiKey $README_SYNC_API_KEY --version 4.0 --docs $TRAVIS_BUILD_DIR/docs/readme-sync/v4.0
#########################################################################################
# directories/scripts for full SDK-reference-guides, to be implemented after agent docs sync
#########################################################################################
# this commented out code can be used to implement syncing SDK guides in future: https://optimizely.atlassian.net/browse/OASIS-6807
## this preps the input directory for readme-sync script
#- mkdir -p $HOME/readme-sync2/docs/readme-sync/sdk-reference-guides
## ${TRAVIS_REPO_SLUG#optimizely/} translates to go-sdk docs/readme-sync/sdk-reference-guides/go-sdk
#- ln -s $TRAVIS_BUILD_DIR/docs/readme-sync/sdk-reference-guides/${TRAVIS_REPO_SLUG#optimizely/} $HOME/readme-sync2/docs/readme-sync/sdk-reference-guides/${TRAVIS_REPO_SLUG#optimizely/}
## now we need to get all the other *-sdk repos too
##
## first we list all possible sdks and inside the for loop, remove the one we are updating
#- export ALL_SDK_REPOS="android-sdk csharp-sdk go-sdk java-sdk javascript-sdk objective-c-sdk python-sdk react-sdk ruby-sdk swift-sdk"
#- mkdir $HOME/sdks && pushd $HOME/sdks && for i in ${ALL_SDK_REPOS//${TRAVIS_REPO_SLUG#optimizely/}}; do git clone https://github.com/optimizely/$i; ( [ -d "$HOME/sdks/$i/docs/readme-sync/sdk-reference-guides/$i" ] && ln -s $HOME/sdks/$i/docs/readme-sync/sdk-reference-guides/$i $HOME/readme-sync2/docs/readme-sync/sdk-reference-guides/$i ) || true; done && popd
## check our work
#- ls -al $HOME/sdks
#- ls -al $HOME/readme-sync2/docs/readme-sync/sdk-reference-guides
#script:
## we need to be in $TRAVIS_BUILD_DIR in order to run the following git diff properly
#- cd $TRAVIS_BUILD_DIR
#- git diff --quiet $TRAVIS_COMMIT_RANGE -- docs/readme-sync || ( cd $HOME/readme-sync2 && npx ts-node sync/index.ts --apiKey $README_SYNC_API_KEY --version 4.0 --docs docs/readme-sync/ )
before_script:
# https://github.com/travis-ci/gimme
- eval "$(gimme)"
- make -e setup build