Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test with CircleCI 2.0 #2310

Merged
merged 4 commits into from
Jan 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like CircleCI's new defaults where a given job stop executing after the first test failure. I prefer running all the tests no matter what, to see if a given commit makes multiple tests fail. I hope you agree with me.


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",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @alexcjohnson @dfcreative

This commit partly reverts 1d3a3f0

npm ls --prod will fail only if a bundle dependency (i.e. ignoring dev-dependencies) is (1) missing, (2) needs to be updated or (3) is extraneous. This step ensures that we're not bundling dist/ bundles with incorrect dependencies.

"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=$?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixup for 9f304e6

No need for this line anymore as now all gl2d mocks are tested on CI.


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