Skip to content

Commit

Permalink
Merge pull request #2310 from plotly/circle2
Browse files Browse the repository at this point in the history
Test with CircleCI 2.0
  • Loading branch information
etpinard authored Jan 31, 2018
2 parents a60cebf + 795ff31 commit 18dac1f
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 57 deletions.
108 changes: 108 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
version: 2.0

# Inspired by:
# https://github.com/CircleCI-Public/circleci-demo-workflows/blob/workspace-forwarding/.circleci/config.yml
# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs

jobs:
build:
docker:
- image: circleci/node:6.10.3
working_directory: ~/plotly.js
steps:
- checkout
- restore_cache:
keys:
- v{{ .Environment.CIRCLE_CACHE_VERSION }}-deps-{{ .Branch }}-{{ checksum "package.json" }}
- v{{ .Environment.CIRCLE_CACHE_VERSION }}-deps-master-{{ checksum "package.json" }}
- run:
name: Install dependencies
command: |
npm install
npm dedupe
npm prune
npm install
- run:
name: List dependency versions
command: |
echo "npm: $(npm --version)"
echo "node: $(node --version)"
npm ls || true
- run:
name: Pretest
command: |
npm run pretest
npm run cibuild
- save_cache:
paths:
- node_modules
key: v{{ .Environment.CIRCLE_CACHE_VERSION }}-deps-{{ .Branch }}-{{ checksum "package.json" }}
- persist_to_workspace:
root: .
paths:
- node_modules
- build
- dist

test-jasmine:
docker:
# need '-browsers' version to test in real (xvfb-wrapped) browsers
- image: circleci/node:6.10.3-browsers
working_directory: ~/plotly.js
steps:
- checkout
- attach_workspace:
at: ~/plotly.js
- run:
name: Set timezone to Alaska time (arbitrary timezone to test date logic)
command: |
sudo cp /usr/share/zoneinfo/America/Anchorage /etc/localtime
- run:
name: Run jasmine tests
command: ./.circleci/test.sh jasmine

test-image:
docker:
- image: plotly/testbed:latest
working_directory: /var/www/streambed/image_server/plotly.js/
steps:
- checkout
- attach_workspace:
at: /var/www/streambed/image_server/plotly.js/
- run:
name: Run and setup container
command: |
supervisord &
npm run docker -- setup
- run:
name: Run image tests
command: ./.circleci/test.sh image
- store_artifacts:
path: build

test-syntax:
docker:
- image: circleci/node:6.10.3
working_directory: ~/plotly.js
steps:
- checkout
- attach_workspace:
at: ~/plotly.js
- run:
name: Run syntax tests
command: ./.circleci/test.sh syntax

workflows:
version: 2
build-and-test:
jobs:
- build
- test-jasmine:
requires:
- build
- test-image:
requires:
- build
- test-syntax:
requires:
- build
24 changes: 16 additions & 8 deletions tasks/ci_test.sh → .circleci/test.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
#!/bin/bash

# override CircleCi's default run settings
set +e
set +o pipefail

EXIT_STATE=0

case $CIRCLE_NODE_INDEX in
case $1 in

jasmine)
npm run test-jasmine || EXIT_STATE=$?
npm run test-bundle || EXIT_STATE=$?
exit $EXIT_STATE
;;

0)
image)
npm run test-image || EXIT_STATE=$?
npm run test-export || EXIT_STATE=$?
npm run test-image-gl2d || EXIT_STATE=$?
npm run test-bundle || EXIT_STATE=$?
npm run lint || EXIT_STATE=$?
exit $EXIT_STATE
;;

1)
npm run test-jasmine || EXIT_STATE=$?
npm run test-export || EXIT_STATE=$?
npm run test-syntax || EXIT_STATE=$?
syntax)
npm run lint || EXIT_STATE=$?
npm run test-syntax || EXIT_STATE=$?
exit $EXIT_STATE
;;

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ npm-debug.log*
*.sublime*

.*
!.circleci
!.gitignore
!.npmignore
!.eslintrc
Expand Down
27 changes: 0 additions & 27 deletions circle.yml

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"start-image_viewer": "node devtools/image_viewer/server.js",
"start": "npm run start-test_dashboard",
"baseline": "node tasks/baseline.js",
"preversion": "npm-link-check && npm dedupe",
"preversion": "npm-link-check && npm dedupe && npm ls --prod",
"version": "npm run build && git add -A dist src build",
"postversion": "node -e \"console.log('Version bumped and committed. If ok, run: git push && git push --tags')\""
},
Expand Down
3 changes: 0 additions & 3 deletions tasks/noci_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,4 @@ npm run test-jasmine -- --tags=noCI --nowatch || EXIT_STATE=$?
# mapbox image tests take too much resources on CI
npm run test-image -- mapbox_* --queue || EXIT_STATE=$?

# run gl2d image test again (some mocks are skipped on CI)
npm run test-image-gl2d || EXIT_STATE=$?

exit $EXIT_STATE
20 changes: 3 additions & 17 deletions tasks/util/container_commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,17 @@ containerCommands.getRunCmd = function(isCI, commands) {

function getRunLocal(commands) {
commands = [containerCommands.cdHome].concat(commands);

var commandsJoined = '"' + commands.join(' && ') + '"';

return [
'docker exec -i',
constants.testContainerName,
'/bin/bash -c',
commandsJoined
'"' + commands.join(' && ') + '"'
].join(' ');
}

function getRunCI(commands) {
commands = ['export CIRCLECI=1', containerCommands.cdHome].concat(commands);

var commandsJoined = '"' + commands.join(' && ') + '"';
var containerId = '$(docker inspect --format \'{{.Id}}\' ' + constants.testContainerName + ')';

return [
'sudo',
'lxc-attach',
'-n', containerId,
'-f', '/var/lib/docker/containers/' + containerId + '/config.lxc',
'-- bash -c',
commandsJoined
].join(' ');
commands = [containerCommands.cdHome].concat(commands);
return commands.join(' && ');
}

module.exports = containerCommands;
2 changes: 1 addition & 1 deletion test/jasmine/tests/toimage_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe('Plotly.toImage', function() {
.then(function() { return Plotly.toImage(gd, {format: 'png', imageDataOnly: true}); })
.then(function(d) {
expect(d.indexOf('data:image/')).toBe(-1);
expect(d.length).toBeWithin(54660, 3e3, 'png image length');
expect(d.length).toBeWithin(50000, 5e3, 'png image length');
})
.then(function() { return Plotly.toImage(gd, {format: 'jpeg', imageDataOnly: true}); })
.then(function(d) {
Expand Down

0 comments on commit 18dac1f

Please sign in to comment.