2019-07-26 16:32:13 +00:00
|
|
|
### ***
|
|
|
|
### WARNING: DO NOT manually EDIT or MERGE this file, it is generated by 'make ci-config'.
|
|
|
|
### INSTEAD: Edit or merge the source in config/ then run 'make ci-config'.
|
|
|
|
### ***
|
ci/packagespec (#9653)
* add packagespec build system
- The majority of changes in this commit are files generated
by packagespec (everything in the packages-oss.lock directory).
* add .yamllint
* update to packagespec@fd54aea4
* ci: bust packagespec cache
- Change to packagespec results in package IDs that can use
git tag refs, not just commit refs.
* update to packagepsec@5fc121d0
- This busts all caches, because of a change to the way we
no longer traverse from tag refs to commit refs, due to
the potential confusion this can cause.
- See https://github.com/hashicorp/packagespec/commit/fd54aea4827bb6cfd637c78a2ab6274111605330
for the original change to packagespec necessitating this.
* update to packagespec@5e6c87b6
- This completes the change to allowing git tag refs
to be used for source IDs, begun in f130b940a8fbe3e9398225b08ea1d63420bef7b6
* update to packagespec@4d3c9e8b
- This busts cache, needed to apply previous change.
* remove RELEASE_BUILD_WORKFLOW_NAME
* update packagespec, add watch-ci target
* fix package names (do not refer to EDITION)
* remove EDITION input from packages-oss.yml
* bump package cache, update packagespec
* update packagespec, add 'aliases' target
* update packagespec; less output noise
* ci: give release bundle file a better name
- When performing a release build, this will include the build ID
as part of the name, making it easier to distinguish from other
builds.
* ci: create aliases tarball artifact
* ci: cache package metadata files
* ci: add metadata artifact
* ci: bust circleci package cache
* Revert "ci: bust circleci package cache"
This reverts commit 1320d182613466f0999d63f5742db12ac17f8e92.
* ci: remove aliases artifact
* ci: use buildID not workflowName to id artifacts
* packages: add BUNDLE_NAME metadata
* do not cache package metadata with binaries
* ci: bump package cache
* ci: debugging
* ci: fix package cache; update packagespec
* ci: update packagespec to 10e7beb2
* ci: write package metadata and aliases
* ci: switch to .zip artifacts
* switch package bundle back to tar.gz (from zip)
- Because of the way zip works, the zip archive was over 2GB rather than under 750MB as with tar.gz.
* bump packagespec, adds list-staged-builds
* update packagespec
* add publish stub + general tidy up
* bump packagespec
* bump packagespec; add make publish-config
* Makefile: tidy up packagespec targets
* pass PRODUCT_REPO_ROOT to packagespec
* bump go to 1.14.6
* packages-oss.yml: use more explicit base image
* bump packagespec to b899b7c1
* bump packagespec to f040ce8f
* packages-oss.yml: pin base image to digest
- This digest is pointed to by debian:buster-20200720
- Using a specific digest ensures that builds use the same
base image in all contexts
* add release-repo; bump packagespec
* remove BUILD_TAGS and -tags flag
* bump packagespec to e444f742
* bump to go1.14.7
* ci: bump to go1.14.7
2020-08-11 09:00:59 +00:00
|
|
|
# Orb 'circleci/slack@3.2.0' resolved to 'circleci/slack@3.2.0'
|
2019-05-03 23:05:10 +00:00
|
|
|
version: 2
|
|
|
|
jobs:
|
|
|
|
install-ui-dependencies:
|
|
|
|
docker:
|
2021-07-22 21:09:12 +00:00
|
|
|
- image: docker.mirror.hashicorp.services/node:14-buster
|
2019-07-24 13:13:41 +00:00
|
|
|
shell: /usr/bin/env bash -euo pipefail -c
|
2021-12-14 16:11:13 +00:00
|
|
|
working_directory: /home/circleci/go/src/github.com/hashicorp/vault
|
2019-05-03 23:05:10 +00:00
|
|
|
steps:
|
2019-06-11 14:55:53 +00:00
|
|
|
- checkout
|
|
|
|
- restore_cache:
|
2021-12-14 17:43:52 +00:00
|
|
|
key: yarn-lock-v7-{{ checksum "ui/yarn.lock" }}
|
2021-06-25 16:17:05 +00:00
|
|
|
name: Restore yarn cache
|
2019-06-11 14:55:53 +00:00
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
cd ui
|
2019-08-20 15:22:55 +00:00
|
|
|
yarn install
|
2019-06-11 14:55:53 +00:00
|
|
|
npm rebuild node-sass
|
|
|
|
name: Install UI dependencies
|
|
|
|
- save_cache:
|
2021-12-14 17:43:52 +00:00
|
|
|
key: yarn-lock-v7-{{ checksum "ui/yarn.lock" }}
|
2021-06-25 16:17:05 +00:00
|
|
|
name: Save yarn cache
|
2019-06-11 14:55:53 +00:00
|
|
|
paths:
|
|
|
|
- ui/node_modules
|
2019-05-03 23:05:10 +00:00
|
|
|
test-ui:
|
|
|
|
docker:
|
2021-07-22 21:09:12 +00:00
|
|
|
- image: docker.mirror.hashicorp.services/node:14-buster
|
2019-07-24 13:13:41 +00:00
|
|
|
shell: /usr/bin/env bash -euo pipefail -c
|
2021-12-14 16:11:13 +00:00
|
|
|
working_directory: /home/circleci/go/src/github.com/hashicorp/vault
|
Ember-cli upgrade from ~3.8 to ~3.20 (#9972)
* Update ember-cli to ~3.20
* Remove bad optional-feature
* Remove ember-fetch dep
* re-install ember-fetch
* update model fragments pr
* update ember model fragments correct package name
* update ember composable helpers to solve array helper error
* update ember-concurrency
* add back engine dependencies, automatically removed during ember-cli-upgrade
* make author-form-options component js file otherwise error
* for now comment out withTestWaiter
* add eslint-node and fix if not with unless in templates
* fix linting for tab index of false is now -1 and add type button to all buttons without types
* fix href errors for linting, likely have to come back and fix
* using eslint fix flag to fix all this.gets
* ember modules codemode removed files that had module twice, will fix in next commit
* finish codemode ember-data-codemod needed to rename const model
* more this.get removal codemode did not work
* cont. removal of this.get
* stop mixin rules until figure out how to reconfig them all
* smaller eslint ignores
* get codemode
* testing app small fixes to bring it back after all the changes
* small changes to eslint
* test removal of getProperties
* fix issue with baseKey because value could be unknown needed to add a question mark in nested get
* smaller linting fixes
* get nested fixes
* small linting error fixes
* small linting changes
* working through more small linting changes
* another round of linting modifications
* liniting fixes
* ember module codemod
* quinit dom codemod
* angle bracket codemod
* discovered that components must have js files
* ran all codemods this is all that's left
* small changes to fix get needs two object, should not have been using get.
* fix issue with one input in form field
* fun times with set and onChange from oninput
* fix issue with model not being passed through on secret-edit-display
* fix issue with yarn run test not working, revert without npm run all
* linting and small fix when loading without a selectAuthBackend
* fix failing test with ui-wizard issue
* fix test failure due to model not being asked for correctly with new changes, probably run into this more.
* fix issue with component helper and at props specific to wizard
* rename log to clilog due to conflict with new eslint rule
* small changes for test failures
* component helper at fixes
* Revert to old component style something with new one broke this and can't figure it out for now
* small fishy smelling test fixes will revisit
* small test changes
* more small test changes, appears upgrade treats spaces differently
* comment out code and test that no longer seems relevant but confirm
* clean run on component test though still some potential timing issues on ui-console test
* fixing one auth test issue and timing issue on enable-test
* small mods
* fix this conditional check from upgrade
* linting fixes after master merge
* package updates using yarn upgrade-interactive
* update libraries that did not effect any of the test failures.
* update ember truth helpers library
* settling tests
* Fix ui-panel control group output
* fix features selection test failures
* Fix auth tests (x-vault-token)
* fix shared test
* fix issue with data null on backend
* Revert "Fix auth tests (x-vault-token)"
This reverts commit 89cb174b2f1998efa56d9604d14131415ae65d6f.
* Fix auth tests (x-vault-token) without updating this.set
* Update redirect-to tests
* fix wrapped token test
* skip some flaky test
* fix issue with href and a tags vs buttons
* fix linting
* updates to get tests running (#10409)
* yarn isntall
* increasing resource_class
* whoops
* trying large
* back to xlarge
* Fix param issue on transform item routes
* test fixes
* settle on policies (old) test
* fix browserstack test warning and skips of test confirmed worked
* Fix redirect-to test
* skips
* fix transformation test and skip some kmip
* Skip tests
* Add meep marker to remaining failing tests
* Skip test with failing component
* rever skip on secret-create test
* Skip piece of test that fails due to navigation-input
* fix settings test where can and skip in others after confirming
* fix circle ci test failures
* ssh role settle
* Fix navigate-input and add settled to test
* Remove extra import
* secret cubbyhole and alicloud
* Add settled to gcpkms test
* settles on redirect to test
* Bump browserstack test resource to large
* Update browserstack resource size to xlarge
* update todos
* add back in withTestWaiter
* try and fix credentials conditional action added comment instead
* Update volatile computed properies to get functions
* this step was never reached and we never defined secretType anywhere so I removed
* add settled to policy old test
* Fix navigate-input on policies and leases
* replace ssh test with no var hoping that helps and add settled to other failing tests, unskip console tests
* kmip, transit, role test remove a skip and add in settled
* fix hover copy button, had to remove some testing functionality
* Remove private router service
* remove skip on control ssh and ui panel, fix search select by restructuring how to read the error
* final bit of working through skipped test
* Replace clearNonGlobalModels by linking directly to namespace with href-to
* Remove unused var
* Fix role-ssh id bug by updating form-field-from-model to form-field-group-loop
* Fix transit create id would not update
* Update option toggle selector for ssh-role
* Fix ssh selector
* cleanup pt1
* small clean up
* cleanup part2
* Fix computed on pricing-metrics-form
* small cleanup based on chelseas comments.
Co-authored-by: Chelsea Shaw <chelshaw.dev@gmail.com>
Co-authored-by: Sarah Thompson <sthompson@hashicorp.com>
2020-12-03 23:00:22 +00:00
|
|
|
resource_class: xlarge
|
2019-05-03 23:05:10 +00:00
|
|
|
steps:
|
2021-06-10 19:08:53 +00:00
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
case "$CIRCLE_BRANCH" in
|
2021-06-18 18:24:54 +00:00
|
|
|
main|ui/*|release/*|merge*) ;;
|
2021-06-10 19:08:53 +00:00
|
|
|
*) # If the branch being tested doesn't match one of the above patterns,
|
|
|
|
# we don't need to run test-ui and can abort the job.
|
|
|
|
circleci-agent step halt
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# exit with success either way
|
|
|
|
exit 0
|
|
|
|
name: Check branch name
|
|
|
|
working_directory: ~/
|
2019-06-11 14:55:53 +00:00
|
|
|
- checkout
|
|
|
|
- restore_cache:
|
2021-12-14 17:43:52 +00:00
|
|
|
key: yarn-lock-v7-{{ checksum "ui/yarn.lock" }}
|
2021-06-25 16:17:05 +00:00
|
|
|
name: Restore yarn cache
|
2019-06-11 14:55:53 +00:00
|
|
|
- attach_workspace:
|
|
|
|
at: .
|
|
|
|
- run:
|
|
|
|
command: |
|
2019-07-24 13:13:41 +00:00
|
|
|
set -x
|
2019-05-24 12:02:51 +00:00
|
|
|
|
2019-06-11 14:55:53 +00:00
|
|
|
# Install Chrome
|
|
|
|
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub \
|
|
|
|
| apt-key add -
|
|
|
|
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" \
|
|
|
|
| tee /etc/apt/sources.list.d/google-chrome.list
|
|
|
|
apt-get update
|
|
|
|
apt-get -y install google-chrome-stable
|
|
|
|
rm /etc/apt/sources.list.d/google-chrome.list
|
|
|
|
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
|
2019-05-24 12:02:51 +00:00
|
|
|
|
2019-06-11 14:55:53 +00:00
|
|
|
# Add ./bin to the PATH so vault binary can be run by Ember tests
|
|
|
|
export PATH="${PWD}/bin:${PATH}"
|
2019-05-24 12:02:51 +00:00
|
|
|
|
2019-06-11 14:55:53 +00:00
|
|
|
# Run Ember tests
|
|
|
|
cd ui
|
|
|
|
mkdir -p test-results/qunit
|
Update ui dependencies (#7244)
* be more specific about node version, and specify a yarn version
* update ember, ember-cli, ember-data, ember-data-model-fragments
* use router handlers to access transition information
* fix shadowing of component helper
* update ivy-codemirror, ember-cli-inject-live-reload
* remove custom router service
* don't use transition.queryParams
* update ember-cli-deprecation-workflow
* refactor kv v1 to use 'path' instead of 'id' on creation
* fix auth-jwt-test and toolbar-link-test
* update ember composable helpers
* remove Ember.copy from test file
* no more deprecations in the workflow
* fix more secret tests
* fix remaining failed tests
* move select component to core because it's used by ttl-picker
* generate new model class for each test instead of reusing an existing one
* fix selectors on kmip tests
* refactor how control groups construct urls from the new transition objects
* add router service override back in, and have it be evented so that we can trigger router events on it
* move stories and markdown files to core if the component lives in core
* update ember-cli, ember-cli-babel, ember-auto-import
* update base64js, date-fns, deepmerge, codemirror, broccoli-asset-rev
* update linting rules
* fix test selectors
* update ember-api-actions, ember-concurrency, ember-load-initializers, escape-string-regexp, normalize.css, prettier-eslint-cli, jsdoc-to-markdown
* remove test-results dir
* update base64js, ember-cli-clipboard, ember-cli-sass, ember-cli-string-helpers, ember-cli-template-lint, ember-cli-uglify, ember-link-action
* fix linting
* run yarn install without restoring from cache
* refactor how tests are run and handle the vault server subprocess
* update makefile for new test task names
* update circle config to use the new yarn task
* fix writing the seal keys when starting the dev server
* remove optional deps from the lockfile
* don't ignore-optional on yarn install
* remove errant console.log
* update ember-basic-dropdown-hover, jsonlint, yargs-parser
* update ember-cli-flash
* add back optionalDeps
* update @babel/core@7.5.5, ember-basic-dropdown@1.1.3, eslint-plugin-ember@6.8.2
* update storybook to the latest release
* add a babel config with targets so that the ember babel plugin works properly
* update ember-resolver, move ember-cli-storybook to devDependencies
* revert normalize.css upgrade
* silence fetchadapter warning for now
* exclude 3rd party array helper now that ember includes one
* fix switch and entity lookup styling
* only add -root suffix if it's not in versions mode
* make sure drop always has an array on the aws role form
* fix labels like we did with the backport
* update eslintignore
* update the yarn version in the docker build file
* update eslint ignore
2019-08-19 20:45:39 +00:00
|
|
|
yarn test:oss
|
2019-06-11 14:55:53 +00:00
|
|
|
name: Test UI
|
|
|
|
- store_artifacts:
|
|
|
|
path: ui/test-results
|
|
|
|
- store_test_results:
|
|
|
|
path: ui/test-results
|
2019-07-24 13:13:41 +00:00
|
|
|
test-ui-browserstack:
|
|
|
|
docker:
|
2021-07-22 21:09:12 +00:00
|
|
|
- image: docker.mirror.hashicorp.services/node:14-buster
|
2019-07-24 13:13:41 +00:00
|
|
|
shell: /usr/bin/env bash -euo pipefail -c
|
2021-12-14 16:11:13 +00:00
|
|
|
working_directory: /home/circleci/go/src/github.com/hashicorp/vault
|
Ember-cli upgrade from ~3.8 to ~3.20 (#9972)
* Update ember-cli to ~3.20
* Remove bad optional-feature
* Remove ember-fetch dep
* re-install ember-fetch
* update model fragments pr
* update ember model fragments correct package name
* update ember composable helpers to solve array helper error
* update ember-concurrency
* add back engine dependencies, automatically removed during ember-cli-upgrade
* make author-form-options component js file otherwise error
* for now comment out withTestWaiter
* add eslint-node and fix if not with unless in templates
* fix linting for tab index of false is now -1 and add type button to all buttons without types
* fix href errors for linting, likely have to come back and fix
* using eslint fix flag to fix all this.gets
* ember modules codemode removed files that had module twice, will fix in next commit
* finish codemode ember-data-codemod needed to rename const model
* more this.get removal codemode did not work
* cont. removal of this.get
* stop mixin rules until figure out how to reconfig them all
* smaller eslint ignores
* get codemode
* testing app small fixes to bring it back after all the changes
* small changes to eslint
* test removal of getProperties
* fix issue with baseKey because value could be unknown needed to add a question mark in nested get
* smaller linting fixes
* get nested fixes
* small linting error fixes
* small linting changes
* working through more small linting changes
* another round of linting modifications
* liniting fixes
* ember module codemod
* quinit dom codemod
* angle bracket codemod
* discovered that components must have js files
* ran all codemods this is all that's left
* small changes to fix get needs two object, should not have been using get.
* fix issue with one input in form field
* fun times with set and onChange from oninput
* fix issue with model not being passed through on secret-edit-display
* fix issue with yarn run test not working, revert without npm run all
* linting and small fix when loading without a selectAuthBackend
* fix failing test with ui-wizard issue
* fix test failure due to model not being asked for correctly with new changes, probably run into this more.
* fix issue with component helper and at props specific to wizard
* rename log to clilog due to conflict with new eslint rule
* small changes for test failures
* component helper at fixes
* Revert to old component style something with new one broke this and can't figure it out for now
* small fishy smelling test fixes will revisit
* small test changes
* more small test changes, appears upgrade treats spaces differently
* comment out code and test that no longer seems relevant but confirm
* clean run on component test though still some potential timing issues on ui-console test
* fixing one auth test issue and timing issue on enable-test
* small mods
* fix this conditional check from upgrade
* linting fixes after master merge
* package updates using yarn upgrade-interactive
* update libraries that did not effect any of the test failures.
* update ember truth helpers library
* settling tests
* Fix ui-panel control group output
* fix features selection test failures
* Fix auth tests (x-vault-token)
* fix shared test
* fix issue with data null on backend
* Revert "Fix auth tests (x-vault-token)"
This reverts commit 89cb174b2f1998efa56d9604d14131415ae65d6f.
* Fix auth tests (x-vault-token) without updating this.set
* Update redirect-to tests
* fix wrapped token test
* skip some flaky test
* fix issue with href and a tags vs buttons
* fix linting
* updates to get tests running (#10409)
* yarn isntall
* increasing resource_class
* whoops
* trying large
* back to xlarge
* Fix param issue on transform item routes
* test fixes
* settle on policies (old) test
* fix browserstack test warning and skips of test confirmed worked
* Fix redirect-to test
* skips
* fix transformation test and skip some kmip
* Skip tests
* Add meep marker to remaining failing tests
* Skip test with failing component
* rever skip on secret-create test
* Skip piece of test that fails due to navigation-input
* fix settings test where can and skip in others after confirming
* fix circle ci test failures
* ssh role settle
* Fix navigate-input and add settled to test
* Remove extra import
* secret cubbyhole and alicloud
* Add settled to gcpkms test
* settles on redirect to test
* Bump browserstack test resource to large
* Update browserstack resource size to xlarge
* update todos
* add back in withTestWaiter
* try and fix credentials conditional action added comment instead
* Update volatile computed properies to get functions
* this step was never reached and we never defined secretType anywhere so I removed
* add settled to policy old test
* Fix navigate-input on policies and leases
* replace ssh test with no var hoping that helps and add settled to other failing tests, unskip console tests
* kmip, transit, role test remove a skip and add in settled
* fix hover copy button, had to remove some testing functionality
* Remove private router service
* remove skip on control ssh and ui panel, fix search select by restructuring how to read the error
* final bit of working through skipped test
* Replace clearNonGlobalModels by linking directly to namespace with href-to
* Remove unused var
* Fix role-ssh id bug by updating form-field-from-model to form-field-group-loop
* Fix transit create id would not update
* Update option toggle selector for ssh-role
* Fix ssh selector
* cleanup pt1
* small clean up
* cleanup part2
* Fix computed on pricing-metrics-form
* small cleanup based on chelseas comments.
Co-authored-by: Chelsea Shaw <chelshaw.dev@gmail.com>
Co-authored-by: Sarah Thompson <sthompson@hashicorp.com>
2020-12-03 23:00:22 +00:00
|
|
|
resource_class: xlarge
|
2019-07-24 13:13:41 +00:00
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- restore_cache:
|
2021-12-14 17:43:52 +00:00
|
|
|
key: yarn-lock-v7-{{ checksum "ui/yarn.lock" }}
|
2021-06-25 16:17:05 +00:00
|
|
|
name: Restore yarn cache
|
2019-07-24 13:13:41 +00:00
|
|
|
- attach_workspace:
|
|
|
|
at: .
|
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
# Add ./bin to the PATH so vault binary can be found.
|
|
|
|
export PATH="${PWD}"/bin:${PATH}
|
|
|
|
make test-ui-browserstack
|
|
|
|
name: Run Browserstack Tests
|
2020-06-29 15:39:08 +00:00
|
|
|
build-go-dev:
|
2019-05-03 23:05:10 +00:00
|
|
|
machine: true
|
2019-07-24 13:13:41 +00:00
|
|
|
shell: /usr/bin/env bash -euo pipefail -c
|
2021-12-14 16:11:13 +00:00
|
|
|
working_directory: /home/circleci/go/src/github.com/hashicorp/vault
|
2019-06-11 14:55:53 +00:00
|
|
|
steps:
|
2020-03-02 20:08:42 +00:00
|
|
|
- run:
|
|
|
|
command: |
|
2020-06-29 15:39:08 +00:00
|
|
|
[ -n "$GO_VERSION" ] || { echo "You must set GO_VERSION"; exit 1; }
|
|
|
|
# Install Go
|
|
|
|
curl -sSLO "https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz"
|
|
|
|
sudo rm -rf /usr/local/go
|
|
|
|
sudo tar -C /usr/local -xzf "go${GO_VERSION}.linux-amd64.tar.gz"
|
|
|
|
rm -f "go${GO_VERSION}.linux-amd64.tar.gz"
|
2021-12-14 16:11:13 +00:00
|
|
|
GOPATH="/home/circleci/go"
|
2020-06-29 15:39:08 +00:00
|
|
|
mkdir $GOPATH 2>/dev/null || { sudo mkdir $GOPATH && sudo chmod 777 $GOPATH; }
|
|
|
|
echo "export GOPATH='$GOPATH'" >> "$BASH_ENV"
|
|
|
|
echo "export PATH='$PATH:$GOPATH/bin:/usr/local/go/bin'" >> "$BASH_ENV"
|
2021-06-25 16:17:05 +00:00
|
|
|
echo "export GOPROXY=off" >> "$BASH_ENV"
|
|
|
|
echo "export GOPRIVATE=github.com/hashicorp/*" >> "$BASH_ENV"
|
2020-06-29 15:39:08 +00:00
|
|
|
|
|
|
|
echo "$ go version"
|
|
|
|
go version
|
|
|
|
name: Setup Go
|
2020-03-02 20:08:42 +00:00
|
|
|
working_directory: ~/
|
2020-06-29 15:39:08 +00:00
|
|
|
- checkout
|
2021-06-25 16:17:05 +00:00
|
|
|
- restore_cache:
|
|
|
|
keys:
|
2021-12-14 16:11:13 +00:00
|
|
|
- v1.4-{{checksum "go.sum"}}-{{checksum "sdk/go.sum"}}-{{checksum "api/go.sum"}}
|
2021-06-25 16:17:05 +00:00
|
|
|
name: Restore exact go modules cache
|
2020-06-29 15:39:08 +00:00
|
|
|
- attach_workspace:
|
|
|
|
at: .
|
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
# Move dev UI assets to expected location
|
|
|
|
rm -rf ./pkg
|
|
|
|
mkdir ./pkg
|
|
|
|
|
|
|
|
# Build dev binary
|
|
|
|
make ci-bootstrap dev
|
|
|
|
name: Build dev binary
|
|
|
|
- persist_to_workspace:
|
|
|
|
paths:
|
|
|
|
- bin
|
|
|
|
root: .
|
|
|
|
environment:
|
|
|
|
- CIRCLECI_CLI_VERSION: 0.1.5546
|
|
|
|
- GO_TAGS: ''
|
2022-02-23 20:08:08 +00:00
|
|
|
- GO_VERSION: 1.17.7
|
2022-01-31 23:24:16 +00:00
|
|
|
- GOFUMPT_VERSION: 0.2.1
|
2020-07-21 17:18:17 +00:00
|
|
|
- GOTESTSUM_VERSION: 0.5.2
|
2020-06-29 15:39:08 +00:00
|
|
|
algolia-index:
|
|
|
|
docker:
|
2021-12-23 17:03:23 +00:00
|
|
|
- image: node:14
|
2020-06-29 15:39:08 +00:00
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
if [ "$CIRCLE_REPOSITORY_URL" != "git@github.com:hashicorp/vault.git" ]; then
|
|
|
|
echo "Not Vault OSS Repo, not indexing Algolia"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
cd website/
|
2021-12-23 17:03:23 +00:00
|
|
|
npm install -g npm@latest
|
2020-06-29 15:39:08 +00:00
|
|
|
npm install
|
|
|
|
node scripts/index_search_content.js
|
|
|
|
name: Push content to Algolia Index
|
2020-09-15 14:01:26 +00:00
|
|
|
test-go-remote-docker:
|
|
|
|
docker:
|
2022-02-23 20:08:08 +00:00
|
|
|
- image: docker.mirror.hashicorp.services/cimg/go:1.17.7
|
2020-12-03 15:57:21 +00:00
|
|
|
resource_class: medium
|
2021-12-14 16:11:13 +00:00
|
|
|
working_directory: /home/circleci/go/src/github.com/hashicorp/vault
|
2020-09-15 14:01:26 +00:00
|
|
|
parallelism: 8
|
|
|
|
steps:
|
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
# If the branch being tested starts with ui/ or docs/ we want to exit the job without failing
|
2022-01-11 14:02:47 +00:00
|
|
|
[[ "$CIRCLE_BRANCH" = ui/* || "$CIRCLE_BRANCH" = docs/* || "$CIRCLE_BRANCH" = backport/docs/* ]] && {
|
2020-09-15 14:01:26 +00:00
|
|
|
# stop the job from this step
|
|
|
|
circleci-agent step halt
|
|
|
|
}
|
|
|
|
# exit with success either way
|
|
|
|
exit 0
|
|
|
|
name: Check branch name
|
|
|
|
working_directory: ~/
|
|
|
|
- checkout
|
|
|
|
- setup_remote_docker:
|
|
|
|
docker_layer_caching: true
|
|
|
|
version: 18.09.3
|
2021-06-28 15:07:00 +00:00
|
|
|
- add_ssh_keys:
|
|
|
|
fingerprints:
|
|
|
|
- 0e:03:77:f4:e2:c3:56:c2:53:6a:03:e1:31:91:2f:06
|
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
git config --global url."git@github.com:".insteadOf https://github.com/
|
2021-04-06 13:42:14 +00:00
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
TZ=GMT date '+%Y%m%d' > /tmp/go-cache-key
|
|
|
|
name: Compute test cache key
|
|
|
|
- restore_cache:
|
|
|
|
keys:
|
|
|
|
- go-test-cache-date-v1-{{ checksum "/tmp/go-cache-key" }}
|
2021-06-25 16:17:05 +00:00
|
|
|
- restore_cache:
|
|
|
|
keys:
|
2021-12-14 16:11:13 +00:00
|
|
|
- v1.4-{{checksum "go.sum"}}-{{checksum "sdk/go.sum"}}-{{checksum "api/go.sum"}}
|
2021-06-25 16:17:05 +00:00
|
|
|
name: Restore exact go modules cache
|
2020-09-15 14:01:26 +00:00
|
|
|
- run:
|
|
|
|
command: |
|
2021-11-03 13:00:38 +00:00
|
|
|
set -exo pipefail
|
2020-09-15 14:01:26 +00:00
|
|
|
|
2021-06-11 17:18:37 +00:00
|
|
|
EXTRA_TAGS=
|
2020-09-15 14:01:26 +00:00
|
|
|
case "" in
|
|
|
|
*-race*) export VAULT_CI_GO_TEST_RACE=1;;
|
2021-06-11 17:18:37 +00:00
|
|
|
*) EXTRA_TAGS=deadlock;;
|
2020-09-15 14:01:26 +00:00
|
|
|
esac
|
|
|
|
|
|
|
|
# Install CircleCI CLI
|
|
|
|
curl -sSL \
|
|
|
|
"https://github.com/CircleCI-Public/circleci-cli/releases/download/v${CIRCLECI_CLI_VERSION}/circleci-cli_${CIRCLECI_CLI_VERSION}_linux_amd64.tar.gz" \
|
|
|
|
| sudo tar --overwrite -xz \
|
|
|
|
-C /usr/local/bin \
|
|
|
|
"circleci-cli_${CIRCLECI_CLI_VERSION}_linux_amd64/circleci"
|
|
|
|
|
|
|
|
USE_DOCKER=0
|
|
|
|
USE_DOCKER=1
|
|
|
|
|
2021-09-27 20:49:10 +00:00
|
|
|
# Check all directories with a go.mod file
|
|
|
|
modules=("." "api" "sdk")
|
|
|
|
all_package_names=""
|
|
|
|
|
|
|
|
for dir in "${modules[@]}"
|
|
|
|
do
|
|
|
|
pushd "$dir"
|
2021-11-03 13:00:38 +00:00
|
|
|
# On its own line so that -e will fail the tests if we detect errors here.
|
|
|
|
go list -test -json ./... > test-list.json
|
2021-09-27 20:49:10 +00:00
|
|
|
# Split Go tests by prior test times. If use_docker is true, only run
|
|
|
|
# tests that depend on docker, otherwise only those that don't.
|
|
|
|
# The appended true condition ensures the command will succeed if no packages are found
|
|
|
|
if [ $USE_DOCKER == 1 ]; then
|
2021-11-03 13:00:38 +00:00
|
|
|
package_names=$(< test-list.json jq -r 'select(.Deps != null) |
|
2021-09-27 20:49:10 +00:00
|
|
|
select(any(.Deps[] ; contains("github.com/hashicorp/vault/helper/testhelpers/docker"))) |
|
|
|
|
.ForTest | select(. != null)' |
|
2021-11-05 14:41:29 +00:00
|
|
|
sort -u | grep -v vault/integ | circleci tests split --split-by=timings --timings-type=classname || true)
|
2021-09-27 20:49:10 +00:00
|
|
|
else
|
2021-11-05 14:41:29 +00:00
|
|
|
package_names=$(< test-list.json jq -r 'select(.Deps != null) |
|
2021-09-27 20:49:10 +00:00
|
|
|
select(all(.Deps[] ; contains("github.com/hashicorp/vault/helper/testhelpers/docker")|not)) |
|
|
|
|
.ForTest | select(. != null)' |
|
2021-11-05 14:41:29 +00:00
|
|
|
sort -u | grep -v vault/integ | circleci tests split --split-by=timings --timings-type=classname || true)
|
2021-09-27 20:49:10 +00:00
|
|
|
fi
|
|
|
|
# Move back into root directory
|
|
|
|
popd
|
|
|
|
# Append the test packages into the global list, if any are found
|
|
|
|
if [ -n "$package_names" ]; then
|
|
|
|
all_package_names+=" ${package_names}"
|
|
|
|
fi
|
|
|
|
done
|
2020-09-15 14:01:26 +00:00
|
|
|
|
|
|
|
# After running tests split step, we are now running the following steps
|
|
|
|
# in multiple different containers, each getting a different subset of
|
|
|
|
# the test packages in their package_names variable. Each container
|
|
|
|
# has its own remote docker VM.
|
|
|
|
|
|
|
|
make prep
|
|
|
|
mkdir -p test-results/go-test
|
|
|
|
|
2021-06-01 14:31:45 +00:00
|
|
|
# We don't want VAULT_LICENSE set when running Go tests, because that's
|
|
|
|
# not what developers have in their environments and it could break some
|
|
|
|
# tests; it would be like setting VAULT_TOKEN. However some non-Go
|
|
|
|
# CI commands, like the UI tests, shouldn't have to worry about licensing.
|
|
|
|
# So we set VAULT_LICENSE in CI, and here we unset it. Instead of
|
|
|
|
# VAULT_LICENSE, we populate VAULT_LICENSE_CI, so that tests which want
|
|
|
|
# an externally supplied license can opt-in to using it.
|
|
|
|
export VAULT_LICENSE_CI="$VAULT_LICENSE"
|
2021-06-01 12:40:38 +00:00
|
|
|
VAULT_LICENSE=
|
|
|
|
|
2020-09-15 14:01:26 +00:00
|
|
|
# Create a docker network for our testcontainer
|
|
|
|
if [ $USE_DOCKER == 1 ]; then
|
2020-09-17 19:24:31 +00:00
|
|
|
# Despite the fact that we're using a circleci image (thus getting the
|
|
|
|
# version they chose for the docker cli) and that we're specifying a
|
|
|
|
# docker version to use for the remote docker instances, we occasionally
|
|
|
|
# see "client version too new, max supported version 1.39" errors for
|
|
|
|
# reasons unclear.
|
|
|
|
export DOCKER_API_VERSION=1.39
|
|
|
|
|
2020-09-15 14:01:26 +00:00
|
|
|
export TEST_DOCKER_NETWORK_ID=$(docker network list -q -f 'name=vaulttest')
|
|
|
|
if [ -z $TEST_DOCKER_NETWORK_ID ]; then
|
|
|
|
TEST_DOCKER_NETWORK_ID=$(docker network create vaulttest)
|
|
|
|
fi
|
|
|
|
|
2021-06-28 15:07:00 +00:00
|
|
|
|
|
|
|
|
2020-09-15 14:01:26 +00:00
|
|
|
# Start a docker testcontainer to run the tests in
|
2021-06-28 15:07:00 +00:00
|
|
|
docker run -d \
|
|
|
|
-e TEST_DOCKER_NETWORK_ID \
|
|
|
|
-e GOPRIVATE \
|
|
|
|
-e DOCKER_CERT_PATH \
|
|
|
|
-e DOCKER_HOST \
|
|
|
|
-e DOCKER_MACHINE_NAME \
|
|
|
|
-e DOCKER_TLS_VERIFY \
|
|
|
|
-e NO_PROXY \
|
2020-09-15 14:01:26 +00:00
|
|
|
-e VAULT_TEST_LOG_DIR=/tmp/testlogs \
|
|
|
|
--network vaulttest --name \
|
2022-02-23 20:08:08 +00:00
|
|
|
testcontainer docker.mirror.hashicorp.services/cimg/go:1.17.7 \
|
2020-09-15 14:01:26 +00:00
|
|
|
tail -f /dev/null
|
|
|
|
|
|
|
|
# Run tests
|
2021-04-06 13:42:14 +00:00
|
|
|
test -d /tmp/go-cache && docker cp /tmp/go-cache testcontainer:/tmp/gocache
|
2021-12-14 16:11:13 +00:00
|
|
|
docker exec testcontainer sh -c 'mkdir -p /home/circleci/go/src/github.com/hashicorp/vault'
|
|
|
|
docker cp . testcontainer:/home/circleci/go/src/github.com/hashicorp/vault/
|
2020-09-15 14:01:26 +00:00
|
|
|
docker cp $DOCKER_CERT_PATH/ testcontainer:$DOCKER_CERT_PATH
|
|
|
|
|
2021-06-25 16:17:05 +00:00
|
|
|
# Copy the downloaded modules inside the container.
|
2021-12-14 16:11:13 +00:00
|
|
|
docker exec testcontainer sh -c 'mkdir -p /home/circleci/go/pkg'
|
|
|
|
docker cp "$(go env GOPATH)/pkg/mod" testcontainer:/home/circleci/go/pkg/mod
|
2021-06-25 16:17:05 +00:00
|
|
|
|
2021-12-14 16:11:13 +00:00
|
|
|
docker exec -w /home/circleci/go/src/github.com/hashicorp/vault/ \
|
2021-06-25 16:17:05 +00:00
|
|
|
-e CIRCLECI -e VAULT_CI_GO_TEST_RACE \
|
|
|
|
-e GOCACHE=/tmp/gocache \
|
2021-06-28 15:07:00 +00:00
|
|
|
-e GO_TAGS \
|
2021-06-25 16:17:05 +00:00
|
|
|
-e GOPROXY="off" \
|
2021-06-01 12:40:38 +00:00
|
|
|
-e VAULT_LICENSE_CI \
|
2021-06-28 15:07:00 +00:00
|
|
|
-e GOARCH=amd64 \
|
2020-09-15 14:01:26 +00:00
|
|
|
testcontainer \
|
2021-06-28 15:07:00 +00:00
|
|
|
gotestsum --format=short-verbose \
|
|
|
|
--junitfile test-results/go-test/results.xml \
|
|
|
|
--jsonfile test-results/go-test/results.json \
|
|
|
|
-- \
|
2021-06-11 17:18:37 +00:00
|
|
|
-tags "${GO_TAGS} ${EXTRA_TAGS}" \
|
2021-06-28 15:07:00 +00:00
|
|
|
-timeout=60m \
|
|
|
|
-parallel=20 \
|
|
|
|
\
|
2021-09-27 20:49:10 +00:00
|
|
|
${all_package_names}
|
2020-09-15 14:01:26 +00:00
|
|
|
else
|
2021-06-01 12:40:38 +00:00
|
|
|
GOARCH=amd64 \
|
|
|
|
GOCACHE=/tmp/go-cache \
|
2021-04-06 13:42:14 +00:00
|
|
|
gotestsum --format=short-verbose \
|
|
|
|
--junitfile test-results/go-test/results.xml \
|
|
|
|
--jsonfile test-results/go-test/results.json \
|
|
|
|
-- \
|
2021-06-11 17:18:37 +00:00
|
|
|
-tags "${GO_TAGS} ${EXTRA_TAGS}" \
|
2021-04-06 13:42:14 +00:00
|
|
|
-timeout=60m \
|
|
|
|
-parallel=20 \
|
|
|
|
\
|
2021-09-27 20:49:10 +00:00
|
|
|
${all_package_names}
|
2020-09-15 14:01:26 +00:00
|
|
|
fi
|
2021-06-28 15:07:00 +00:00
|
|
|
environment:
|
|
|
|
GOPRIVATE: github.com/hashicorp/*
|
2020-09-15 14:01:26 +00:00
|
|
|
name: Run Go tests
|
|
|
|
no_output_timeout: 60m
|
|
|
|
- run:
|
|
|
|
command: |
|
2021-12-14 16:11:13 +00:00
|
|
|
docker cp testcontainer:/home/circleci/go/src/github.com/hashicorp/vault/test-results .
|
2021-04-06 13:42:14 +00:00
|
|
|
docker cp testcontainer:/tmp/gocache /tmp/go-cache
|
2020-09-15 14:01:26 +00:00
|
|
|
name: Copy test results
|
|
|
|
when: always
|
|
|
|
- store_artifacts:
|
|
|
|
path: test-results
|
|
|
|
- store_test_results:
|
|
|
|
path: test-results
|
|
|
|
- store_artifacts:
|
2021-12-06 16:06:22 +00:00
|
|
|
path: /tmp/testlogs
|
|
|
|
environment:
|
|
|
|
- CIRCLECI_CLI_VERSION: 0.1.5546
|
|
|
|
- GO_TAGS: ''
|
2022-01-31 23:24:16 +00:00
|
|
|
fmt:
|
|
|
|
machine: true
|
|
|
|
shell: /usr/bin/env bash -euo pipefail -c
|
|
|
|
working_directory: /home/circleci/go/src/github.com/hashicorp/vault
|
|
|
|
steps:
|
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
[ -n "$GO_VERSION" ] || { echo "You must set GO_VERSION"; exit 1; }
|
|
|
|
# Install Go
|
|
|
|
curl -sSLO "https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz"
|
|
|
|
sudo rm -rf /usr/local/go
|
|
|
|
sudo tar -C /usr/local -xzf "go${GO_VERSION}.linux-amd64.tar.gz"
|
|
|
|
rm -f "go${GO_VERSION}.linux-amd64.tar.gz"
|
|
|
|
GOPATH="/home/circleci/go"
|
|
|
|
mkdir $GOPATH 2>/dev/null || { sudo mkdir $GOPATH && sudo chmod 777 $GOPATH; }
|
|
|
|
echo "export GOPATH='$GOPATH'" >> "$BASH_ENV"
|
|
|
|
echo "export PATH='$PATH:$GOPATH/bin:/usr/local/go/bin'" >> "$BASH_ENV"
|
|
|
|
echo "export GOPROXY=https://proxy.golang.org,direct" >> "$BASH_ENV"
|
|
|
|
echo "export GOPRIVATE=github.com/hashicorp/*" >> "$BASH_ENV"
|
|
|
|
|
|
|
|
echo "$ go version"
|
|
|
|
go version
|
|
|
|
name: Setup Go
|
|
|
|
working_directory: ~/
|
|
|
|
- checkout
|
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
go install "mvdan.cc/gofumpt@v${GOFUMPT_VERSION}"
|
|
|
|
make fmt
|
|
|
|
if ! git diff --exit-code; then
|
|
|
|
echo "Code has formatting errors. Run 'make fmt' to fix"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
name: make fmt
|
|
|
|
environment:
|
|
|
|
- CIRCLECI_CLI_VERSION: 0.1.5546
|
|
|
|
- GO_TAGS: ''
|
2022-02-23 20:08:08 +00:00
|
|
|
- GO_VERSION: 1.17.7
|
2022-01-31 23:24:16 +00:00
|
|
|
- GOFUMPT_VERSION: 0.2.1
|
|
|
|
- GOTESTSUM_VERSION: 0.5.2
|
2020-06-29 15:39:08 +00:00
|
|
|
test-go-race:
|
2020-09-15 14:01:26 +00:00
|
|
|
docker:
|
2022-02-23 20:08:08 +00:00
|
|
|
- image: docker.mirror.hashicorp.services/cimg/go:1.17.7
|
2020-09-15 14:01:26 +00:00
|
|
|
resource_class: xlarge
|
2021-12-14 16:11:13 +00:00
|
|
|
working_directory: /home/circleci/go/src/github.com/hashicorp/vault
|
2020-09-15 14:01:26 +00:00
|
|
|
parallelism: 8
|
2020-06-29 15:39:08 +00:00
|
|
|
steps:
|
2019-06-11 14:55:53 +00:00
|
|
|
- run:
|
|
|
|
command: |
|
2020-09-15 14:01:26 +00:00
|
|
|
# If the branch being tested starts with ui/ or docs/ we want to exit the job without failing
|
2022-01-11 14:02:47 +00:00
|
|
|
[[ "$CIRCLE_BRANCH" = ui/* || "$CIRCLE_BRANCH" = docs/* || "$CIRCLE_BRANCH" = backport/docs/* ]] && {
|
2020-09-15 14:01:26 +00:00
|
|
|
# stop the job from this step
|
|
|
|
circleci-agent step halt
|
|
|
|
}
|
|
|
|
# exit with success either way
|
|
|
|
exit 0
|
|
|
|
name: Check branch name
|
2019-11-06 13:15:06 +00:00
|
|
|
working_directory: ~/
|
|
|
|
- checkout
|
2021-06-28 15:07:00 +00:00
|
|
|
- add_ssh_keys:
|
|
|
|
fingerprints:
|
|
|
|
- 0e:03:77:f4:e2:c3:56:c2:53:6a:03:e1:31:91:2f:06
|
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
git config --global url."git@github.com:".insteadOf https://github.com/
|
2021-04-06 13:42:14 +00:00
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
TZ=GMT date '+%Y%m%d' > /tmp/go-cache-key
|
|
|
|
name: Compute test cache key
|
|
|
|
- restore_cache:
|
|
|
|
keys:
|
|
|
|
- go-test-cache-date-v1-{{ checksum "/tmp/go-cache-key" }}
|
2021-06-25 16:17:05 +00:00
|
|
|
- restore_cache:
|
|
|
|
keys:
|
2021-12-14 16:11:13 +00:00
|
|
|
- v1.4-{{checksum "go.sum"}}-{{checksum "sdk/go.sum"}}-{{checksum "api/go.sum"}}
|
2021-06-25 16:17:05 +00:00
|
|
|
name: Restore exact go modules cache
|
2019-11-06 13:15:06 +00:00
|
|
|
- run:
|
|
|
|
command: |
|
2021-11-03 13:00:38 +00:00
|
|
|
set -exo pipefail
|
2019-06-11 14:55:53 +00:00
|
|
|
|
2021-06-11 17:18:37 +00:00
|
|
|
EXTRA_TAGS=
|
2020-07-21 14:50:28 +00:00
|
|
|
case "-race" in
|
2020-09-15 14:01:26 +00:00
|
|
|
*-race*) export VAULT_CI_GO_TEST_RACE=1;;
|
2021-06-11 17:18:37 +00:00
|
|
|
*) EXTRA_TAGS=deadlock;;
|
2020-07-21 14:50:28 +00:00
|
|
|
esac
|
|
|
|
|
2019-06-11 14:55:53 +00:00
|
|
|
# Install CircleCI CLI
|
|
|
|
curl -sSL \
|
|
|
|
"https://github.com/CircleCI-Public/circleci-cli/releases/download/v${CIRCLECI_CLI_VERSION}/circleci-cli_${CIRCLECI_CLI_VERSION}_linux_amd64.tar.gz" \
|
|
|
|
| sudo tar --overwrite -xz \
|
|
|
|
-C /usr/local/bin \
|
|
|
|
"circleci-cli_${CIRCLECI_CLI_VERSION}_linux_amd64/circleci"
|
|
|
|
|
2020-09-15 14:01:26 +00:00
|
|
|
USE_DOCKER=0
|
2019-06-11 14:55:53 +00:00
|
|
|
|
2021-09-27 20:49:10 +00:00
|
|
|
# Check all directories with a go.mod file
|
|
|
|
modules=("." "api" "sdk")
|
|
|
|
all_package_names=""
|
|
|
|
|
|
|
|
for dir in "${modules[@]}"
|
|
|
|
do
|
|
|
|
pushd "$dir"
|
2021-11-03 13:00:38 +00:00
|
|
|
# On its own line so that -e will fail the tests if we detect errors here.
|
|
|
|
go list -test -json ./... > test-list.json
|
2021-09-27 20:49:10 +00:00
|
|
|
# Split Go tests by prior test times. If use_docker is true, only run
|
|
|
|
# tests that depend on docker, otherwise only those that don't.
|
|
|
|
# The appended true condition ensures the command will succeed if no packages are found
|
|
|
|
if [ $USE_DOCKER == 1 ]; then
|
2021-11-03 13:00:38 +00:00
|
|
|
package_names=$(< test-list.json jq -r 'select(.Deps != null) |
|
2021-09-27 20:49:10 +00:00
|
|
|
select(any(.Deps[] ; contains("github.com/hashicorp/vault/helper/testhelpers/docker"))) |
|
|
|
|
.ForTest | select(. != null)' |
|
2021-11-05 14:41:29 +00:00
|
|
|
sort -u | grep -v vault/integ | circleci tests split --split-by=timings --timings-type=classname || true)
|
2021-09-27 20:49:10 +00:00
|
|
|
else
|
2021-11-05 14:41:29 +00:00
|
|
|
package_names=$(< test-list.json jq -r 'select(.Deps != null) |
|
2021-09-27 20:49:10 +00:00
|
|
|
select(all(.Deps[] ; contains("github.com/hashicorp/vault/helper/testhelpers/docker")|not)) |
|
|
|
|
.ForTest | select(. != null)' |
|
2021-11-05 14:41:29 +00:00
|
|
|
sort -u | grep -v vault/integ | circleci tests split --split-by=timings --timings-type=classname || true)
|
2021-09-27 20:49:10 +00:00
|
|
|
fi
|
|
|
|
# Move back into root directory
|
|
|
|
popd
|
|
|
|
# Append the test packages into the global list, if any are found
|
|
|
|
if [ -n "$package_names" ]; then
|
|
|
|
all_package_names+=" ${package_names}"
|
|
|
|
fi
|
|
|
|
done
|
2020-09-15 14:01:26 +00:00
|
|
|
|
|
|
|
# After running tests split step, we are now running the following steps
|
|
|
|
# in multiple different containers, each getting a different subset of
|
|
|
|
# the test packages in their package_names variable. Each container
|
|
|
|
# has its own remote docker VM.
|
2019-06-11 14:55:53 +00:00
|
|
|
|
|
|
|
make prep
|
|
|
|
mkdir -p test-results/go-test
|
2020-09-15 14:01:26 +00:00
|
|
|
|
2021-06-01 14:31:45 +00:00
|
|
|
# We don't want VAULT_LICENSE set when running Go tests, because that's
|
|
|
|
# not what developers have in their environments and it could break some
|
|
|
|
# tests; it would be like setting VAULT_TOKEN. However some non-Go
|
|
|
|
# CI commands, like the UI tests, shouldn't have to worry about licensing.
|
|
|
|
# So we set VAULT_LICENSE in CI, and here we unset it. Instead of
|
|
|
|
# VAULT_LICENSE, we populate VAULT_LICENSE_CI, so that tests which want
|
|
|
|
# an externally supplied license can opt-in to using it.
|
|
|
|
export VAULT_LICENSE_CI="$VAULT_LICENSE"
|
2021-06-01 12:40:38 +00:00
|
|
|
VAULT_LICENSE=
|
|
|
|
|
2020-09-15 14:01:26 +00:00
|
|
|
# Create a docker network for our testcontainer
|
|
|
|
if [ $USE_DOCKER == 1 ]; then
|
2020-09-17 19:24:31 +00:00
|
|
|
# Despite the fact that we're using a circleci image (thus getting the
|
|
|
|
# version they chose for the docker cli) and that we're specifying a
|
|
|
|
# docker version to use for the remote docker instances, we occasionally
|
|
|
|
# see "client version too new, max supported version 1.39" errors for
|
|
|
|
# reasons unclear.
|
|
|
|
export DOCKER_API_VERSION=1.39
|
|
|
|
|
2020-09-15 14:01:26 +00:00
|
|
|
export TEST_DOCKER_NETWORK_ID=$(docker network list -q -f 'name=vaulttest')
|
|
|
|
if [ -z $TEST_DOCKER_NETWORK_ID ]; then
|
|
|
|
TEST_DOCKER_NETWORK_ID=$(docker network create vaulttest)
|
|
|
|
fi
|
|
|
|
|
2021-06-28 15:07:00 +00:00
|
|
|
|
|
|
|
|
2020-09-15 14:01:26 +00:00
|
|
|
# Start a docker testcontainer to run the tests in
|
2021-06-28 15:07:00 +00:00
|
|
|
docker run -d \
|
|
|
|
-e TEST_DOCKER_NETWORK_ID \
|
|
|
|
-e GOPRIVATE \
|
|
|
|
-e DOCKER_CERT_PATH \
|
|
|
|
-e DOCKER_HOST \
|
|
|
|
-e DOCKER_MACHINE_NAME \
|
|
|
|
-e DOCKER_TLS_VERIFY \
|
|
|
|
-e NO_PROXY \
|
2020-09-15 14:01:26 +00:00
|
|
|
-e VAULT_TEST_LOG_DIR=/tmp/testlogs \
|
|
|
|
--network vaulttest --name \
|
2022-02-23 20:08:08 +00:00
|
|
|
testcontainer docker.mirror.hashicorp.services/cimg/go:1.17.7 \
|
2020-09-15 14:01:26 +00:00
|
|
|
tail -f /dev/null
|
|
|
|
|
|
|
|
# Run tests
|
2021-04-06 13:42:14 +00:00
|
|
|
test -d /tmp/go-cache && docker cp /tmp/go-cache testcontainer:/tmp/gocache
|
2021-12-14 16:11:13 +00:00
|
|
|
docker exec testcontainer sh -c 'mkdir -p /home/circleci/go/src/github.com/hashicorp/vault'
|
|
|
|
docker cp . testcontainer:/home/circleci/go/src/github.com/hashicorp/vault/
|
2020-09-15 14:01:26 +00:00
|
|
|
docker cp $DOCKER_CERT_PATH/ testcontainer:$DOCKER_CERT_PATH
|
|
|
|
|
2021-06-25 16:17:05 +00:00
|
|
|
# Copy the downloaded modules inside the container.
|
2021-12-14 16:11:13 +00:00
|
|
|
docker exec testcontainer sh -c 'mkdir -p /home/circleci/go/pkg'
|
|
|
|
docker cp "$(go env GOPATH)/pkg/mod" testcontainer:/home/circleci/go/pkg/mod
|
2021-06-25 16:17:05 +00:00
|
|
|
|
2021-12-14 16:11:13 +00:00
|
|
|
docker exec -w /home/circleci/go/src/github.com/hashicorp/vault/ \
|
2021-06-25 16:17:05 +00:00
|
|
|
-e CIRCLECI -e VAULT_CI_GO_TEST_RACE \
|
|
|
|
-e GOCACHE=/tmp/gocache \
|
2021-06-28 15:07:00 +00:00
|
|
|
-e GO_TAGS \
|
2021-06-25 16:17:05 +00:00
|
|
|
-e GOPROXY="off" \
|
2021-06-01 12:40:38 +00:00
|
|
|
-e VAULT_LICENSE_CI \
|
2021-06-28 15:07:00 +00:00
|
|
|
-e GOARCH=amd64 \
|
2020-09-15 14:01:26 +00:00
|
|
|
testcontainer \
|
2021-06-28 15:07:00 +00:00
|
|
|
gotestsum --format=short-verbose \
|
|
|
|
--junitfile test-results/go-test/results.xml \
|
|
|
|
--jsonfile test-results/go-test/results.json \
|
|
|
|
-- \
|
2021-06-11 17:18:37 +00:00
|
|
|
-tags "${GO_TAGS} ${EXTRA_TAGS}" \
|
2021-06-28 15:07:00 +00:00
|
|
|
-timeout=60m \
|
|
|
|
-parallel=20 \
|
|
|
|
-race \
|
2021-09-27 20:49:10 +00:00
|
|
|
${all_package_names}
|
2020-09-15 14:01:26 +00:00
|
|
|
else
|
2021-06-01 12:40:38 +00:00
|
|
|
GOARCH=amd64 \
|
|
|
|
GOCACHE=/tmp/go-cache \
|
2021-04-06 13:42:14 +00:00
|
|
|
gotestsum --format=short-verbose \
|
|
|
|
--junitfile test-results/go-test/results.xml \
|
|
|
|
--jsonfile test-results/go-test/results.json \
|
|
|
|
-- \
|
2021-06-11 17:18:37 +00:00
|
|
|
-tags "${GO_TAGS} ${EXTRA_TAGS}" \
|
2021-04-06 13:42:14 +00:00
|
|
|
-timeout=60m \
|
|
|
|
-parallel=20 \
|
|
|
|
-race \
|
2021-09-27 20:49:10 +00:00
|
|
|
${all_package_names}
|
2020-09-15 14:01:26 +00:00
|
|
|
fi
|
2021-06-28 15:07:00 +00:00
|
|
|
environment:
|
|
|
|
GOPRIVATE: github.com/hashicorp/*
|
2019-06-11 14:55:53 +00:00
|
|
|
name: Run Go tests
|
2019-11-12 14:03:42 +00:00
|
|
|
no_output_timeout: 60m
|
2019-06-11 14:55:53 +00:00
|
|
|
- store_artifacts:
|
|
|
|
path: test-results
|
|
|
|
- store_test_results:
|
|
|
|
path: test-results
|
2020-05-01 16:26:26 +00:00
|
|
|
- store_artifacts:
|
|
|
|
path: /tmp/testlogs
|
2019-06-11 14:55:53 +00:00
|
|
|
environment:
|
|
|
|
- CIRCLECI_CLI_VERSION: 0.1.5546
|
2019-11-06 13:15:06 +00:00
|
|
|
- GO_TAGS: ''
|
2020-06-29 15:39:08 +00:00
|
|
|
website-docker-image:
|
|
|
|
docker:
|
|
|
|
- image: circleci/buildpack-deps
|
|
|
|
shell: /usr/bin/env bash -euo pipefail -c
|
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- setup_remote_docker
|
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
IMAGE_TAG="$(git rev-list -n1 HEAD -- website/Dockerfile website/package-lock.json)"
|
|
|
|
echo "Using $IMAGE_TAG"
|
|
|
|
if [ "$CIRCLE_REPOSITORY_URL" != "git@github.com:hashicorp/vault.git" ]; then
|
|
|
|
echo "Not Vault OSS Repo, not building website docker image"
|
|
|
|
elif curl https://hub.docker.com/v2/repositories/hashicorp/vault-website/tags/$IMAGE_TAG -fsL > /dev/null; then
|
|
|
|
echo "Dependencies have not changed, not building a new website docker image."
|
|
|
|
else
|
|
|
|
cd website/
|
|
|
|
docker build -t hashicorp/vault-website:$IMAGE_TAG .
|
|
|
|
docker tag hashicorp/vault-website:$IMAGE_TAG hashicorp/vault-website:latest
|
|
|
|
docker login -u $WEBSITE_DOCKER_USER -p $WEBSITE_DOCKER_PASS
|
|
|
|
docker push hashicorp/vault-website
|
|
|
|
fi
|
|
|
|
name: Build Docker Image if Necessary
|
|
|
|
test-go:
|
2020-09-15 14:01:26 +00:00
|
|
|
docker:
|
2022-02-23 20:08:08 +00:00
|
|
|
- image: docker.mirror.hashicorp.services/cimg/go:1.17.7
|
2020-12-03 15:57:21 +00:00
|
|
|
resource_class: large
|
2021-12-14 16:11:13 +00:00
|
|
|
working_directory: /home/circleci/go/src/github.com/hashicorp/vault
|
2020-09-15 14:01:26 +00:00
|
|
|
parallelism: 8
|
2019-05-03 23:05:10 +00:00
|
|
|
steps:
|
2020-06-29 15:39:08 +00:00
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
# If the branch being tested starts with ui/ or docs/ we want to exit the job without failing
|
2022-01-11 14:02:47 +00:00
|
|
|
[[ "$CIRCLE_BRANCH" = ui/* || "$CIRCLE_BRANCH" = docs/* || "$CIRCLE_BRANCH" = backport/docs/* ]] && {
|
2020-06-29 15:39:08 +00:00
|
|
|
# stop the job from this step
|
|
|
|
circleci-agent step halt
|
|
|
|
}
|
|
|
|
# exit with success either way
|
|
|
|
exit 0
|
|
|
|
name: Check branch name
|
|
|
|
working_directory: ~/
|
2019-11-06 13:15:06 +00:00
|
|
|
- checkout
|
2021-06-28 15:07:00 +00:00
|
|
|
- add_ssh_keys:
|
|
|
|
fingerprints:
|
|
|
|
- 0e:03:77:f4:e2:c3:56:c2:53:6a:03:e1:31:91:2f:06
|
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
git config --global url."git@github.com:".insteadOf https://github.com/
|
2021-04-06 13:42:14 +00:00
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
TZ=GMT date '+%Y%m%d' > /tmp/go-cache-key
|
|
|
|
name: Compute test cache key
|
|
|
|
- restore_cache:
|
|
|
|
keys:
|
|
|
|
- go-test-cache-date-v1-{{ checksum "/tmp/go-cache-key" }}
|
2021-06-25 16:17:05 +00:00
|
|
|
- restore_cache:
|
|
|
|
keys:
|
2021-12-14 16:11:13 +00:00
|
|
|
- v1.4-{{checksum "go.sum"}}-{{checksum "sdk/go.sum"}}-{{checksum "api/go.sum"}}
|
2021-06-25 16:17:05 +00:00
|
|
|
name: Restore exact go modules cache
|
2019-11-06 13:15:06 +00:00
|
|
|
- run:
|
|
|
|
command: |
|
2021-11-03 13:00:38 +00:00
|
|
|
set -exo pipefail
|
2019-05-03 23:05:10 +00:00
|
|
|
|
2021-06-11 17:18:37 +00:00
|
|
|
EXTRA_TAGS=
|
2020-07-21 14:50:28 +00:00
|
|
|
case "" in
|
2020-09-15 14:01:26 +00:00
|
|
|
*-race*) export VAULT_CI_GO_TEST_RACE=1;;
|
2021-06-11 17:18:37 +00:00
|
|
|
*) EXTRA_TAGS=deadlock;;
|
2020-07-21 14:50:28 +00:00
|
|
|
esac
|
|
|
|
|
2019-06-11 14:55:53 +00:00
|
|
|
# Install CircleCI CLI
|
|
|
|
curl -sSL \
|
|
|
|
"https://github.com/CircleCI-Public/circleci-cli/releases/download/v${CIRCLECI_CLI_VERSION}/circleci-cli_${CIRCLECI_CLI_VERSION}_linux_amd64.tar.gz" \
|
|
|
|
| sudo tar --overwrite -xz \
|
|
|
|
-C /usr/local/bin \
|
|
|
|
"circleci-cli_${CIRCLECI_CLI_VERSION}_linux_amd64/circleci"
|
|
|
|
|
2020-09-15 14:01:26 +00:00
|
|
|
USE_DOCKER=0
|
2019-06-11 14:55:53 +00:00
|
|
|
|
2021-09-27 20:49:10 +00:00
|
|
|
# Check all directories with a go.mod file
|
|
|
|
modules=("." "api" "sdk")
|
|
|
|
all_package_names=""
|
|
|
|
|
|
|
|
for dir in "${modules[@]}"
|
|
|
|
do
|
|
|
|
pushd "$dir"
|
2021-11-03 13:00:38 +00:00
|
|
|
# On its own line so that -e will fail the tests if we detect errors here.
|
|
|
|
go list -test -json ./... > test-list.json
|
2021-09-27 20:49:10 +00:00
|
|
|
# Split Go tests by prior test times. If use_docker is true, only run
|
|
|
|
# tests that depend on docker, otherwise only those that don't.
|
|
|
|
# The appended true condition ensures the command will succeed if no packages are found
|
|
|
|
if [ $USE_DOCKER == 1 ]; then
|
2021-11-03 13:00:38 +00:00
|
|
|
package_names=$(< test-list.json jq -r 'select(.Deps != null) |
|
2021-09-27 20:49:10 +00:00
|
|
|
select(any(.Deps[] ; contains("github.com/hashicorp/vault/helper/testhelpers/docker"))) |
|
|
|
|
.ForTest | select(. != null)' |
|
2021-11-05 14:41:29 +00:00
|
|
|
sort -u | grep -v vault/integ | circleci tests split --split-by=timings --timings-type=classname || true)
|
2021-09-27 20:49:10 +00:00
|
|
|
else
|
2021-11-05 14:41:29 +00:00
|
|
|
package_names=$(< test-list.json jq -r 'select(.Deps != null) |
|
2021-09-27 20:49:10 +00:00
|
|
|
select(all(.Deps[] ; contains("github.com/hashicorp/vault/helper/testhelpers/docker")|not)) |
|
|
|
|
.ForTest | select(. != null)' |
|
2021-11-05 14:41:29 +00:00
|
|
|
sort -u | grep -v vault/integ | circleci tests split --split-by=timings --timings-type=classname || true)
|
2021-09-27 20:49:10 +00:00
|
|
|
fi
|
|
|
|
# Move back into root directory
|
|
|
|
popd
|
|
|
|
# Append the test packages into the global list, if any are found
|
|
|
|
if [ -n "$package_names" ]; then
|
|
|
|
all_package_names+=" ${package_names}"
|
|
|
|
fi
|
|
|
|
done
|
2020-09-15 14:01:26 +00:00
|
|
|
|
|
|
|
# After running tests split step, we are now running the following steps
|
|
|
|
# in multiple different containers, each getting a different subset of
|
|
|
|
# the test packages in their package_names variable. Each container
|
|
|
|
# has its own remote docker VM.
|
2019-06-11 14:55:53 +00:00
|
|
|
|
|
|
|
make prep
|
|
|
|
mkdir -p test-results/go-test
|
2020-09-15 14:01:26 +00:00
|
|
|
|
2021-06-01 14:31:45 +00:00
|
|
|
# We don't want VAULT_LICENSE set when running Go tests, because that's
|
|
|
|
# not what developers have in their environments and it could break some
|
|
|
|
# tests; it would be like setting VAULT_TOKEN. However some non-Go
|
|
|
|
# CI commands, like the UI tests, shouldn't have to worry about licensing.
|
|
|
|
# So we set VAULT_LICENSE in CI, and here we unset it. Instead of
|
|
|
|
# VAULT_LICENSE, we populate VAULT_LICENSE_CI, so that tests which want
|
|
|
|
# an externally supplied license can opt-in to using it.
|
|
|
|
export VAULT_LICENSE_CI="$VAULT_LICENSE"
|
2021-06-01 12:40:38 +00:00
|
|
|
VAULT_LICENSE=
|
|
|
|
|
2020-09-15 14:01:26 +00:00
|
|
|
# Create a docker network for our testcontainer
|
|
|
|
if [ $USE_DOCKER == 1 ]; then
|
2020-09-17 19:24:31 +00:00
|
|
|
# Despite the fact that we're using a circleci image (thus getting the
|
|
|
|
# version they chose for the docker cli) and that we're specifying a
|
|
|
|
# docker version to use for the remote docker instances, we occasionally
|
|
|
|
# see "client version too new, max supported version 1.39" errors for
|
|
|
|
# reasons unclear.
|
|
|
|
export DOCKER_API_VERSION=1.39
|
|
|
|
|
2020-09-15 14:01:26 +00:00
|
|
|
export TEST_DOCKER_NETWORK_ID=$(docker network list -q -f 'name=vaulttest')
|
|
|
|
if [ -z $TEST_DOCKER_NETWORK_ID ]; then
|
|
|
|
TEST_DOCKER_NETWORK_ID=$(docker network create vaulttest)
|
|
|
|
fi
|
|
|
|
|
2021-06-28 15:07:00 +00:00
|
|
|
|
|
|
|
|
2020-09-15 14:01:26 +00:00
|
|
|
# Start a docker testcontainer to run the tests in
|
2021-06-28 15:07:00 +00:00
|
|
|
docker run -d \
|
|
|
|
-e TEST_DOCKER_NETWORK_ID \
|
|
|
|
-e GOPRIVATE \
|
|
|
|
-e DOCKER_CERT_PATH \
|
|
|
|
-e DOCKER_HOST \
|
|
|
|
-e DOCKER_MACHINE_NAME \
|
|
|
|
-e DOCKER_TLS_VERIFY \
|
|
|
|
-e NO_PROXY \
|
2020-09-15 14:01:26 +00:00
|
|
|
-e VAULT_TEST_LOG_DIR=/tmp/testlogs \
|
|
|
|
--network vaulttest --name \
|
2022-02-23 20:08:08 +00:00
|
|
|
testcontainer docker.mirror.hashicorp.services/cimg/go:1.17.7 \
|
2020-09-15 14:01:26 +00:00
|
|
|
tail -f /dev/null
|
|
|
|
|
|
|
|
# Run tests
|
2021-04-06 13:42:14 +00:00
|
|
|
test -d /tmp/go-cache && docker cp /tmp/go-cache testcontainer:/tmp/gocache
|
2021-12-14 16:11:13 +00:00
|
|
|
docker exec testcontainer sh -c 'mkdir -p /home/circleci/go/src/github.com/hashicorp/vault'
|
|
|
|
docker cp . testcontainer:/home/circleci/go/src/github.com/hashicorp/vault/
|
2020-09-15 14:01:26 +00:00
|
|
|
docker cp $DOCKER_CERT_PATH/ testcontainer:$DOCKER_CERT_PATH
|
|
|
|
|
2021-06-25 16:17:05 +00:00
|
|
|
# Copy the downloaded modules inside the container.
|
2021-12-14 16:11:13 +00:00
|
|
|
docker exec testcontainer sh -c 'mkdir -p /home/circleci/go/pkg'
|
|
|
|
docker cp "$(go env GOPATH)/pkg/mod" testcontainer:/home/circleci/go/pkg/mod
|
2021-06-25 16:17:05 +00:00
|
|
|
|
2021-12-14 16:11:13 +00:00
|
|
|
docker exec -w /home/circleci/go/src/github.com/hashicorp/vault/ \
|
2021-06-25 16:17:05 +00:00
|
|
|
-e CIRCLECI -e VAULT_CI_GO_TEST_RACE \
|
|
|
|
-e GOCACHE=/tmp/gocache \
|
2021-06-28 15:07:00 +00:00
|
|
|
-e GO_TAGS \
|
2021-06-25 16:17:05 +00:00
|
|
|
-e GOPROXY="off" \
|
2021-06-01 12:40:38 +00:00
|
|
|
-e VAULT_LICENSE_CI \
|
2021-06-28 15:07:00 +00:00
|
|
|
-e GOARCH=amd64 \
|
2020-09-15 14:01:26 +00:00
|
|
|
testcontainer \
|
2021-06-28 15:07:00 +00:00
|
|
|
gotestsum --format=short-verbose \
|
|
|
|
--junitfile test-results/go-test/results.xml \
|
|
|
|
--jsonfile test-results/go-test/results.json \
|
|
|
|
-- \
|
2021-06-11 17:18:37 +00:00
|
|
|
-tags "${GO_TAGS} ${EXTRA_TAGS}" \
|
2021-06-28 15:07:00 +00:00
|
|
|
-timeout=60m \
|
|
|
|
-parallel=20 \
|
|
|
|
\
|
2021-09-27 20:49:10 +00:00
|
|
|
${all_package_names}
|
2020-09-15 14:01:26 +00:00
|
|
|
else
|
2021-06-01 12:40:38 +00:00
|
|
|
GOARCH=amd64 \
|
|
|
|
GOCACHE=/tmp/go-cache \
|
2021-04-06 13:42:14 +00:00
|
|
|
gotestsum --format=short-verbose \
|
|
|
|
--junitfile test-results/go-test/results.xml \
|
|
|
|
--jsonfile test-results/go-test/results.json \
|
|
|
|
-- \
|
2021-06-11 17:18:37 +00:00
|
|
|
-tags "${GO_TAGS} ${EXTRA_TAGS}" \
|
2021-04-06 13:42:14 +00:00
|
|
|
-timeout=60m \
|
|
|
|
-parallel=20 \
|
|
|
|
\
|
2021-09-27 20:49:10 +00:00
|
|
|
${all_package_names}
|
2020-09-15 14:01:26 +00:00
|
|
|
fi
|
2021-06-28 15:07:00 +00:00
|
|
|
environment:
|
|
|
|
GOPRIVATE: github.com/hashicorp/*
|
2019-06-11 14:55:53 +00:00
|
|
|
name: Run Go tests
|
2019-11-12 14:03:42 +00:00
|
|
|
no_output_timeout: 60m
|
2019-06-11 14:55:53 +00:00
|
|
|
- store_artifacts:
|
|
|
|
path: test-results
|
|
|
|
- store_test_results:
|
|
|
|
path: test-results
|
2020-05-01 16:26:26 +00:00
|
|
|
- store_artifacts:
|
|
|
|
path: /tmp/testlogs
|
2019-06-11 14:55:53 +00:00
|
|
|
environment:
|
|
|
|
- CIRCLECI_CLI_VERSION: 0.1.5546
|
2019-11-06 13:15:06 +00:00
|
|
|
- GO_TAGS: ''
|
2020-06-29 15:39:08 +00:00
|
|
|
pre-flight-checks:
|
2021-06-25 16:17:05 +00:00
|
|
|
machine: true
|
|
|
|
shell: /usr/bin/env bash -euo pipefail -c
|
2021-12-14 16:11:13 +00:00
|
|
|
working_directory: /home/circleci/go/src/github.com/hashicorp/vault
|
2020-01-18 00:18:09 +00:00
|
|
|
steps:
|
2021-06-25 16:17:05 +00:00
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
[ -n "$GO_VERSION" ] || { echo "You must set GO_VERSION"; exit 1; }
|
|
|
|
# Install Go
|
|
|
|
curl -sSLO "https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz"
|
|
|
|
sudo rm -rf /usr/local/go
|
|
|
|
sudo tar -C /usr/local -xzf "go${GO_VERSION}.linux-amd64.tar.gz"
|
|
|
|
rm -f "go${GO_VERSION}.linux-amd64.tar.gz"
|
2021-12-14 16:11:13 +00:00
|
|
|
GOPATH="/home/circleci/go"
|
2021-06-25 16:17:05 +00:00
|
|
|
mkdir $GOPATH 2>/dev/null || { sudo mkdir $GOPATH && sudo chmod 777 $GOPATH; }
|
|
|
|
echo "export GOPATH='$GOPATH'" >> "$BASH_ENV"
|
|
|
|
echo "export PATH='$PATH:$GOPATH/bin:/usr/local/go/bin'" >> "$BASH_ENV"
|
|
|
|
echo "export GOPROXY=https://proxy.golang.org,direct" >> "$BASH_ENV"
|
|
|
|
echo "export GOPRIVATE=github.com/hashicorp/*" >> "$BASH_ENV"
|
|
|
|
|
|
|
|
echo "$ go version"
|
|
|
|
go version
|
|
|
|
name: Setup Go
|
|
|
|
working_directory: ~/
|
2020-01-18 00:18:09 +00:00
|
|
|
- checkout
|
|
|
|
- run:
|
|
|
|
command: |
|
2021-06-25 16:17:05 +00:00
|
|
|
export CCI_PATH=/tmp/circleci-cli/$CIRCLECI_CLI_VERSION
|
2020-06-29 15:39:08 +00:00
|
|
|
mkdir -p $CCI_PATH
|
2021-06-25 16:17:05 +00:00
|
|
|
NAME=circleci-cli_${CIRCLECI_CLI_VERSION}_${ARCH}
|
|
|
|
URL=$BASE/v${CIRCLECI_CLI_VERSION}/${NAME}.tar.gz
|
2020-06-29 15:39:08 +00:00
|
|
|
curl -sSL $URL \
|
|
|
|
| tar --overwrite --strip-components=1 -xz -C $CCI_PATH "${NAME}/circleci"
|
|
|
|
# Add circleci to the path for subsequent steps.
|
|
|
|
echo "export PATH=$CCI_PATH:\$PATH" >> $BASH_ENV
|
|
|
|
# Done, print some debug info.
|
|
|
|
set -x
|
|
|
|
. $BASH_ENV
|
|
|
|
which circleci
|
|
|
|
circleci version
|
|
|
|
environment:
|
|
|
|
ARCH: linux_amd64
|
|
|
|
BASE: https://github.com/CircleCI-Public/circleci-cli/releases/download
|
|
|
|
name: Install CircleCI CLI
|
|
|
|
- run:
|
|
|
|
command: make ci-verify
|
2021-06-25 16:17:05 +00:00
|
|
|
- add_ssh_keys:
|
|
|
|
fingerprints:
|
|
|
|
- 0e:03:77:f4:e2:c3:56:c2:53:6a:03:e1:31:91:2f:06
|
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
git config --global url."git@github.com:".insteadOf https://github.com/
|
|
|
|
- restore_cache:
|
|
|
|
keys:
|
2021-12-14 16:11:13 +00:00
|
|
|
- v1.4-{{checksum "go.sum"}}-{{checksum "sdk/go.sum"}}-{{checksum "api/go.sum"}}
|
|
|
|
- v1.4-{{checksum "go.sum"}}-{{checksum "sdk/go.sum"}}
|
|
|
|
- v1.4-{{checksum "go.sum"}}
|
2021-06-25 16:17:05 +00:00
|
|
|
name: Restore closest matching go modules cache
|
|
|
|
- run:
|
|
|
|
command: |
|
2021-07-06 13:24:10 +00:00
|
|
|
# go list ./... forces downloading some additional versions of modules that 'go mod
|
|
|
|
# download' misses. We need this because we make use of go list itself during
|
|
|
|
# code generation in later builds that rely on this module cache.
|
|
|
|
go list ./...
|
2021-06-25 16:17:05 +00:00
|
|
|
go mod download -json
|
|
|
|
( cd sdk && go mod download -json; )
|
|
|
|
( cd api && go mod download -json; )
|
|
|
|
name: go mod download
|
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
git --no-pager diff --exit-code || {
|
|
|
|
echo "ERROR: Files modified by go mod download, see above."
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
name: Verify downloading modules did not modify any files
|
|
|
|
- save_cache:
|
2021-12-14 16:11:13 +00:00
|
|
|
key: v1.4-{{checksum "go.sum"}}-{{checksum "sdk/go.sum"}}-{{checksum "api/go.sum"}}
|
2021-06-25 16:17:05 +00:00
|
|
|
name: Save go modules cache
|
|
|
|
paths:
|
2021-12-14 16:11:13 +00:00
|
|
|
- /home/circleci/go/pkg/mod
|
2021-06-25 16:17:05 +00:00
|
|
|
environment:
|
|
|
|
- CIRCLECI_CLI_VERSION: 0.1.5546
|
|
|
|
- GO_TAGS: ''
|
2022-02-23 20:08:08 +00:00
|
|
|
- GO_VERSION: 1.17.7
|
2022-01-31 23:24:16 +00:00
|
|
|
- GOFUMPT_VERSION: 0.2.1
|
2021-06-25 16:17:05 +00:00
|
|
|
- GOTESTSUM_VERSION: 0.5.2
|
2020-09-15 14:01:26 +00:00
|
|
|
test-go-race-remote-docker:
|
|
|
|
docker:
|
2022-02-23 20:08:08 +00:00
|
|
|
- image: docker.mirror.hashicorp.services/cimg/go:1.17.7
|
2020-12-03 15:57:21 +00:00
|
|
|
resource_class: medium
|
2021-12-14 16:11:13 +00:00
|
|
|
working_directory: /home/circleci/go/src/github.com/hashicorp/vault
|
2020-09-15 14:01:26 +00:00
|
|
|
parallelism: 8
|
|
|
|
steps:
|
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
# If the branch being tested starts with ui/ or docs/ we want to exit the job without failing
|
2022-01-11 14:02:47 +00:00
|
|
|
[[ "$CIRCLE_BRANCH" = ui/* || "$CIRCLE_BRANCH" = docs/* || "$CIRCLE_BRANCH" = backport/docs/* ]] && {
|
2020-09-15 14:01:26 +00:00
|
|
|
# stop the job from this step
|
|
|
|
circleci-agent step halt
|
|
|
|
}
|
|
|
|
# exit with success either way
|
|
|
|
exit 0
|
|
|
|
name: Check branch name
|
|
|
|
working_directory: ~/
|
|
|
|
- checkout
|
|
|
|
- setup_remote_docker:
|
|
|
|
docker_layer_caching: true
|
|
|
|
version: 18.09.3
|
2021-06-28 15:07:00 +00:00
|
|
|
- add_ssh_keys:
|
|
|
|
fingerprints:
|
|
|
|
- 0e:03:77:f4:e2:c3:56:c2:53:6a:03:e1:31:91:2f:06
|
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
git config --global url."git@github.com:".insteadOf https://github.com/
|
2021-04-06 13:42:14 +00:00
|
|
|
- run:
|
|
|
|
command: |
|
|
|
|
TZ=GMT date '+%Y%m%d' > /tmp/go-cache-key
|
|
|
|
name: Compute test cache key
|
|
|
|
- restore_cache:
|
|
|
|
keys:
|
|
|
|
- go-test-cache-date-v1-{{ checksum "/tmp/go-cache-key" }}
|
2021-06-25 16:17:05 +00:00
|
|
|
- restore_cache:
|
|
|
|
keys:
|
2021-12-14 16:11:13 +00:00
|
|
|
- v1.4-{{checksum "go.sum"}}-{{checksum "sdk/go.sum"}}-{{checksum "api/go.sum"}}
|
2021-06-25 16:17:05 +00:00
|
|
|
name: Restore exact go modules cache
|
2020-09-15 14:01:26 +00:00
|
|
|
- run:
|
|
|
|
command: |
|
2021-11-03 13:00:38 +00:00
|
|
|
set -exo pipefail
|
2020-09-15 14:01:26 +00:00
|
|
|
|
2021-06-11 17:18:37 +00:00
|
|
|
EXTRA_TAGS=
|
2020-09-15 14:01:26 +00:00
|
|
|
case "-race" in
|
|
|
|
*-race*) export VAULT_CI_GO_TEST_RACE=1;;
|
2021-06-11 17:18:37 +00:00
|
|
|
*) EXTRA_TAGS=deadlock;;
|
2020-09-15 14:01:26 +00:00
|
|
|
esac
|
|
|
|
|
|
|
|
# Install CircleCI CLI
|
|
|
|
curl -sSL \
|
|
|
|
"https://github.com/CircleCI-Public/circleci-cli/releases/download/v${CIRCLECI_CLI_VERSION}/circleci-cli_${CIRCLECI_CLI_VERSION}_linux_amd64.tar.gz" \
|
|
|
|
| sudo tar --overwrite -xz \
|
|
|
|
-C /usr/local/bin \
|
|
|
|
"circleci-cli_${CIRCLECI_CLI_VERSION}_linux_amd64/circleci"
|
|
|
|
|
|
|
|
USE_DOCKER=0
|
|
|
|
USE_DOCKER=1
|
|
|
|
|
2021-09-27 20:49:10 +00:00
|
|
|
# Check all directories with a go.mod file
|
|
|
|
modules=("." "api" "sdk")
|
|
|
|
all_package_names=""
|
|
|
|
|
|
|
|
for dir in "${modules[@]}"
|
|
|
|
do
|
|
|
|
pushd "$dir"
|
2021-11-03 13:00:38 +00:00
|
|
|
# On its own line so that -e will fail the tests if we detect errors here.
|
|
|
|
go list -test -json ./... > test-list.json
|
2021-09-27 20:49:10 +00:00
|
|
|
# Split Go tests by prior test times. If use_docker is true, only run
|
|
|
|
# tests that depend on docker, otherwise only those that don't.
|
|
|
|
# The appended true condition ensures the command will succeed if no packages are found
|
|
|
|
if [ $USE_DOCKER == 1 ]; then
|
2021-11-03 13:00:38 +00:00
|
|
|
package_names=$(< test-list.json jq -r 'select(.Deps != null) |
|
2021-09-27 20:49:10 +00:00
|
|
|
select(any(.Deps[] ; contains("github.com/hashicorp/vault/helper/testhelpers/docker"))) |
|
|
|
|
.ForTest | select(. != null)' |
|
2021-11-05 14:41:29 +00:00
|
|
|
sort -u | grep -v vault/integ | circleci tests split --split-by=timings --timings-type=classname || true)
|
2021-09-27 20:49:10 +00:00
|
|
|
else
|
2021-11-05 14:41:29 +00:00
|
|
|
package_names=$(< test-list.json jq -r 'select(.Deps != null) |
|
2021-09-27 20:49:10 +00:00
|
|
|
select(all(.Deps[] ; contains("github.com/hashicorp/vault/helper/testhelpers/docker")|not)) |
|
|
|
|
.ForTest | select(. != null)' |
|
2021-11-05 14:41:29 +00:00
|
|
|
sort -u | grep -v vault/integ | circleci tests split --split-by=timings --timings-type=classname || true)
|
2021-09-27 20:49:10 +00:00
|
|
|
fi
|
|
|
|
# Move back into root directory
|
|
|
|
popd
|
|
|
|
# Append the test packages into the global list, if any are found
|
|
|
|
if [ -n "$package_names" ]; then
|
|
|
|
all_package_names+=" ${package_names}"
|
|
|
|
fi
|
|
|
|
done
|
2020-09-15 14:01:26 +00:00
|
|
|
|
|
|
|
# After running tests split step, we are now running the following steps
|
|
|
|
# in multiple different containers, each getting a different subset of
|
|
|
|
# the test packages in their package_names variable. Each container
|
|
|
|
# has its own remote docker VM.
|
|
|
|
|
|
|
|
make prep
|
|
|
|
mkdir -p test-results/go-test
|
|
|
|
|
2021-06-01 14:31:45 +00:00
|
|
|
# We don't want VAULT_LICENSE set when running Go tests, because that's
|
|
|
|
# not what developers have in their environments and it could break some
|
|
|
|
# tests; it would be like setting VAULT_TOKEN. However some non-Go
|
|
|
|
# CI commands, like the UI tests, shouldn't have to worry about licensing.
|
|
|
|
# So we set VAULT_LICENSE in CI, and here we unset it. Instead of
|
|
|
|
# VAULT_LICENSE, we populate VAULT_LICENSE_CI, so that tests which want
|
|
|
|
# an externally supplied license can opt-in to using it.
|
|
|
|
export VAULT_LICENSE_CI="$VAULT_LICENSE"
|
2021-06-01 12:40:38 +00:00
|
|
|
VAULT_LICENSE=
|
|
|
|
|
2020-09-15 14:01:26 +00:00
|
|
|
# Create a docker network for our testcontainer
|
|
|
|
if [ $USE_DOCKER == 1 ]; then
|
2020-09-17 19:24:31 +00:00
|
|
|
# Despite the fact that we're using a circleci image (thus getting the
|
|
|
|
# version they chose for the docker cli) and that we're specifying a
|
|
|
|
# docker version to use for the remote docker instances, we occasionally
|
|
|
|
# see "client version too new, max supported version 1.39" errors for
|
|
|
|
# reasons unclear.
|
|
|
|
export DOCKER_API_VERSION=1.39
|
|
|
|
|
2020-09-15 14:01:26 +00:00
|
|
|
export TEST_DOCKER_NETWORK_ID=$(docker network list -q -f 'name=vaulttest')
|
|
|
|
if [ -z $TEST_DOCKER_NETWORK_ID ]; then
|
|
|
|
TEST_DOCKER_NETWORK_ID=$(docker network create vaulttest)
|
|
|
|
fi
|
|
|
|
|
2021-06-28 15:07:00 +00:00
|
|
|
|
|
|
|
|
2020-09-15 14:01:26 +00:00
|
|
|
# Start a docker testcontainer to run the tests in
|
2021-06-28 15:07:00 +00:00
|
|
|
docker run -d \
|
|
|
|
-e TEST_DOCKER_NETWORK_ID \
|
|
|
|
-e GOPRIVATE \
|
|
|
|
-e DOCKER_CERT_PATH \
|
|
|
|
-e DOCKER_HOST \
|
|
|
|
-e DOCKER_MACHINE_NAME \
|
|
|
|
-e DOCKER_TLS_VERIFY \
|
|
|
|
-e NO_PROXY \
|
2020-09-15 14:01:26 +00:00
|
|
|
-e VAULT_TEST_LOG_DIR=/tmp/testlogs \
|
|
|
|
--network vaulttest --name \
|
2022-02-23 20:08:08 +00:00
|
|
|
testcontainer docker.mirror.hashicorp.services/cimg/go:1.17.7 \
|
2020-09-15 14:01:26 +00:00
|
|
|
tail -f /dev/null
|
|
|
|
|
|
|
|
# Run tests
|
2021-04-06 13:42:14 +00:00
|
|
|
test -d /tmp/go-cache && docker cp /tmp/go-cache testcontainer:/tmp/gocache
|
2021-12-14 16:11:13 +00:00
|
|
|
docker exec testcontainer sh -c 'mkdir -p /home/circleci/go/src/github.com/hashicorp/vault'
|
|
|
|
docker cp . testcontainer:/home/circleci/go/src/github.com/hashicorp/vault/
|
2020-09-15 14:01:26 +00:00
|
|
|
docker cp $DOCKER_CERT_PATH/ testcontainer:$DOCKER_CERT_PATH
|
|
|
|
|
2021-06-25 16:17:05 +00:00
|
|
|
# Copy the downloaded modules inside the container.
|
2021-12-14 16:11:13 +00:00
|
|
|
docker exec testcontainer sh -c 'mkdir -p /home/circleci/go/pkg'
|
|
|
|
docker cp "$(go env GOPATH)/pkg/mod" testcontainer:/home/circleci/go/pkg/mod
|
2021-06-25 16:17:05 +00:00
|
|
|
|
2021-12-14 16:11:13 +00:00
|
|
|
docker exec -w /home/circleci/go/src/github.com/hashicorp/vault/ \
|
2021-06-25 16:17:05 +00:00
|
|
|
-e CIRCLECI -e VAULT_CI_GO_TEST_RACE \
|
|
|
|
-e GOCACHE=/tmp/gocache \
|
2021-06-28 15:07:00 +00:00
|
|
|
-e GO_TAGS \
|
2021-06-25 16:17:05 +00:00
|
|
|
-e GOPROXY="off" \
|
2021-06-01 12:40:38 +00:00
|
|
|
-e VAULT_LICENSE_CI \
|
2021-06-28 15:07:00 +00:00
|
|
|
-e GOARCH=amd64 \
|
2020-09-15 14:01:26 +00:00
|
|
|
testcontainer \
|
2021-06-28 15:07:00 +00:00
|
|
|
gotestsum --format=short-verbose \
|
|
|
|
--junitfile test-results/go-test/results.xml \
|
|
|
|
--jsonfile test-results/go-test/results.json \
|
|
|
|
-- \
|
2021-06-11 17:18:37 +00:00
|
|
|
-tags "${GO_TAGS} ${EXTRA_TAGS}" \
|
2021-06-28 15:07:00 +00:00
|
|
|
-timeout=60m \
|
|
|
|
-parallel=20 \
|
|
|
|
-race \
|
2021-09-27 20:49:10 +00:00
|
|
|
${all_package_names}
|
2020-09-15 14:01:26 +00:00
|
|
|
else
|
2021-06-01 12:40:38 +00:00
|
|
|
GOARCH=amd64 \
|
|
|
|
GOCACHE=/tmp/go-cache \
|
2021-04-06 13:42:14 +00:00
|
|
|
gotestsum --format=short-verbose \
|
|
|
|
--junitfile test-results/go-test/results.xml \
|
|
|
|
--jsonfile test-results/go-test/results.json \
|
|
|
|
-- \
|
2021-06-11 17:18:37 +00:00
|
|
|
-tags "${GO_TAGS} ${EXTRA_TAGS}" \
|
2021-04-06 13:42:14 +00:00
|
|
|
-timeout=60m \
|
|
|
|
-parallel=20 \
|
|
|
|
-race \
|
2021-09-27 20:49:10 +00:00
|
|
|
${all_package_names}
|
2020-09-15 14:01:26 +00:00
|
|
|
fi
|
2021-06-28 15:07:00 +00:00
|
|
|
environment:
|
|
|
|
GOPRIVATE: github.com/hashicorp/*
|
2020-09-15 14:01:26 +00:00
|
|
|
name: Run Go tests
|
|
|
|
no_output_timeout: 60m
|
|
|
|
- run:
|
|
|
|
command: |
|
2021-12-14 16:11:13 +00:00
|
|
|
docker cp testcontainer:/home/circleci/go/src/github.com/hashicorp/vault/test-results .
|
2021-04-06 13:42:14 +00:00
|
|
|
docker cp testcontainer:/tmp/gocache /tmp/go-cache
|
2020-09-15 14:01:26 +00:00
|
|
|
name: Copy test results
|
|
|
|
when: always
|
|
|
|
- store_artifacts:
|
|
|
|
path: test-results
|
|
|
|
- store_test_results:
|
|
|
|
path: test-results
|
|
|
|
- store_artifacts:
|
|
|
|
path: /tmp/testlogs
|
|
|
|
environment:
|
|
|
|
- CIRCLECI_CLI_VERSION: 0.1.5546
|
|
|
|
- GO_TAGS: ''
|
2019-06-11 14:55:53 +00:00
|
|
|
workflows:
|
2019-05-03 23:05:10 +00:00
|
|
|
ci:
|
|
|
|
jobs:
|
2019-06-26 14:14:23 +00:00
|
|
|
- pre-flight-checks
|
2022-01-31 23:24:16 +00:00
|
|
|
- fmt
|
2019-06-26 14:14:23 +00:00
|
|
|
- install-ui-dependencies:
|
|
|
|
requires:
|
|
|
|
- pre-flight-checks
|
2019-06-11 14:55:53 +00:00
|
|
|
- build-go-dev:
|
|
|
|
requires:
|
2019-11-06 13:15:06 +00:00
|
|
|
- pre-flight-checks
|
2019-06-11 14:55:53 +00:00
|
|
|
- test-ui:
|
|
|
|
requires:
|
|
|
|
- install-ui-dependencies
|
|
|
|
- build-go-dev
|
2019-07-24 13:13:41 +00:00
|
|
|
- test-ui-browserstack:
|
2019-07-25 10:35:12 +00:00
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
ignore: /pull\/[0-9]+/
|
2019-07-24 13:13:41 +00:00
|
|
|
requires:
|
|
|
|
- install-ui-dependencies
|
|
|
|
- build-go-dev
|
2019-06-11 14:55:53 +00:00
|
|
|
- test-go:
|
|
|
|
requires:
|
2020-09-15 14:01:26 +00:00
|
|
|
- pre-flight-checks
|
|
|
|
- test-go-remote-docker:
|
|
|
|
requires:
|
|
|
|
- pre-flight-checks
|
2019-06-11 14:55:53 +00:00
|
|
|
- test-go-race:
|
|
|
|
requires:
|
2020-09-15 14:01:26 +00:00
|
|
|
- pre-flight-checks
|
|
|
|
- test-go-race-remote-docker:
|
|
|
|
requires:
|
|
|
|
- pre-flight-checks
|
2020-02-03 17:04:33 +00:00
|
|
|
- website-docker-image:
|
2020-03-06 18:50:38 +00:00
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
only:
|
2021-06-18 18:24:54 +00:00
|
|
|
- main
|
2020-02-03 17:04:33 +00:00
|
|
|
context: vault-docs
|
2020-06-29 15:39:08 +00:00
|
|
|
- algolia-index:
|
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
only:
|
|
|
|
- stable-website
|
|
|
|
context: vault-docs
|
2019-06-11 14:55:53 +00:00
|
|
|
version: 2
|