Skip to content

Commit 6a8e588

Browse files
authored
Housekeeping, remove PhantomJS + use headless chrome (#125)
1 parent ea20d64 commit 6a8e588

File tree

8 files changed

+19961
-14868
lines changed

8 files changed

+19961
-14868
lines changed

.circleci/config.yml

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: 2
22
jobs:
33
build:
44
docker:
5-
- image: circleci/node:8-browsers
5+
- image: circleci/node:14-browsers
66
steps:
77
- checkout
88
- run: npm config set "//registry.npmjs.org/:_authToken" $NPM_AUTH
@@ -14,28 +14,32 @@ jobs:
1414
NPM_CONFIG_PROGRESS: false
1515
NPM_CONFIG_SPIN: false
1616
TEST_REPORTS_DIR: $CIRCLE_TEST_REPORTS
17-
publish:
18-
docker:
19-
- image: circleci/node:8-browsers
20-
steps:
21-
- checkout
22-
- run: make build
23-
- run: npm config set "//registry.npmjs.org/:_authToken" $NPM_AUTH
24-
- run: npm publish .
2517

26-
workflows:
27-
version: 2
28-
test_and_publish:
29-
jobs:
30-
- build:
31-
filters:
32-
tags:
33-
only: /.*/
34-
- publish:
35-
requires:
36-
- build
37-
filters:
38-
tags:
39-
only: /[0-9]+(\.[0-9]+)*(-.+)?/
40-
branches:
41-
ignore: /.*/
18+
19+
# Disabling because people seem to be publishing manually for the last few years.
20+
# We are no longer using CircleCI as a company (and I think we'd need a to set a new npm automation token).
21+
22+
# publish:
23+
# docker:
24+
# - image: circleci/node:14-browsers
25+
# steps:
26+
# - checkout
27+
# - run: make build
28+
# - run: npm config set "//registry.npmjs.org/:_authToken" $NPM_AUTH
29+
# - run: npm publish .
30+
# workflows:
31+
# version: 2
32+
# test_and_publish:
33+
# jobs:
34+
# - build:
35+
# filters:
36+
# tags:
37+
# only: /.*/
38+
# - publish:
39+
# requires:
40+
# - build
41+
# filters:
42+
# tags:
43+
# only: /[0-9]+(\.[0-9]+)*(-.+)?/
44+
# branches:
45+
# ignore: /.*/

Makefile

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
##
44

55
ESLINT := node_modules/.bin/eslint
6-
ISTANBUL := node_modules/.bin/istanbul
76
KARMA := node_modules/.bin/karma
87
MATCHA := node_modules/.bin/matcha
98
MOCHA := node_modules/.bin/mocha
@@ -47,20 +46,13 @@ MOCHA_FLAGS := \
4746
--reporter "$(MOCHA_REPORTER)" \
4847
--ui bdd
4948

50-
# Istanbul flags.
51-
COVERAGE_DIR ?= coverage
52-
ISTANBUL_FLAGS := \
53-
--root "./lib" \
54-
--include-all-sources true \
55-
--dir "$(COVERAGE_DIR)/Node $(shell node -v)"
56-
5749
##
5850
# Tasks
5951
##
6052

6153
# Install node modules.
6254
node_modules: package.json $(wildcard node_modules/*/package.json)
63-
@npm install
55+
@npm ci
6456
@touch $@
6557

6658
# Install dependencies.
@@ -96,7 +88,7 @@ bench: install build
9688

9789
# Run unit tests in node.
9890
test-node: install build
99-
@NODE_ENV=test $(ISTANBUL) cover $(ISTANBUL_FLAGS) $(_MOCHA) -- $(MOCHA_FLAGS) test/render.test.js
91+
@NODE_ENV=test $(_MOCHA) -- $(MOCHA_FLAGS) test/render.test.js
10092
.PHONY: test-node
10193

10294
# Run browser unit tests in a browser.
@@ -105,6 +97,6 @@ test-browser: install build
10597
.PHONY: test-browser
10698

10799
# Default test target.
108-
test: lint bench test-node test-browser
100+
test: bench test-node test-browser
109101
.PHONY: test
110102
.DEFAULT_GOAL = test

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,22 @@ Returns the maxified version of the analytics.js snippet given a set of `options
5151
### snippet.min(options)
5252

5353
Returns the minified version of the snippet.
54+
55+
56+
## Development
57+
58+
### Installation + Running Tests
59+
```
60+
nvm use
61+
make install
62+
make test
63+
```
64+
65+
## Publishing to `npm`
66+
```
67+
git co master
68+
make build
69+
npm version <patch|minor|major>
70+
git push --follow-tags
71+
npm publish
72+
```

karma.conf.ci.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module.exports = function(config) {
5858

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

61-
browsers: ['PhantomJS'].concat(Object.keys(customLaunchers)),
61+
browsers: Object.keys(customLaunchers),
6262

6363
customLaunchers: customLaunchers,
6464

karma.conf.js

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
/* eslint-env node */
22
'use strict';
3+
const { chromium } = require('playwright-chromium')
4+
5+
process.env.CHROME_BIN = chromium.executablePath()
36

47
module.exports = function(config) {
58
config.set({
9+
autoWatch: false,
10+
singleRun: true,
611
files: [
712
// https://app.segment.com/segment-libraries/sources/snippet/settings/keys
813
'https://cdn.segment.com/analytics.js/v1/zCueSsEKipbrRgqbJarlTG8UJsAZWpkm/analytics.js',
914
'test/**/*.test.js'
1015
],
1116

12-
browsers: ['PhantomJS'],
17+
browsers: ['ChromeHeadless'],
1318

1419
frameworks: ['browserify', 'mocha'],
1520

16-
reporters: ['spec', 'coverage'],
17-
21+
reporters: ['spec'],
22+
1823
preprocessors: {
19-
'test/**/*.js': 'browserify'
24+
'test/**/*.js': ['browserify']
2025
},
21-
2226
client: {
2327
mocha: {
2428
grep: process.env.GREP,
@@ -27,28 +31,6 @@ module.exports = function(config) {
2731
}
2832
},
2933

30-
browserify: {
31-
debug: true,
32-
transform: [
33-
[
34-
'browserify-istanbul',
35-
{
36-
instrumenterConfig: {
37-
embedSource: true
38-
}
39-
}
40-
]
41-
]
42-
},
43-
44-
coverageReporter: {
45-
reporters: [
46-
{ type: 'text' },
47-
{ type: 'html' },
48-
{ type: 'json' }
49-
]
50-
},
51-
5234
plugins: [
5335
'karma-*'
5436
]

0 commit comments

Comments
 (0)