@@ -23,15 +23,28 @@ workflows:
2323 - node8
2424 - node10
2525 filters : *all_commits
26- - publish_npm :
26+ - system_tests :
27+ requires :
28+ - lint
29+ - docs
30+ filters : &master_and_releases
31+ branches :
32+ only : master
33+ tags : &releases
34+ only : ' /^v[\d.]+$/'
35+ - sample_tests :
2736 requires :
2837 - lint
2938 - docs
39+ filters : *master_and_releases
40+ - publish_npm :
41+ requires :
42+ - system_tests
43+ - sample_tests
3044 filters :
3145 branches :
3246 ignore : /.*/
33- tags :
34- only : ' /^v[\d.]+$/'
47+ tags : *releases
3548 nightly :
3649 triggers :
3750 - schedule :
@@ -46,17 +59,17 @@ jobs:
4659 - image : ' node:6'
4760 user : node
4861 steps : &unit_tests_steps
49- - checkout
62+ - checkout
5063 - run : &npm_install_and_link
5164 name : Install and link the module
5265 command : |-
5366 mkdir -p /home/node/.npm-global
54- npm install
67+ ./.circleci/ npm- install-retry.js
5568 environment :
5669 NPM_CONFIG_PREFIX : /home/node/.npm-global
5770 - run : npm test
5871 - run : node_modules/.bin/codecov
59-
72+
6073 node8 :
6174 docker :
6275 - image : ' node:8'
@@ -74,12 +87,12 @@ jobs:
7487 steps :
7588 - checkout
7689 - run : *npm_install_and_link
77- - run :
90+ - run : &samples_npm_install_and_link
7891 name : Link the module being tested to the samples.
7992 command : |
8093 cd samples/
81- npm install
8294 npm link ../
95+ ./../.circleci/npm-install-retry.js
8396 environment :
8497 NPM_CONFIG_PREFIX : /home/node/.npm-global
8598 - run :
@@ -94,14 +107,71 @@ jobs:
94107 steps :
95108 - checkout
96109 - run : *npm_install_and_link
110+ - run : npm run docs
111+ sample_tests :
112+ docker :
113+ - image : ' node:8'
114+ user : node
115+ steps :
116+ - checkout
97117 - run :
98- name : Build documentation.
99- command : npm run docs
118+ name : Decrypt credentials.
119+ command : |
120+ if ! [[ -z "${SYSTEM_TESTS_ENCRYPTION_KEY}" ]]; then
121+ openssl aes-256-cbc -d -in .circleci/key.json.enc \
122+ -out .circleci/key.json \
123+ -k "${SYSTEM_TESTS_ENCRYPTION_KEY}"
124+ fi
125+ - run : *npm_install_and_link
126+ - run : *samples_npm_install_and_link
127+ - run :
128+ name : Run sample tests.
129+ command : npm run samples-test
130+ environment :
131+ GCLOUD_PROJECT : long-door-651
132+ GOOGLE_APPLICATION_CREDENTIALS : /home/node/samples/.circleci/key.json
133+ NPM_CONFIG_PREFIX : /home/node/.npm-global
134+ - run :
135+ name : Remove unencrypted key.
136+ command : |
137+ if ! [[ -z "${SYSTEM_TESTS_ENCRYPTION_KEY}" ]]; then
138+ rm .circleci/key.json
139+ fi
140+ when : always
141+ working_directory : /home/node/samples/
142+ system_tests :
143+ docker :
144+ - image : ' node:8'
145+ user : node
146+ steps :
147+ - checkout
148+ - run :
149+ name : Decrypt credentials.
150+ command : |
151+ if ! [[ -z "${SYSTEM_TESTS_ENCRYPTION_KEY}" ]]; then
152+ openssl aes-256-cbc -d -in .circleci/key.json.enc \
153+ -out .circleci/key.json \
154+ -k "${SYSTEM_TESTS_ENCRYPTION_KEY}"
155+ fi
156+ - run : *npm_install_and_link
157+ - run :
158+ name : Run system tests.
159+ command : npm run system-test
160+ environment :
161+ GOOGLE_APPLICATION_CREDENTIALS : .circleci/key.json
162+ - run :
163+ name : Remove unencrypted key.
164+ command : |
165+ if ! [[ -z "${SYSTEM_TESTS_ENCRYPTION_KEY}" ]]; then
166+ rm .circleci/key.json
167+ fi
168+ when : always
100169 publish_npm :
101170 docker :
102171 - image : ' node:8'
103172 user : node
104173 steps :
105174 - checkout
106- - run : ' echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc'
175+ - run : ./.circleci/npm-install-retry.js
176+ - run : echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
107177 - run : npm publish --access=public
0 commit comments