Skip to content

Commit

Permalink
chore: update CircleCI config
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith committed Nov 1, 2018
1 parent c2ab3c0 commit ce9cd4a
Showing 1 changed file with 80 additions and 100 deletions.
180 changes: 80 additions & 100 deletions .circleci/config.yml
Expand Up @@ -3,48 +3,55 @@ workflows:
version: 2
tests:
jobs: &workflow_jobs
- node4:
filters:
tags:
only: /.*/
- node6:
filters: &all_commits
filters:
tags:
only: /.*/
- node8:
filters: *all_commits
filters:
tags:
only: /.*/
- node9:
filters:
tags:
only: /.*/
- node10:
filters: *all_commits
filters:
tags:
only: /.*/
- lint:
requires:
- node4
- node6
- node8
- node9
- node10
filters: *all_commits
filters:
tags:
only: /.*/
- docs:
requires:
- node4
- node6
- node8
- node9
- node10
filters: *all_commits
- system_tests:
requires:
- lint
- docs
filters: &master_and_releases
branches:
only: master
tags: &releases
only: '/^v[\d.]+$/'
- sample_tests:
filters:
tags:
only: /.*/
- publish_npm:
requires:
- lint
- docs
filters: *master_and_releases
- publish_npm:
requires:
- system_tests
- sample_tests
filters:
branches:
ignore: /.*/
tags: *releases
tags:
only: '/^v[\d.]+$/'
nightly:
triggers:
- schedule:
Expand All @@ -54,25 +61,48 @@ workflows:
only: master
jobs: *workflow_jobs
jobs:
node6:
node4:
docker:
- image: 'node:6'
- image: 'node:4'
user: node
steps: &unit_tests_steps
- checkout
- run: &npm_install_and_link
name: Install and link the module
command: |-
mkdir -p /home/node/.npm-global
./.circleci/npm-install-retry.js
environment:
NPM_CONFIG_PREFIX: /home/node/.npm-global
- run: npm test
- run: &remove_package_lock
name: Remove package-lock.json if needed.
command: |
WORKFLOW_NAME=`python .circleci/get_workflow_name.py`
echo "Workflow name: $WORKFLOW_NAME"
if [ "$WORKFLOW_NAME" = "nightly" ]; then
echo "Nightly build detected, removing package-lock.json."
rm -f package-lock.json samples/package-lock.json
else
echo "Not a nightly build, skipping this step."
fi
- run:
name: Install modules and dependencies.
command: npm install
- run:
name: Run unit tests.
command: npm run test-only
- run:
name: Submit coverage data to codecov.
command: node_modules/.bin/codecov
when: always
node6:
docker:
- image: 'node:6'
user: node
steps: *unit_tests_steps
node8:
docker:
- image: 'node:8'
user: node
steps: *unit_tests_steps
node9:
docker:
- image: 'node:9'
user: node
steps: *unit_tests_steps
node10:
docker:
- image: 'node:10'
Expand All @@ -84,18 +114,18 @@ jobs:
user: node
steps:
- checkout
- run: *npm_install_and_link
- run: &samples_npm_install_and_link
name: Link the module being tested to the samples.
- run: *remove_package_lock
- run:
name: Install modules and dependencies.
command: |
cd samples/
npm link ../
./../.circleci/npm-install-retry.js
mkdir -p /home/node/.npm-global
npm install
npm link
environment:
NPM_CONFIG_PREFIX: /home/node/.npm-global
- run:
name: Run linting.
command: npm run lint
command: npm run check
environment:
NPM_CONFIG_PREFIX: /home/node/.npm-global
docs:
Expand All @@ -104,75 +134,25 @@ jobs:
user: node
steps:
- checkout
- run: *npm_install_and_link
- run: npm run docs
sample_tests:
docker:
- image: 'node:8'
user: node
steps:
- checkout
- run:
name: Decrypt credentials.
command: |
if ! [[ -z "${SYSTEM_TESTS_ENCRYPTION_KEY}" ]]; then
openssl aes-256-cbc -d -in .circleci/key.json.enc \
-out .circleci/key.json \
-k "${SYSTEM_TESTS_ENCRYPTION_KEY}"
fi
- run: *npm_install_and_link
- run: *samples_npm_install_and_link
- run: *remove_package_lock
- run:
name: Run sample tests.
command: npm run samples-test
environment:
GCLOUD_PROJECT: long-door-651
GOOGLE_APPLICATION_CREDENTIALS: /home/node/samples/.circleci/key.json
NPM_CONFIG_PREFIX: /home/node/.npm-global
name: Install modules and dependencies.
command: npm install
- run:
name: Remove unencrypted key.
command: |
if ! [[ -z "${SYSTEM_TESTS_ENCRYPTION_KEY}" ]]; then
rm .circleci/key.json
fi
when: always
working_directory: /home/node/samples/
system_tests:
name: Build documentation.
command: npm run docs
publish_npm:
docker:
- image: 'node:8'
user: node
steps:
- checkout
- run:
name: Decrypt credentials.
command: |
if ! [[ -z "${SYSTEM_TESTS_ENCRYPTION_KEY}" ]]; then
for encrypted_key in .circleci/*.json.enc; do
openssl aes-256-cbc -d -in $encrypted_key \
-out $(echo $encrypted_key | sed 's/\.enc//') \
-k "${SYSTEM_TESTS_ENCRYPTION_KEY}"
done
fi
- run: *npm_install_and_link
name: Set NPM authentication.
command: 'echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc'
- run:
name: Run system tests.
command: npm run system-test
environment:
GCLOUD_PROJECT: long-door-651
GOOGLE_APPLICATION_CREDENTIALS: .circleci/key.json
name: Install dependencies
command: npm install --unsafe-perm
- run:
name: Remove unencrypted key.
command: |
if ! [[ -z "${SYSTEM_TESTS_ENCRYPTION_KEY}" ]]; then
rm .circleci/*.json
fi
when: always
publish_npm:
docker:
- image: 'node:8'
user: node
steps:
- checkout
- run: ./.circleci/npm-install-retry.js
- run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
- run: npm publish --access=public
name: Publish the module to npm.
command: npm publish

0 comments on commit ce9cd4a

Please sign in to comment.