|
1 | 1 | version: 0.2
|
2 | 2 |
|
3 |
| -env: |
4 |
| - variables: |
5 |
| - NPM_CONFIG_UNSAFE_PERM: true |
6 |
| - NODE_OPTIONS: "--max-old-space-size=4096" |
7 |
| - BRANCH: "master" |
8 |
| - # An explicit version bump |
9 |
| - VERSION_BUMP: "" |
10 |
| - secrets-manager: |
11 |
| - OTP_SECRET_KEY: npm/aws-crypto-tools-ci-bot/2FA:OTP_SECRET_KEY |
12 |
| - NPM_TOKEN: npm/aws-crypto-tools-ci-bot/2FA:NPM_TOKEN |
13 |
| - git-credential-helper: yes |
14 |
| - |
15 |
| -phases: |
16 |
| - install: |
17 |
| - commands: |
18 |
| - - npm ci --unsafe-perm |
19 |
| - # Install `otplib` to extract the OTP from the npm 2FA secret |
20 |
| - - npm install otplib --no-save |
21 |
| - - npm run build |
22 |
| - runtime-versions: |
23 |
| - nodejs: 12 |
24 |
| - pre_build: |
25 |
| - commands: |
26 |
| - - git config --global user.name "aws-crypto-tools-ci-bot" |
27 |
| - - git config --global user.email "no-reply@noemail.local" |
28 |
| - - git checkout $BRANCH |
29 |
| - build: |
30 |
| - commands: |
31 |
| - # Pre-check, make sure everything is happy |
32 |
| - - npm test |
33 |
| - - npm run test_conditions |
34 |
| - # Publish to a local verdaccio server and run all tests against it |
35 |
| - - npm run verdaccio |
36 |
| - # Generate new version and CHANGELOG entry and push it |
37 |
| - - npx lerna version --conventional-commits --git-remote origin --yes ${VERSION_BUMP:+$VERSION_BUMP --force-publish} |
38 |
| - # Log the commit for posterity |
39 |
| - - git log -n 1 |
40 |
| - # Extract the otp using the secrets environment variables from above. |
41 |
| - # This will wait for the next token. This is because npm uses |
42 |
| - # TOTP and the tokens time out after 30 seconds. If the process just |
43 |
| - # extracted the token then the lifetime for this token |
44 |
| - # would be very random. This will maximize the amount of time |
45 |
| - # available on the OTP to publish. |
46 |
| - - >- |
47 |
| - OTP=`node -e " |
48 |
| - auth=require('otplib').authenticator; |
49 |
| - setTimeout(() => |
50 |
| - console.log(auth.generate(process.env.OTP_SECRET_KEY)), |
51 |
| - auth.timeRemaining() * 1000); |
52 |
| - "` |
53 |
| - # npm will only expand env vars inside .npmrc |
54 |
| - # NOTE the ' this is to keep the env var NPM_TOKEN from expanding! |
55 |
| - - echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > .npmrc |
56 |
| - # Now we publish to npm. |
57 |
| - # This is going to use the OTP generated above and the NPM_TOKEN |
58 |
| - # environment variable. This will only publish things that are |
59 |
| - # missing from npm. It is therefore safe to run repeatedly. |
60 |
| - - npx lerna publish from-package --yes --otp $OTP |
61 |
| - # remove after publishing |
62 |
| - - rm .npmrc |
63 |
| - # Clear out the verdaccio cache so that we get the latest version |
64 |
| - # of everything from public npm |
65 |
| - - rm -rf verdaccio/storage/ |
66 |
| - # Since the cache is empty, and we don't call `verdaccio-publish` |
67 |
| - # this will run the integrations from the public code in npm |
68 |
| - - npx run-s verdaccio-publish-* |
69 |
| - |
70 |
| - |
71 |
| -# Batching is technically unnecessary for now since we have just the one |
72 |
| -# buildspec, but leaving it in place makes it easier to extend later on |
73 | 3 | batch:
|
74 | 4 | fast-fail: true
|
75 | 5 | build-graph:
|
76 |
| - - identifier: release_to_prod |
| 6 | + |
| 7 | +# Lint and specification compliance |
| 8 | + - identifier: compliance |
| 9 | + buildspec: codebuild/compliance.yml |
| 10 | + |
| 11 | +# Unit Tests |
| 12 | + - identifier: testNodejsLatest |
| 13 | + buildspec: codebuild/nodejs_latest.yml |
| 14 | + env: |
| 15 | + image: aws/codebuild/standard:5.0 |
| 16 | + - identifier: testBrowser |
| 17 | + buildspec: codebuild/browser.yml |
| 18 | + |
| 19 | +# Integration Tests |
| 20 | + - identifier: testVectorsNodejsLatest |
| 21 | + buildspec: codebuild/test_vectors/nodejs_latest.yml |
| 22 | + env: |
| 23 | + variables: |
| 24 | + PUBLISH_LOCAL: "true" |
| 25 | + image: aws/codebuild/standard:5.0 |
| 26 | + - identifier: testVectorsBrowser |
| 27 | + buildspec: codebuild/test_vectors/browser.yml |
| 28 | + env: |
| 29 | + variables: |
| 30 | + PUBLISH_LOCAL: "true" |
| 31 | + image: aws/codebuild/standard:5.0 |
| 32 | + |
| 33 | +# Version the project and push git commits and tags |
| 34 | + - identifier: version |
| 35 | + depend-on: |
| 36 | + - compliance |
| 37 | + - testNodejsLatest |
| 38 | + - testBrowser |
| 39 | + - testVectorsNodejsLatest |
| 40 | + - testVectorsBrowser |
| 41 | + buildspec: codebuild/release/version.yml |
| 42 | + |
| 43 | +# Publish the release to npm |
| 44 | + - identifier: publish |
| 45 | + depend-on: |
| 46 | + - version |
| 47 | + buildspec: codebuild/release/publish.yml |
| 48 | + |
| 49 | +# Validate that the published versions are available |
| 50 | + - identifier: validateNodejs |
| 51 | + depend-on: |
| 52 | + - publish |
| 53 | + buildspec: codebuild/test_vectors/nodejs_latest.yml |
| 54 | + env: |
| 55 | + variables: |
| 56 | + PUBLISH_LOCAL: "false" |
| 57 | + image: aws/codebuild/standard:5.0 |
| 58 | + - identifier: validateBrowser |
| 59 | + depend-on: |
| 60 | + - publish |
| 61 | + buildspec: codebuild/test_vectors/browser.yml |
| 62 | + env: |
| 63 | + variables: |
| 64 | + PUBLISH_LOCAL: "false" |
| 65 | + image: aws/codebuild/standard:5.0 |
0 commit comments