Skip to content

Commit 7587333

Browse files
authored
Merge pull request Driftt#8 from Driftt/rebase-master
Rebase master
2 parents 6714182 + 760dd4d commit 7587333

16 files changed

+314
-186
lines changed

.eslintrc

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
11
{
2-
"extends": "segment/browser",
3-
4-
"rules": {
5-
"global-strict": 0,
6-
"max-len": 0,
7-
"strict": 1
8-
},
9-
10-
"globals": {
11-
"exports": true,
12-
"module": true,
13-
"require": true
14-
}
2+
"extends": "@segment/eslint-config/browser/legacy"
153
}

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
*.log
2-
.DS_Store
3-
build.js
4-
components
1+
coverage
52
node_modules

Contributing.md renamed to CONTRIBUTING.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ That will install all of our [npm](http://npmjs.org) and [component](http://comp
2121
The commands you'll want to know for development are:
2222

2323
```bash
24-
$ make # re-compiles the development build of analytics.js for testing
25-
$ make test # runs all of the tests in your terminal
26-
$ make test-browser # runs all of the tests in your browser, for nicer debugging
24+
$ make test # runs all of the tests in your terminal
25+
$ make test-browser BROWSERS=Chrome # runs all of the tests in Chrome for nicer debugging
2726
```
2827

2928
## Writing Tests

History.md renamed to HISTORY.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
2+
2.0.1 / 2016-07-25
3+
==================
4+
5+
* Merge pull request #2 from segment-integrations/sync_partner_repo
6+
* Add back changes lost during duo->browserify migration
7+
* Update CONTRIBUTING.md
8+
* Move Sauce Labs credentials into circle.yml
9+
* Update Karma to 1.1.0
10+
11+
2.0.0 / 2016-06-21
12+
==================
13+
14+
* Remove Duo compatibility
15+
* Add CI setup (coverage, linting, cross-browser compatibility, etc.)
16+
* Update eslint configuration
17+
118
1.0.9 / 2016-05-07
219
==================
320

File renamed without changes.

Makefile

Lines changed: 65 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,80 @@
1-
#
2-
# Binaries.
3-
#
4-
5-
DUO = node_modules/.bin/duo
6-
DUOT = node_modules/.bin/duo-test
7-
ESLINT = node_modules/.bin/eslint
8-
9-
#
10-
# Files.
11-
#
12-
13-
SRCS_DIR = lib
14-
SRCS = $(shell find $(SRCS_DIR) -type f -name "*.js")
15-
TESTS_DIR = test
16-
TESTS = $(shell find $(TESTS_DIR) -type f -name '*.test.js')
17-
18-
#
19-
# Task config.
20-
#
21-
22-
BROWSER ?= chrome
23-
24-
PORT ?= 0
25-
26-
DUOT_ARGS = \
27-
--reporter spec \
28-
--port $(PORT) \
29-
--commands "make build"
30-
31-
#
32-
# Chore tasks.
33-
#
34-
35-
# Install node dependencies.
1+
##
2+
# Binaries
3+
##
4+
5+
ESLINT := node_modules/.bin/eslint
6+
KARMA := node_modules/.bin/karma
7+
8+
##
9+
# Files
10+
##
11+
12+
LIBS = $(shell find lib -type f -name "*.js")
13+
TESTS = $(shell find test -type f -name "*.test.js")
14+
SUPPORT = $(wildcard karma.conf*.js)
15+
ALL_FILES = $(LIBS) $(TESTS) $(SUPPORT)
16+
17+
##
18+
# Program options/flags
19+
##
20+
21+
# A list of options to pass to Karma
22+
# Overriding this overwrites all options specified in this file (e.g. BROWSERS)
23+
KARMA_FLAGS ?=
24+
25+
# A list of Karma browser launchers to run
26+
# http://karma-runner.github.io/0.13/config/browsers.html
27+
BROWSERS ?=
28+
ifdef BROWSERS
29+
KARMA_FLAGS += --browsers $(BROWSERS)
30+
endif
31+
32+
ifdef CI
33+
KARMA_CONF ?= karma.conf.ci.js
34+
else
35+
KARMA_CONF ?= karma.conf.js
36+
endif
37+
38+
# Mocha flags.
39+
GREP ?= .
40+
41+
##
42+
# Tasks
43+
##
44+
45+
# Install node modules.
3646
node_modules: package.json $(wildcard node_modules/*/package.json)
3747
@npm install
48+
@touch $@
49+
50+
# Install dependencies.
51+
install: node_modules
3852

3953
# Remove temporary files and build artifacts.
4054
clean:
41-
rm -rf build.js
55+
rm -rf *.log coverage
4256
.PHONY: clean
4357

4458
# Remove temporary files, build artifacts, and vendor dependencies.
4559
distclean: clean
46-
rm -rf components node_modules
60+
rm -rf node_modules
4761
.PHONY: distclean
4862

49-
#
50-
# Build tasks.
51-
#
52-
53-
# Build all integrations, tests, and dependencies together for testing.
54-
build.js: node_modules component.json $(SRCS) $(TESTS)
55-
@$(DUO) --stdout --development $(TESTS) > $@
56-
57-
# Build shortcut.
58-
build: build.js
59-
.DEFAULT_GOAL = build
63+
# Lint JavaScript source files.
64+
lint: install
65+
@$(ESLINT) $(ALL_FILES)
66+
.PHONY: lint
6067

61-
#
62-
# Test tasks.
63-
#
68+
# Attempt to fix linting errors.
69+
fmt: install
70+
@$(ESLINT) --fix $(ALL_FILES)
71+
.PHONY: fmt
6472

65-
# Lint JavaScript source.
66-
lint: node_modules
67-
@$(ESLINT) $(SRCS) $(TESTS)
68-
.PHONY: lint
73+
# Run browser unit tests in a browser.
74+
test-browser: install
75+
@$(KARMA) start $(KARMA_FLAGS) $(KARMA_CONF)
6976

70-
# Test locally in PhantomJS.
71-
test-phantomjs: node_modules build.js
72-
@$(DUOT) phantomjs $(TESTS_DIR) args: \
73-
--ignore-ssl-errors=true --ssl-protocol=tlsv1 --path node_modules/.bin/phantomjs
74-
.PHONY: test-phantomjs
75-
76-
# Test locally in the browser.
77-
test-browser: node_modules build.js
78-
@$(DUOT) browser --commands "make build" $(TESTS_DIR)
79-
.PHONY: test-browser
80-
81-
# Test in Sauce Labs. Note that you must set the SAUCE_USERNAME and
82-
# SAUCE_ACCESS_KEY environment variables using your Sauce Labs credentials.
83-
test-sauce: node_modules build.js
84-
@$(DUOT) saucelabs $(TESTS_DIR) \
85-
--name analytics.js-integrations \
86-
--browsers $(BROWSER) \
87-
--user $(SAUCE_USERNAME) \
88-
--key $(SAUCE_ACCESS_KEY)
89-
.PHONY: test-sauce
90-
91-
# Test shortcut.
92-
test: lint test-phantomjs
77+
# Default test target.
78+
test: lint test-browser
9379
.PHONY: test
80+
.DEFAULT_GOAL = test

Readme.md renamed to README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Drift integration for [Analytics.js][].
44

55
## License
66

7-
Released under the [MIT license](License.md).
7+
Released under the [MIT license](LICENSE).
88

99

1010
[Analytics.js]: https://segment.com/docs/libraries/analytics.js/

circle.yml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
11
machine:
22
node:
3-
version: 0.12
3+
version: 4
4+
environment:
5+
NPM_CONFIG_PROGRESS: false
6+
NPM_CONFIG_SPIN: false
7+
SAUCE_ACCESS_KEY: 80dcffc2-c9a2-45e2-9fb7-87b29a6cd986
8+
SAUCE_USERNAME: segment-oss
9+
TEST_REPORTS_DIR: $CIRCLE_TEST_REPORTS
10+
411
dependencies:
512
pre:
6-
- 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
7-
- npm install -g npm@'>=2.7.0'
8-
- make
13+
- npm config set "//registry.npmjs.org/:_authToken" $NPM_AUTH
14+
- npm -g install codecov
15+
override:
16+
- make install
17+
918
test:
1019
override:
1120
- make test
21+
post:
22+
- cp -R coverage $CIRCLE_ARTIFACTS/
23+
- codecov
24+
25+
deployment:
26+
publish:
27+
owner: segment-integrations
28+
# Works on e.g. `1.0.0-alpha.1`
29+
tag: /[0-9]+(\.[0-9]+)*(-.+)?/
30+
commands:
31+
- npm publish .

component.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

karma.conf.ci.js

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/* eslint-env node */
2+
'use strict';
3+
4+
var baseConfig = require('./karma.conf');
5+
6+
var customLaunchers = {
7+
sl_chrome_latest: {
8+
base: 'SauceLabs',
9+
browserName: 'chrome',
10+
platform: 'linux',
11+
version: 'latest'
12+
},
13+
sl_chrome_latest_1: {
14+
base: 'SauceLabs',
15+
browserName: 'chrome',
16+
platform: 'linux',
17+
version: 'latest-1'
18+
},
19+
sl_firefox_latest: {
20+
base: 'SauceLabs',
21+
browserName: 'firefox',
22+
platform: 'linux',
23+
version: 'latest'
24+
},
25+
sl_firefox_latest_1: {
26+
base: 'SauceLabs',
27+
browserName: 'firefox',
28+
platform: 'linux',
29+
version: 'latest-1'
30+
},
31+
sl_safari_9: {
32+
base: 'SauceLabs',
33+
browserName: 'safari',
34+
version: '9.0'
35+
},
36+
// FIXME(ndhoule): Bad IE7/8 support in testing packages make these fail
37+
// sl_ie_7: {
38+
// base: 'SauceLabs',
39+
// browserName: 'internet explorer',
40+
// version: '7'
41+
// },
42+
// sl_ie_8: {
43+
// base: 'SauceLabs',
44+
// browserName: 'internet explorer',
45+
// version: '8'
46+
// },
47+
sl_ie_9: {
48+
base: 'SauceLabs',
49+
browserName: 'internet explorer',
50+
version: '9'
51+
},
52+
sl_ie_10: {
53+
base: 'SauceLabs',
54+
browserName: 'internet explorer',
55+
version: '10'
56+
},
57+
sl_ie_11: {
58+
base: 'SauceLabs',
59+
browserName: 'internet explorer',
60+
version: '11'
61+
},
62+
sl_edge_latest: {
63+
base: 'SauceLabs',
64+
browserName: 'microsoftedge'
65+
}
66+
};
67+
68+
module.exports = function(config) {
69+
baseConfig(config);
70+
71+
if (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) {
72+
throw new Error('SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables are required but are missing');
73+
}
74+
75+
config.set({
76+
browserDisconnectTolerance: 1,
77+
78+
singleRun: true,
79+
80+
reporters: ['progress', 'junit', 'coverage'],
81+
82+
browsers: ['PhantomJS'].concat(Object.keys(customLaunchers)),
83+
84+
customLaunchers: customLaunchers,
85+
86+
junitReporter: {
87+
outputDir: process.env.TEST_REPORTS_DIR,
88+
suite: require('./package.json').name
89+
},
90+
91+
sauceLabs: {
92+
testName: require('./package.json').name
93+
},
94+
95+
coverageReporter: {
96+
reporters: [
97+
{ type: 'lcov' }
98+
]
99+
}
100+
});
101+
};

0 commit comments

Comments
 (0)