From a7995c45182455fa46f83d0a21ae057cb6a25c22 Mon Sep 17 00:00:00 2001 From: Rhys Evans Date: Tue, 16 Jan 2018 21:29:08 +0000 Subject: [PATCH] Circleci (#245) * start configuring for circleci workflows * more config tweaks * force * force * try to run test as workflow * try circle1 * try again * try to build * shift build * simple build again * try adding workflows again * tweak circelci * tweak circelci * workflow tweak * add fan out * cache node_modules * test both versions of node fetch * chrome headless tests * try circleci docker with browsers * firefox and lint * added deploy step * final tweaks to tasks --- .circleci/config.yml | 102 +++++++++++++++++++++++++++++++++++++++++++ .travis.yml | 9 ---- Makefile | 9 ++-- karma.conf.js | 12 +---- package.json | 2 - 5 files changed, 108 insertions(+), 26 deletions(-) create mode 100644 .circleci/config.yml delete mode 100644 .travis.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..1c701ada --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,102 @@ +version: 2.0 +jobs: + checkout_code: + docker: + - image: circleci/node:8.9.0 + steps: + - checkout + - run: npm install + - save_cache: + key: dependency-cache-{{ checksum "package.json" }} + paths: + - node_modules + + lint: + docker: + - image: circleci/node:8.9.0 + steps: + - checkout + - restore_cache: + key: dependency-cache-{{ checksum "package.json" }} + - run: make lint + + nodefetch2: + docker: + - image: circleci/node:8.9.0 + steps: + - checkout + - restore_cache: + key: dependency-cache-{{ checksum "package.json" }} + - run: make coverage-report + + nodefetch1: + docker: + - image: circleci/node:8.9.0 + steps: + - checkout + - restore_cache: + key: dependency-cache-{{ checksum "package.json" }} + - run: npm install node-fetch@1 + - run: make test-unit + + chrome: + docker: + - image: circleci/node:8.9.0-browsers + steps: + - checkout + - restore_cache: + key: dependency-cache-{{ checksum "package.json" }} + - run: make test-chrome + + firefox: + docker: + - image: circleci/node:8.9.0-browsers + steps: + - checkout + - restore_cache: + key: dependency-cache-{{ checksum "package.json" }} + - run: npm install karma-firefox-launcher + - run: make test-firefox + + deploy: + docker: + - image: circleci/node:8.9.0 + steps: + - checkout + - restore_cache: + key: dependency-cache-{{ checksum "package.json" }} + - run: npm version --no-git-tag-version ${CIRCLE_TAG} + - run: npm publish --access public + +workflows: + version: 2 + checkout_and_test: + jobs: + - checkout_code + - nodefetch1: + requires: + - checkout_code + - nodefetch2: + requires: + - checkout_code + - chrome: + requires: + - checkout_code + - firefox: + requires: + - checkout_code + - lint: + requires: + - checkout_code + - deploy: + requires: + - nodefetch1 + - nodefetch2 + - chrome + - firefox + - lint + filters: + tags: + only: /v.*/ + + diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5a0f695b..00000000 --- a/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -sudo: false -language: node_js -script: npm test -node_js: -- '4' -before_install: -- export CHROME_BIN=chromium-browser -- export DISPLAY=:99.0 -- sh -e /etc/init.d/xvfb start \ No newline at end of file diff --git a/Makefile b/Makefile index 1947855f..ff15c97c 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,11 @@ build-sw: test-dev: build-sw ./node_modules/karma/bin/karma start -test-browser: build-sw - ./node_modules/karma/bin/karma start --single-run +test-chrome: build-sw + ./node_modules/karma/bin/karma start --single-run --browsers=Chrome + +test-firefox: build-sw + ./node_modules/karma/bin/karma start --single-run --browsers=Firefox test-unit: ./node_modules/.bin/mocha test/server.js @@ -15,8 +18,6 @@ test-unit: lint: ./node_modules/.bin/eslint src test -test: test-unit lint test-browser coverage-report - coverage-report: istanbul cover node_modules/.bin/_mocha --report=lcovonly 'test/server.js' cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js diff --git a/karma.conf.js b/karma.conf.js index e2a4f0f2..efc1dbda 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,6 +1,7 @@ 'use strict'; module.exports = function(karma) { + var configuration = { frameworks: [ 'mocha', 'chai', 'browserify'], @@ -24,20 +25,9 @@ module.exports = function(karma) { 'plugins': ['transform-object-assign'] }] ] - }, - browsers: ['Chrome'], - customLaunchers: { - Chrome_travis_ci: { - base: 'Chrome', - flags: ['--no-sandbox'] - } } }; - if(process.env.TRAVIS){ - configuration.browsers = ['PhantomJS', 'Firefox', 'Chrome_travis_ci']; - } - karma.set(configuration); }; diff --git a/package.json b/package.json index cee1a329..9fab0494 100644 --- a/package.json +++ b/package.json @@ -49,9 +49,7 @@ "karma-browserify": "^5.1.0", "karma-chai": "^0.1.0", "karma-chrome-launcher": "^2.0.0", - "karma-firefox-launcher": "^1.0.0", "karma-mocha": "^1.2.0", - "karma-phantomjs-launcher": "^1.0.2", "mocha": "^2.2.4", "mockery": "^1.4.0", "sinon": "^1.17.0",