|
| 1 | +--- |
| 2 | +# "Include" for unit tests definition. |
| 3 | +unit_tests: &unit_tests |
| 4 | + steps: |
| 5 | + - checkout |
| 6 | + - run: |
| 7 | + name: Install modules and dependencies. |
| 8 | + command: npm install |
| 9 | + - run: |
| 10 | + name: Run unit tests. |
| 11 | + command: npm test |
| 12 | + - run: |
| 13 | + name: Submit coverage data to codecov. |
| 14 | + command: node_modules/.bin/codecov |
| 15 | + when: always |
| 16 | + |
| 17 | +version: 2.0 |
| 18 | +workflows: |
| 19 | + version: 2 |
| 20 | + tests: |
| 21 | + jobs: |
| 22 | + - node4: |
| 23 | + filters: |
| 24 | + tags: |
| 25 | + only: /.*/ |
| 26 | + - node6: |
| 27 | + filters: |
| 28 | + tags: |
| 29 | + only: /.*/ |
| 30 | + - node7: |
| 31 | + filters: |
| 32 | + tags: |
| 33 | + only: /.*/ |
| 34 | + - node8: |
| 35 | + filters: |
| 36 | + tags: |
| 37 | + only: /.*/ |
| 38 | + - lint: |
| 39 | + requires: |
| 40 | + - node4 |
| 41 | + - node6 |
| 42 | + - node7 |
| 43 | + - node8 |
| 44 | + filters: |
| 45 | + tags: |
| 46 | + only: /.*/ |
| 47 | + - docs: |
| 48 | + requires: |
| 49 | + - node4 |
| 50 | + - node6 |
| 51 | + - node7 |
| 52 | + - node8 |
| 53 | + filters: |
| 54 | + tags: |
| 55 | + only: /.*/ |
| 56 | + - system_tests: |
| 57 | + requires: |
| 58 | + - lint |
| 59 | + - docs |
| 60 | + filters: |
| 61 | + branches: |
| 62 | + only: master |
| 63 | + tags: |
| 64 | + only: /^v[\d.]+$/ |
| 65 | + - sample_tests: |
| 66 | + requires: |
| 67 | + - lint |
| 68 | + - docs |
| 69 | + filters: |
| 70 | + branches: |
| 71 | + only: master |
| 72 | + tags: |
| 73 | + only: /^v[\d.]+$/ |
| 74 | + - publish_npm: |
| 75 | + requires: |
| 76 | + - system_tests |
| 77 | + - sample_tests |
| 78 | + filters: |
| 79 | + branches: |
| 80 | + ignore: /.*/ |
| 81 | + tags: |
| 82 | + only: /^v[\d.]+$/ |
| 83 | + |
| 84 | +jobs: |
| 85 | + node4: |
| 86 | + docker: |
| 87 | + - image: node:4 |
| 88 | + steps: |
| 89 | + - checkout |
| 90 | + - run: |
| 91 | + name: Install modules and dependencies. |
| 92 | + command: npm install --unsafe-perm |
| 93 | + - run: |
| 94 | + name: Run unit tests. |
| 95 | + command: npm test |
| 96 | + - run: |
| 97 | + name: Submit coverage data to codecov. |
| 98 | + command: node_modules/.bin/codecov |
| 99 | + when: always |
| 100 | + node6: |
| 101 | + docker: |
| 102 | + - image: node:6 |
| 103 | + <<: *unit_tests |
| 104 | + node7: |
| 105 | + docker: |
| 106 | + - image: node:7 |
| 107 | + <<: *unit_tests |
| 108 | + node8: |
| 109 | + docker: |
| 110 | + - image: node:8 |
| 111 | + <<: *unit_tests |
| 112 | + |
| 113 | + lint: |
| 114 | + docker: |
| 115 | + - image: node:8 |
| 116 | + steps: |
| 117 | + - checkout |
| 118 | + - run: |
| 119 | + name: Install modules and dependencies. |
| 120 | + command: | |
| 121 | + npm install |
| 122 | + npm link |
| 123 | + - run: |
| 124 | + name: Link the module being tested to the samples. |
| 125 | + command: | |
| 126 | + cd samples/ |
| 127 | + npm link @google-cloud/compute |
| 128 | + npm install |
| 129 | + cd .. |
| 130 | + - run: |
| 131 | + name: Run linting. |
| 132 | + command: npm run lint |
| 133 | + |
| 134 | + docs: |
| 135 | + docker: |
| 136 | + - image: node:8 |
| 137 | + steps: |
| 138 | + - checkout |
| 139 | + - run: |
| 140 | + name: Install modules and dependencies. |
| 141 | + command: npm install |
| 142 | + - run: |
| 143 | + name: Build documentation. |
| 144 | + command: npm run docs |
| 145 | + |
| 146 | + sample_tests: |
| 147 | + docker: |
| 148 | + - image: node:8 |
| 149 | + steps: |
| 150 | + - checkout |
| 151 | + - run: |
| 152 | + name: Decrypt credentials. |
| 153 | + command: | |
| 154 | + openssl aes-256-cbc -d -in .circleci/key.json.enc \ |
| 155 | + -out .circleci/key.json \ |
| 156 | + -k "${SYSTEM_TESTS_ENCRYPTION_KEY}" |
| 157 | + - run: |
| 158 | + name: Install and link the module. |
| 159 | + command: | |
| 160 | + npm install |
| 161 | + npm link |
| 162 | + - run: |
| 163 | + name: Link the module being tested to the samples. |
| 164 | + command: | |
| 165 | + cd samples/ |
| 166 | + npm link @google-cloud/compute |
| 167 | + npm install |
| 168 | + cd .. |
| 169 | + - run: |
| 170 | + name: Run sample tests. |
| 171 | + command: npm run samples-test |
| 172 | + environment: |
| 173 | + GCLOUD_PROJECT: long-door-651 |
| 174 | + GOOGLE_APPLICATION_CREDENTIALS: /var/compute/.circleci/key.json |
| 175 | + - run: |
| 176 | + name: Remove unencrypted key. |
| 177 | + command: rm .circleci/key.json |
| 178 | + when: always |
| 179 | + working_directory: /var/compute/ |
| 180 | + |
| 181 | + system_tests: |
| 182 | + docker: |
| 183 | + - image: node:8 |
| 184 | + steps: |
| 185 | + - checkout |
| 186 | + - run: |
| 187 | + name: Decrypt credentials. |
| 188 | + command: | |
| 189 | + openssl aes-256-cbc -d -in .circleci/key.json.enc \ |
| 190 | + -out .circleci/key.json \ |
| 191 | + -k "${SYSTEM_TESTS_ENCRYPTION_KEY}" |
| 192 | + - run: |
| 193 | + name: Install modules and dependencies. |
| 194 | + command: npm install |
| 195 | + - run: |
| 196 | + name: Run system tests. |
| 197 | + command: npm run system-test |
| 198 | + environment: |
| 199 | + GOOGLE_APPLICATION_CREDENTIALS: .circleci/key.json |
| 200 | + - run: |
| 201 | + name: Remove unencrypted key. |
| 202 | + command: rm .circleci/key.json |
| 203 | + when: always |
| 204 | + |
| 205 | + publish_npm: |
| 206 | + docker: |
| 207 | + - image: node:8 |
| 208 | + steps: |
| 209 | + - checkout |
| 210 | + - run: |
| 211 | + name: Set NPM authentication. |
| 212 | + command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc |
| 213 | + - run: |
| 214 | + name: Publish the module to npm. |
| 215 | + command: npm publish |
0 commit comments