Skip to content
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
14 changes: 1 addition & 13 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
{
"extends": "segment/browser",

"rules": {
"global-strict": 0,
"max-len": 0,
"strict": 1
},

"globals": {
"exports": true,
"module": true,
"require": true
}
"extends": "@segment/eslint-config/browser/legacy"
}
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
*.log
.DS_Store
build.js
components
coverage
node_modules
File renamed without changes.
7 changes: 7 additions & 0 deletions History.md → HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2.0.0 / ????-??-??
==================

* Remove Duo compatibility
* Add CI setup (coverage, linting, cross-browser compatibility, etc.)
* Update eslint configuration

1.0.9 / 2016-05-07
==================

Expand Down
File renamed without changes.
143 changes: 65 additions & 78 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,93 +1,80 @@
#
# Binaries.
#

DUO = node_modules/.bin/duo
DUOT = node_modules/.bin/duo-test
ESLINT = node_modules/.bin/eslint

#
# Files.
#

SRCS_DIR = lib
SRCS = $(shell find $(SRCS_DIR) -type f -name "*.js")
TESTS_DIR = test
TESTS = $(shell find $(TESTS_DIR) -type f -name '*.test.js')

#
# Task config.
#

BROWSER ?= chrome

PORT ?= 0

DUOT_ARGS = \
--reporter spec \
--port $(PORT) \
--commands "make build"

#
# Chore tasks.
#

# Install node dependencies.
##
# Binaries
##

ESLINT := node_modules/.bin/eslint
KARMA := node_modules/.bin/karma

##
# Files
##

LIBS = $(shell find lib -type f -name "*.js")
TESTS = $(shell find test -type f -name "*.test.js")
SUPPORT = $(wildcard karma.conf*.js)
ALL_FILES = $(LIBS) $(TESTS) $(SUPPORT)

##
# Program options/flags
##

# A list of options to pass to Karma
# Overriding this overwrites all options specified in this file (e.g. BROWSERS)
KARMA_FLAGS ?=

# A list of Karma browser launchers to run
# http://karma-runner.github.io/0.13/config/browsers.html
BROWSERS ?=
ifdef BROWSERS
KARMA_FLAGS += --browsers $(BROWSERS)
endif

ifdef CI
KARMA_CONF ?= karma.conf.ci.js
else
KARMA_CONF ?= karma.conf.js
endif

# Mocha flags.
GREP ?= .

##
# Tasks
##

