|
| 1 | +os: linux |
| 2 | +dist: xenial |
| 3 | +language: shell |
| 4 | + |
| 5 | +env: |
| 6 | + global: |
| 7 | + # GO VERSION is set here with GIMME_GO_VERSION see: https://github.com/travis-ci/gimme |
| 8 | + # may also want to run `go mod edit -go=1.20` to fix go.mod as well |
| 9 | + - GIMME_GO_VERSION=1.20 GIMME_OS=linux GIMME_ARCH=amd64 |
| 10 | + |
| 11 | +branches: |
| 12 | + only: |
| 13 | + - master |
| 14 | + # https://docs.travis-ci.com/user/customizing-the-build/#safelisting-or-blocklisting-branches |
| 15 | + - /^v\d+\.\d+(\.\d+)?(-\S*)?$/ |
| 16 | + |
| 17 | +stages: |
| 18 | + - 'Fmt' |
| 19 | + - 'Tests' |
| 20 | + - 'Trigger FSC Tests' |
| 21 | + - 'Test Build using latest tag (no upload)' |
| 22 | + - 'Build, Upload and Publish (draft)' |
| 23 | + - 'Test github release assets' |
| 24 | + - 'Publish (real)' |
| 25 | + - 'Readme-sync-preview' |
| 26 | + - 'Readme-sync' |
| 27 | + |
| 28 | +jobs: |
| 29 | + |
| 30 | + include: |
| 31 | + |
| 32 | + - stage: Fmt |
| 33 | + script: |
| 34 | + - test -z "$(go fmt ./pkg/...)" |
| 35 | + - stage: Tests |
| 36 | + name: hadolint |
| 37 | + os: linux |
| 38 | + dist: xenial |
| 39 | + script: |
| 40 | + - make -e lint |
| 41 | + - for f in `find scripts/dockerfiles -type f`; do echo $f; docker run --rm -i hadolint/hadolint:v2.1.0 < $f; done |
| 42 | + |
| 43 | + - stage: Tests |
| 44 | + name: coveralls |
| 45 | + os: linux |
| 46 | + dist: xenial |
| 47 | + script: |
| 48 | + - make -e cover COVER_FILE=coverage.txt |
| 49 | + after_success: |
| 50 | + - go get github.com/mattn/goveralls |
| 51 | + - $GOPATH/bin/goveralls -coverprofile=coverage.txt -service=travis-ci |
| 52 | + |
| 53 | + - stage: Tests |
| 54 | + name: sourceclear |
| 55 | + os: linux |
| 56 | + dist: xenial |
| 57 | + addons: |
| 58 | + srcclr: true |
| 59 | + script: |
| 60 | + - go get -v -d ./... |
| 61 | + |
| 62 | + - stage: Tests |
| 63 | + name: windows build.ps1 test |
| 64 | + os: windows |
| 65 | + language: shell |
| 66 | + before_script: skip |
| 67 | + script: |
| 68 | + - PowerShell -Command Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser |
| 69 | + - PowerShell -File "scripts\build.ps1" noninteractive |
| 70 | + - PowerShell -File "scripts\check_exe.ps1" |
| 71 | + after_success: |
| 72 | + - ( [ ${TRAVIS_EVENT_TYPE} = "push" ] && [ ! -z ${TRAVIS_TAG} ] ) && scripts/upload_artifacts.sh |
| 73 | + |
| 74 | + - stage: Tests |
| 75 | + name: acceptance |
| 76 | + os: linux |
| 77 | + dist: xenial |
| 78 | + language: python |
| 79 | + python: "3.9" |
| 80 | + install: |
| 81 | + - pip install -r tests/acceptance/requirements.txt |
| 82 | + script: |
| 83 | + - MYHOST="http://localhost:8080" make test-acceptance |
| 84 | + |
| 85 | + - stage: 'Trigger FSC Tests' |
| 86 | + if: (branch = master AND type = push) OR type = pull_request OR tag IS present |
| 87 | + env: |
| 88 | + SDK=agent |
| 89 | + SDK_BRANCH=$(if [ -z "$TRAVIS_PULL_REQUEST_BRANCH" ]; then echo ${TRAVIS_BRANCH}; else echo "$TRAVIS_PULL_REQUEST_BRANCH"; fi) |
| 90 | + EVENT_TYPE=$TRAVIS_EVENT_TYPE |
| 91 | + PULL_REQUEST_SLUG=$TRAVIS_PULL_REQUEST_SLUG |
| 92 | + PULL_REQUEST_SHA=$TRAVIS_PULL_REQUEST_SHA |
| 93 | + GITHUB_REPOSITORY=$TRAVIS_REPO_SLUG |
| 94 | + UPSTREAM_REPO=$TRAVIS_REPO_SLUG |
| 95 | + UPSTREAM_SHA=$TRAVIS_COMMIT |
| 96 | + PULL_REQUEST_NUMBER=$TRAVIS_PULL_REQUEST |
| 97 | + TOKEN=$GITHUB_TOKEN |
| 98 | + cache: false |
| 99 | + before_install: |
| 100 | + ./scripts/pull_travis_ci_tools.sh |
| 101 | + install: skip |
| 102 | + script: |
| 103 | + - "$HOME/travisci-tools/trigger-script-with-status-update.sh" |
| 104 | + |
| 105 | + - stage: 'Test Build using latest tag (no upload)' |
| 106 | + name: linux |
| 107 | + os: linux |
| 108 | + dist: xenial |
| 109 | + script: |
| 110 | + - export APP_VERSION=$(git describe --abbrev=0 --tags | tr -d '^v') |
| 111 | + - $TRAVIS_BUILD_DIR/scripts/ci_create_packages.sh |
| 112 | + - $TRAVIS_BUILD_DIR/scripts/ci_build_generate_secret.sh |
| 113 | + |
| 114 | + - stage: 'Build, Upload and Publish (draft)' |
| 115 | + if: type = push AND tag IS present AND tag =~ /^v[0-9]+\.[0-9]+\.[0-9]+(\-beta)?[0-9]*$/ |
| 116 | + name: linux |
| 117 | + os: linux |
| 118 | + dist: xenial |
| 119 | + |
| 120 | + # 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. |
| 121 | + # It is also picked up in scripts/Makefile.ci to be used in the package name when they are built. |
| 122 | + |
| 123 | + env: APP_VERSION=${TRAVIS_TAG#v} |
| 124 | + |
| 125 | + before_install: |
| 126 | + - ./scripts/pull_travis_ci_tools.sh |
| 127 | + install: |
| 128 | + # installs hub to ~/bin |
| 129 | + - $HOME/travisci-tools/release_github/install_hub.sh |
| 130 | + - export PATH=$HOME/bin:$HOME/travisci-tools/release_github:$PATH |
| 131 | + |
| 132 | + script: |
| 133 | + # now we're going to create packages & upload packages |
| 134 | + - $TRAVIS_BUILD_DIR/scripts/ci_create_packages.sh && $TRAVIS_BUILD_DIR/scripts/ci_upload_packages.sh |
| 135 | + # create the github release (draft) |
| 136 | + - release_github_v2.sh "$TRAVIS_TAG" |
| 137 | + # attach generate_secret to the github release |
| 138 | + - $TRAVIS_BUILD_DIR/scripts/ci_build_generate_secret.sh && $TRAVIS_BUILD_DIR/scripts/ci_attach_generate_secret.sh |
| 139 | + |
| 140 | + - stage: 'Test github release assets' |
| 141 | + if: type = push AND tag IS present AND tag =~ /^v[0-9]+\.[0-9]+\.[0-9]+(\-beta)?[0-9]*$/ |
| 142 | + name: linux |
| 143 | + os: linux |
| 144 | + env: APP_VERSION=${TRAVIS_TAG#v} |
| 145 | + |
| 146 | + before_install: |
| 147 | + - ./scripts/pull_travis_ci_tools.sh |
| 148 | + |
| 149 | + install: |
| 150 | + # installs hub to ~/bin |
| 151 | + - $HOME/travisci-tools/release_github/install_hub.sh |
| 152 | + - export PATH=$HOME/bin:$HOME/travisci-tools/slack:$PATH |
| 153 | + |
| 154 | + before_script: skip |
| 155 | + |
| 156 | + script: |
| 157 | + - hub release download $(git describe --abbrev=0 --tags) -i '*-linux-amd64-*' |
| 158 | + - tar xvfz generate_secret-linux-amd64-${APP_VERSION}.tar.gz -C /tmp |
| 159 | + - /tmp/generate_secret |
| 160 | + |
| 161 | + after_failure: |
| 162 | + - SLACK_TEXT="${APP_VERSION} $TRAVIS_OS_NAME assets failed verification." send_to_slack.sh |
| 163 | + |
| 164 | + - stage: 'Test github release assets' |
| 165 | + if: type = push AND tag IS present AND tag =~ /^v[0-9]+\.[0-9]+\.[0-9]+(\-beta)?[0-9]*$/ |
| 166 | + name: darwin |
| 167 | + os: osx |
| 168 | + env: APP_VERSION=${TRAVIS_TAG#v} |
| 169 | + |
| 170 | + before_install: |
| 171 | + - ./scripts/pull_travis_ci_tools.sh |
| 172 | + - HOMEBREW_NO_AUTO_UPDATE=1 brew install jq |
| 173 | + |
| 174 | + install: |
| 175 | + # installs hub to ~/bin |
| 176 | + - $HOME/travisci-tools/release_github/install_hub.sh |
| 177 | + - export PATH=$HOME/bin:$HOME/travisci-tools/slack:$PATH |
| 178 | + |
| 179 | + before_script: skip |
| 180 | + |
| 181 | + script: |
| 182 | + - hub release download $(git describe --abbrev=0 --tags) -i '*-darwin-amd64-*' |
| 183 | + - tar xvfz generate_secret-darwin-amd64-${APP_VERSION}.tar.gz -C /tmp |
| 184 | + - /tmp/generate_secret |
| 185 | + |
| 186 | + after_failure: |
| 187 | + - SLACK_TEXT="${APP_VERSION} $TRAVIS_OS_NAME assets failed verification." send_to_slack.sh |
| 188 | + |
| 189 | + - stage: 'Test github release assets' |
| 190 | + if: type = push AND tag IS present AND tag =~ /^v[0-9]+\.[0-9]+\.[0-9]+(\-beta)?[0-9]*$/ |
| 191 | + name: windows |
| 192 | + os: windows |
| 193 | + env: APP_VERSION=${TRAVIS_TAG#v} |
| 194 | + |
| 195 | + before_install: |
| 196 | + - ./scripts/pull_travis_ci_tools.sh |
| 197 | + |
| 198 | + install: |
| 199 | + # installs hub to ~/bin |
| 200 | + - $HOME/travisci-tools/release_github/install_hub.sh |
| 201 | + - export PATH=$HOME/bin:$HOME/travisci-tools/slack:$PATH |
| 202 | + |
| 203 | + before_script: skip |
| 204 | + |
| 205 | + script: |
| 206 | + - hub release download $(git describe --abbrev=0 --tags) -i '*-windows-amd64-*' |
| 207 | + - tar xvfz generate_secret-windows-amd64-${APP_VERSION}.tar.gz -C /tmp |
| 208 | + - /tmp/generate_secret.exe |
| 209 | + |
| 210 | + after_failure: |
| 211 | + - SLACK_TEXT="${APP_VERSION} $TRAVIS_OS_NAME assets failed verification." send_to_slack.sh |
| 212 | + |
| 213 | + - stage: 'Publish (real)' |
| 214 | + if: type = push AND tag IS present AND tag =~ /^v[0-9]+\.[0-9]+\.[0-9]+(\-beta)?[0-9]*$/ |
| 215 | + name: publish and notify in slack |
| 216 | + os: linux |
| 217 | + env: APP_VERSION=${TRAVIS_TAG#v} |
| 218 | + |
| 219 | + before_install: |
| 220 | + - ./scripts/pull_travis_ci_tools.sh |
| 221 | + |
| 222 | + install: |
| 223 | + # installs hub to ~/bin |
| 224 | + - $HOME/travisci-tools/release_github/install_hub.sh |
| 225 | + - export PATH=$HOME/bin:$HOME/travisci-tools/slack:$PATH |
| 226 | + |
| 227 | + before_script: skip |
| 228 | + |
| 229 | + script: |
| 230 | + - SLACK_TEXT="${APP_VERSION} all assets verified. Publishing https://github.com/optimizely/agent/releases/tag/${TRAVIS_TAG}" send_to_slack.sh |
| 231 | + # how to use hub: https://hub.github.com/hub.1.html |
| 232 | + - hub release edit --draft=false -m "" ${TRAVIS_TAG} |
| 233 | + |
| 234 | + - stage: 'Readme-sync-preview' |
| 235 | + # 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 |
| 236 | + # committing to master |
| 237 | + before_script: skip |
| 238 | + cache: false |
| 239 | + # translation: if we're committing to a pull request... |
| 240 | + if: false AND type = pull_request |
| 241 | + |
| 242 | + language: node_js |
| 243 | + install: |
| 244 | + |
| 245 | + |
| 246 | + # make dir $HOME/readme-sync2 & clone readme-sync2 repo to it; install dependencies |
| 247 | + |
| 248 | + - mkdir $HOME/readme-sync2 && pushd $HOME/readme-sync2 && git init && git pull https://[email protected]/optimizely/readme-sync2.git && popd |
| 249 | + - source ~/.nvm/nvm.sh && cd $HOME/readme-sync2 && nvm install && npm install |
| 250 | + |
| 251 | + script: |
| 252 | + # we need to be in $TRAVIS_BUILD_DIR in order to run the following git diff properly |
| 253 | + - cd $TRAVIS_BUILD_DIR |
| 254 | + |
| 255 | + # print which docs changed in this Pull Request (and which therefore we expect to be updated by readme-sync-2 tool): |
| 256 | + - CHANGED_DOCS_FILES=($(git diff --name-only $TRAVIS_COMMIT_RANGE -- docs/readme-sync)) |
| 257 | + - echo $CHANGED_DOCS_FILES |
| 258 | + |
| 259 | + # only if changes were made in the docs/readme-sync repo, trigger this readme-sync stage and sync the docs |
| 260 | + # to staging readme project at https://rollouts-sandbox-doc-test.readme.io/docs |
| 261 | + |
| 262 | + |
| 263 | + # build v3.1 docs to v 1.0 of readme staging project |
| 264 | + - 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) |
| 265 | + # build v4.0 docs to v 1.5 of staging project |
| 266 | + - 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) |
| 267 | + |
| 268 | + - stage: 'Readme-sync' |
| 269 | + before_script: skip |
| 270 | + cache: false |
| 271 | + # translation: if we're merging into a master branch... |
| 272 | + if: false AND type = push AND branch = master |
| 273 | + |
| 274 | + language: node_js |
| 275 | + install: |
| 276 | + |
| 277 | + |
| 278 | + # make dir $HOME/readme-sync2 & clone readme-sync2 repo to it; install dependencies |
| 279 | + |
| 280 | + - mkdir $HOME/readme-sync2 && pushd $HOME/readme-sync2 && git init && git pull https://[email protected]/optimizely/readme-sync2.git && popd |
| 281 | + - source ~/.nvm/nvm.sh && cd $HOME/readme-sync2 && nvm install && npm install |
| 282 | + |
| 283 | + script: |
| 284 | + # we need to be in $TRAVIS_BUILD_DIR in order to run the following git diff properly |
| 285 | + - cd $TRAVIS_BUILD_DIR |
| 286 | + |
| 287 | + #print which docs changed in this Pull Request (and which therefore we expect to be updated by readme-sync-2 tool): |
| 288 | + - CHANGED_DOCS_FILES=($(git diff --name-only $TRAVIS_COMMIT_RANGE -- docs/readme-sync)) |
| 289 | + - echo $CHANGED_DOCS_FILES |
| 290 | + |
| 291 | + #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) |
| 292 | + # sync v3.1 docs folder to readme project v 3.1 |
| 293 | + - 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 |
| 294 | + # sync v4.0 docs folder to readme project v 4.0 |
| 295 | + - 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 |
| 296 | + ######################################################################################### |
| 297 | + # directories/scripts for full SDK-reference-guides, to be implemented after agent docs sync |
| 298 | + ######################################################################################### |
| 299 | + # this commented out code can be used to implement syncing SDK guides in future: https://optimizely.atlassian.net/browse/OASIS-6807 |
| 300 | + ## this preps the input directory for readme-sync script |
| 301 | + #- mkdir -p $HOME/readme-sync2/docs/readme-sync/sdk-reference-guides |
| 302 | + ## ${TRAVIS_REPO_SLUG#optimizely/} translates to go-sdk docs/readme-sync/sdk-reference-guides/go-sdk |
| 303 | + #- 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/} |
| 304 | + |
| 305 | + ## now we need to get all the other *-sdk repos too |
| 306 | + ## |
| 307 | + ## first we list all possible sdks and inside the for loop, remove the one we are updating |
| 308 | + #- 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" |
| 309 | + #- 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 |
| 310 | + ## check our work |
| 311 | + #- ls -al $HOME/sdks |
| 312 | + #- ls -al $HOME/readme-sync2/docs/readme-sync/sdk-reference-guides |
| 313 | + #script: |
| 314 | + ## we need to be in $TRAVIS_BUILD_DIR in order to run the following git diff properly |
| 315 | + #- cd $TRAVIS_BUILD_DIR |
| 316 | + #- 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/ ) |
| 317 | + |
| 318 | + |
| 319 | + |
| 320 | +before_script: |
| 321 | + # https://github.com/travis-ci/gimme |
| 322 | + - eval "$(gimme)" |
| 323 | + - make -e setup build |
0 commit comments