# Install node modules.
node_modules: package.json $(wildcard node_modules/*/package.json)
@npm install
@touch $@

# Install dependencies.
install: node_modules

# Remove temporary files and build artifacts.
clean:
rm -rf build.js
rm -rf *.log coverage
.PHONY: clean

# Remove temporary files, build artifacts, and vendor dependencies.
distclean: clean
rm -rf components node_modules
rm -rf node_modules
.PHONY: distclean

#
# Build tasks.
#

# Build all integrations, tests, and dependencies together for testing.
build.js: node_modules component.json $(SRCS) $(TESTS)
@$(DUO) --stdout --development $(TESTS) > $@

# Build shortcut.
build: build.js
.DEFAULT_GOAL = build
# Lint JavaScript source files.
lint: install
@$(ESLINT) $(ALL_FILES)
.PHONY: lint

#
# Test tasks.
#
# Attempt to fix linting errors.
fmt: install
@$(ESLINT) --fix $(ALL_FILES)
.PHONY: fmt

# Lint JavaScript source.
lint: node_modules
@$(ESLINT) $(SRCS) $(TESTS)
.PHONY: lint
# Run browser unit tests in a browser.
test-browser: install
@$(KARMA) start $(KARMA_FLAGS) $(KARMA_CONF)

# Test locally in PhantomJS.
test-phantomjs: node_modules build.js
@$(DUOT) phantomjs $(TESTS_DIR) args: \
--ignore-ssl-errors=true --ssl-protocol=tlsv1 --path node_modules/.bin/phantomjs
.PHONY: test-phantomjs

# Test locally in the browser.
test-browser: node_modules build.js
@$(DUOT) browser --commands "make build" $(TESTS_DIR)
.PHONY: test-browser

# Test in Sauce Labs. Note that you must set the SAUCE_USERNAME and
# SAUCE_ACCESS_KEY environment variables using your Sauce Labs credentials.
test-sauce: node_modules build.js
@$(DUOT) saucelabs $(TESTS_DIR) \
--name analytics.js-integrations \
--browsers $(BROWSER) \
--user $(SAUCE_USERNAME) \
--key $(SAUCE_ACCESS_KEY)
.PHONY: test-sauce

# Test shortcut.
test: lint test-phantomjs
# Default test target.
test: lint test-browser
.PHONY: test
.DEFAULT_GOAL = test
2 changes: 1 addition & 1 deletion Readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Drift integration for [Analytics.js][].

## License

Released under the [MIT license](License.md).
Released under the [MIT license](LICENSE).


[Analytics.js]: https://segment.com/docs/libraries/analytics.js/
Expand Down
26 changes: 22 additions & 4 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
machine:
node:
version: 0.12
version: 4
environment:
NPM_CONFIG_PROGRESS: false
NPM_CONFIG_SPIN: false
TEST_REPORTS_DIR: $CIRCLE_TEST_REPORTS

dependencies:
pre:
- echo "github.com,192.30.252.*,192.30.253.*,192.30.254.*,192.30.255.* ssh-rsa $(ssh-keyscan -t rsa github.com | cut -d ' ' -f 3-)" >> ~/.ssh/known_hosts
- npm install -g npm@'>=2.7.0'
- make
- npm config set "//registry.npmjs.org/:_authToken" $NPM_AUTH
- npm -g install codecov
override:
- make install

test:
override:
- make test
post:
- cp -R coverage $CIRCLE_ARTIFACTS/
- codecov

deployment:
publish:
owner: segmentio
# Works on e.g. `1.0.0-alpha.1`
tag: /[0-9]+(\.[0-9]+)*(-.+)?/
commands:
- npm publish .
19 changes: 0 additions & 19 deletions component.json

This file was deleted.

101 changes: 101 additions & 0 deletions karma.conf.ci.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/* eslint-env node */
'use strict';

var baseConfig = require('./karma.conf');

var customLaunchers = {
sl_chrome_latest: {
base: 'SauceLabs',
browserName: 'chrome',
platform: 'linux',
version: 'latest'
},
sl_chrome_latest_1: {
base: 'SauceLabs',
browserName: 'chrome',
platform: 'linux',
version: 'latest-1'
},
sl_firefox_latest: {
base: 'SauceLabs',
browserName: 'firefox',
platform: 'linux',
version: 'latest'
},
sl_firefox_latest_1: {
base: 'SauceLabs',
browserName: 'firefox',
platform: 'linux',
version: 'latest-1'
},
sl_safari_9: {
base: 'SauceLabs',
browserName: 'safari',
version: '9.0'
},
// FIXME(ndhoule): Bad IE7/8 support in testing packages make these fail
// sl_ie_7: {
// base: 'SauceLabs',
// browserName: 'internet explorer',
// version: '7'
// },
// sl_ie_8: {
// base: 'SauceLabs',
// browserName: 'internet explorer',
// version: '8'
// },
sl_ie_9: {
base: 'SauceLabs',
browserName: 'internet explorer',
version: '9'
},
sl_ie_10: {
base: 'SauceLabs',
browserName: 'internet explorer',
version: '10'
},
sl_ie_11: {
base: 'SauceLabs',
browserName: 'internet explorer',
version: '11'
},
sl_edge_latest: {
base: 'SauceLabs',
browserName: 'microsoftedge'
}
};

module.exports = function(config) {
baseConfig(config);

if (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) {
throw new Error('SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables are required but are missing');
}

config.set({
browserDisconnectTolerance: 1,

singleRun: true,

reporters: ['progress', 'junit', 'coverage'],

browsers: ['PhantomJS'].concat(Object.keys(customLaunchers)),

customLaunchers: customLaunchers,

junitReporter: {
outputDir: process.env.TEST_REPORTS_DIR,
suite: require('./package.json').name
},

sauceLabs: {
testName: require('./package.json').name
},

coverageReporter: {
reporters: [
{ type: 'lcov' }
]
}
});
};
Loading