Skip to content

Commit d02a04c

Browse files
authored
Travis ci migrate (#116)
* Remove codacy and inline references * Update travis CI to use cross platform support. * update dependencies to latest. * Add browser tests to travis build. * update from single to double quotes for karma.conf.js * Normalize line endings to LF. * increase mocha timeout for sauce labs. * add attribution badges
1 parent 4fff285 commit d02a04c

6 files changed

Lines changed: 663 additions & 1157 deletions

File tree

.travis.yml

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,64 @@
33
# https://docs.travis-ci.com/user/customizing-the-build/
44
# https://docs.travis-ci.com/user/migrating-from-legacy/
55

6-
dist: trusty
7-
sudo: required # Required for headless Chrome
6+
filter_secrets: false
87
language: node_js
98

10-
addons:
11-
firefox: latest
12-
chrome: stable
9+
node_js:
10+
- 10
11+
- 8
12+
- 6
1313

14-
matrix:
15-
include:
16-
# Node 10 + Browser tests
17-
- node_js: 10
18-
env: KARMA=true
19-
20-
# Node 8 + SauceLabs tests
21-
- node_js: 8
22-
env: KARMA=true SAUCE=true
23-
24-
# Node 6 tests
25-
- node_js: 6
14+
os:
15+
- linux
16+
- osx
17+
- windows
2618

2719
before_script:
28-
# Setup a virtual display for browser testing
29-
- export DISPLAY=:99.0
30-
- sh -e /etc/init.d/xvfb start
20+
- npm run lint
3121

32-
script: npm run lint && npm run test:typescript && npm run coverage
22+
script:
23+
- npm run test:typescript
24+
- npm run coverage:node
3325

3426
after_success:
3527
# concatenate all code-coverage data into a single file
3628
- ls -R1 coverage/*/lcov.info
3729
- cat coverage/*/lcov.info > ./coverage/lcov.info
3830

39-
# send code-coverage data to Codacy
40-
- cat ./coverage/lcov.info | node_modules/.bin/codacy-coverage -p .
41-
4231
# send code-coverage data to Coveralls
4332
- cat ./coverage/lcov.info | node_modules/coveralls/bin/coveralls.js
33+
34+
jobs:
35+
include:
36+
- name: Browser tests (Linux)
37+
os: linux
38+
script: npm run coverage:browser
39+
addons:
40+
firefox: latest
41+
chrome: stable
42+
43+
- name: Browser tests (Mac)
44+
os: osx
45+
script: npm run coverage:browser
46+
addons:
47+
firefox: latest
48+
chrome: stable
49+
50+
- name: Browser tests (Windows via SauceLabs)
51+
os: linux
52+
script: npm run coverage:browser
53+
env: WINDOWS=true
54+
55+
- stage: Deploy
56+
name: Publish to npm
57+
script: npm run build
58+
after_success: true
59+
deploy:
60+
provider: npm
61+
email: $NPM_EMAIL
62+
api_key: $NPM_API_KEY
63+
skip_cleanup: true
64+
on:
65+
tags: true
66+
branch: master

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ JSON Schema $Ref Parser
22
============================
33
#### Parse, Resolve, and Dereference JSON Schema $ref pointers
44

5-
[![Build Status](https://api.travis-ci.org/APIDevTools/json-schema-ref-parser.svg?branch=master)](https://travis-ci.org/APIDevTools/json-schema-ref-parser)
6-
[![Dependencies](https://david-dm.org/APIDevTools/json-schema-ref-parser.svg)](https://david-dm.org/APIDevTools/json-schema-ref-parser)
5+
[![Build Status](https://api.travis-ci.com/APIDevTools/json-schema-ref-parser.svg?branch=master)](https://travis-ci.com/APIDevTools/json-schema-ref-parser)
76
[![Coverage Status](https://coveralls.io/repos/github/APIDevTools/json-schema-ref-parser/badge.svg?branch=master)](https://coveralls.io/github/APIDevTools/json-schema-ref-parser)
8-
[![Codacy Score](https://api.codacy.com/project/badge/d8abfe5e9a4044b89bd9f4b999d4a574)](https://www.codacy.com/public/JamesMessinger/json-schema-ref-parser)
9-
[![Inline docs](https://inch-ci.org/github/APIDevTools/json-schema-ref-parser.svg?branch=master&style=shields)](https://inch-ci.org/github/APIDevTools/json-schema-ref-parser)
107

118
[![npm](https://img.shields.io/npm/v/json-schema-ref-parser.svg)](https://www.npmjs.com/package/json-schema-ref-parser)
9+
[![Dependencies](https://david-dm.org/APIDevTools/json-schema-ref-parser.svg)](https://david-dm.org/APIDevTools/json-schema-ref-parser)
1210
[![License](https://img.shields.io/npm/l/json-schema-ref-parser.svg)](LICENSE)
1311

14-
[![Browser Compatibility](https://saucelabs.com/browser-matrix/json-schema-parser.svg)](https://saucelabs.com/u/json-schema-parser)
12+
13+
[![OS and Browser Compatibility](https://apidevtools.org/img/badges/ci-badges-with-ie.svg)](https://travis-ci.com/APIDevTools/json-schema-ref-parser)
1514

1615

1716
The Problem:
@@ -149,3 +148,11 @@ To build/test the project locally on your computer:
149148
License
150149
--------------------------
151150
JSON Schema $Ref Parser is 100% free and open-source, under the [MIT license](LICENSE). Use it however you want.
151+
152+
Big Thanks To
153+
--------------------------
154+
Thanks to these awesome companies for their support of Open Source developers ❤
155+
156+
[![Travis CI](https://jsdevtools.org/img/badges/travis-ci.svg)](https://travis-ci.com)
157+
[![SauceLabs](https://jsdevtools.org/img/badges/sauce-labs.svg)](https://saucelabs.com)
158+
[![Coveralls](https://jsdevtools.org/img/badges/coveralls.svg)](https://coveralls.io)

karma.conf.js

Lines changed: 68 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,60 @@
11
// Karma config
22
// https://karma-runner.github.io/0.12/config/configuration-file.html
3-
'use strict';
4-
3+
"use strict";
54

65
module.exports = function (karma) {
76
var config = {
8-
frameworks: ['mocha', 'chai', 'host-environment'],
9-
reporters: ['verbose'],
7+
frameworks: ["mocha", "chai", "host-environment"],
8+
reporters: ["verbose"],
109

1110
files: [
1211
// Polyfills for older browsers
13-
'test/polyfills/promise.js',
14-
'test/polyfills/typedarray.js',
12+
"test/polyfills/promise.js",
13+
"test/polyfills/typedarray.js",
1514

1615
// Json Schema $Ref Parser
17-
'dist/ref-parser.min.js',
18-
{ pattern: 'dist/*.map', included: false, served: true },
16+
"dist/ref-parser.min.js",
17+
{ pattern: "dist/*.map", included: false, served: true },
1918

2019
// Test Fixtures
21-
'test/fixtures/**/*.js',
20+
"test/fixtures/**/*.js",
2221

2322
// Test Specs
24-
'test/specs/**/*.parsed.js',
25-
'test/specs/**/*.dereferenced.js',
26-
'test/specs/**/*.bundled.js',
27-
'test/specs/**/*.spec.js',
28-
{ pattern: 'test/specs/**', included: false, served: true }
23+
"test/specs/**/*.parsed.js",
24+
"test/specs/**/*.dereferenced.js",
25+
"test/specs/**/*.bundled.js",
26+
"test/specs/**/*.spec.js",
27+
{ pattern: "test/specs/**", included: false, served: true }
2928
]
3029
};
3130

32-
exitIfDisabled();
3331
configureCodeCoverage(config);
34-
configureLocalBrowsers(config);
35-
configureSauceLabs(config);
32+
configureBrowsers(config);
3633

37-
console.log('Karma Config:\n', JSON.stringify(config, null, 2));
34+
console.log("Karma Config:\n", JSON.stringify(config, null, 2));
3835
karma.set(config);
3936
};
4037

41-
/**
42-
* If this is a CI job, and Karma is not enabled, then exit.
43-
* (useful for CI jobs that are only testing Node.js, not web browsers)
44-
*/
45-
function exitIfDisabled () {
46-
var CI = process.env.CI === 'true';
47-
var KARMA = process.env.KARMA === 'true';
48-
49-
if (CI && !KARMA) {
50-
console.warn('Karma is not enabled');
51-
process.exit();
52-
}
53-
}
54-
5538
/**
5639
* Configures the code-coverage reporter
5740
*/
5841
function configureCodeCoverage (config) {
59-
if (process.argv.indexOf('--coverage') === -1) {
60-
console.warn('Code-coverage is not enabled');
61-
return;
62-
}
63-
else if (process.env.SAUCE === 'true') {
64-
// Code coverage causes sporadic failures on SauceLabs
65-
// https://github.com/karma-runner/karma-sauce-launcher/issues/95#issuecomment-255020888
66-
console.warn('Code-coverage is disabled for SauceLabs');
42+
if (process.argv.indexOf("--coverage") === -1) {
43+
console.warn("Code-coverage is not enabled");
6744
return;
6845
}
6946

70-
config.reporters.push('coverage');
47+
config.reporters.push("coverage");
7148
config.coverageReporter = {
7249
reporters: [
73-
{ type: 'text-summary' },
74-
{ type: 'lcov' }
50+
{ type: "text-summary" },
51+
{ type: "lcov" }
7552
]
7653
};
7754

7855
config.files = config.files.map(function (file) {
79-
if (typeof file === 'string') {
80-
file = file.replace(/^dist\/(.*)\.min\.js$/, 'dist/$1.coverage.js');
56+
if (typeof file === "string") {
57+
file = file.replace(/^dist\/(.*)\.min\.js$/, "dist/$1.coverage.js");
8158
}
8259
return file;
8360
});
@@ -86,19 +63,32 @@ function configureCodeCoverage (config) {
8663
/**
8764
* Configures the browsers for the current platform
8865
*/
89-
function configureLocalBrowsers (config) {
90-
var isMac = /^darwin/.test(process.platform);
91-
var isWindows = /^win/.test(process.platform);
92-
var isLinux = !isMac && !isWindows;
93-
94-
if (isMac) {
95-
config.browsers = ['Firefox', 'Chrome', 'Safari'];
66+
function configureBrowsers (config) {
67+
let isWindows = /^win/.test(process.platform) || process.env.WINDOWS === "true";
68+
let isMac = /^darwin/.test(process.platform);
69+
let isLinux = !isMac && !isWindows;
70+
let isCI = process.env.CI === "true";
71+
72+
if (isCI) {
73+
if (isWindows) {
74+
// IE and Edge aren't available in CI, so use SauceLabs
75+
configureSauceLabs(config);
76+
}
77+
else if (isMac) {
78+
config.browsers = ["FirefoxHeadless", "ChromeHeadless", "Safari"];
79+
}
80+
else if (isLinux) {
81+
config.browsers = ["FirefoxHeadless", "ChromeHeadless"];
82+
}
83+
}
84+
else if (isMac) {
85+
config.browsers = ["Firefox", "Chrome", "Safari"];
9686
}
9787
else if (isLinux) {
98-
config.browsers = ['Firefox', 'ChromeHeadless'];
88+
config.browsers = ["Firefox", "Chrome"];
9989
}
10090
else if (isWindows) {
101-
config.browsers = ['Firefox', 'Chrome', 'IE', 'Edge'];
91+
config.browsers = ["Firefox", "Chrome", "IE", "Edge"];
10292
}
10393
}
10494

@@ -107,79 +97,52 @@ function configureLocalBrowsers (config) {
10797
* https://github.com/karma-runner/karma-sauce-launcher
10898
*/
10999
function configureSauceLabs (config) {
110-
var SAUCE = process.env.SAUCE === 'true';
111-
var username = process.env.SAUCE_USERNAME;
112-
var accessKey = process.env.SAUCE_ACCESS_KEY;
100+
let username = process.env.SAUCE_USERNAME;
101+
let accessKey = process.env.SAUCE_ACCESS_KEY;
113102

114-
if (!SAUCE || !username || !accessKey) {
115-
console.warn('SauceLabs is not enabled');
116-
return;
103+
if (!username || !accessKey) {
104+
throw new Error(`SAUCE_USERNAME and/or SAUCE_ACCESS_KEY is not set`);
117105
}
118106

119-
var project = require('./package.json');
120-
var testName = project.name + ' v' + project.version;
121-
var build = testName + ' Build #' + process.env.TRAVIS_JOB_NUMBER + ' @ ' + new Date();
107+
let project = require("./package.json");
122108

123109
config.sauceLabs = {
124-
build: build,
125-
testName: testName,
110+
build: `${project.name} v${project.version} Build #${process.env.TRAVIS_JOB_NUMBER}`,
111+
testName: `${project.name} v${project.version}`,
126112
tags: [project.name],
127113
};
128114

129115
config.customLaunchers = {
130-
SauceLabs_IE_11: {
131-
base: 'SauceLabs',
132-
platform: 'Windows 10',
133-
browserName: 'internet explorer'
134-
},
135-
SauceLabs_IE_Edge: {
136-
base: 'SauceLabs',
137-
platform: 'Windows 10',
138-
browserName: 'microsoftedge'
139-
},
140-
141-
// TODO FIXME TODO FIXME TODO FIXME TODO FIXME TODO FIXME TODO FIXME TODO
142-
// ======================================================================
143-
// I've temporarily commented-out Safari on Mac because SauceLabs seems to
144-
// be having problems with their Mac VMs right now.
145-
// https://travis-ci.org/APIDevTools/json-schema-ref-parser/jobs/440110398#L1169-L1194
146-
// ======================================================================
147-
// SauceLabs_Safari_Latest: {
148-
// base: 'SauceLabs',
149-
// platform: 'macOS 10.13',
150-
// browserName: 'safari'
151-
// },
152-
153-
SauceLabs_Chrome_Latest: {
154-
base: 'SauceLabs',
155-
platform: 'Windows 10',
156-
browserName: 'chrome'
116+
IE_11: {
117+
base: "SauceLabs",
118+
platform: "Windows 7",
119+
browserName: "internet explorer"
157120
},
158-
SauceLabs_Firefox_Latest: {
159-
base: 'SauceLabs',
160-
platform: 'Windows 10',
161-
browserName: 'firefox'
121+
Edge: {
122+
base: "SauceLabs",
123+
platform: "Windows 10",
124+
browserName: "microsoftedge"
162125
},
163126
};
164127

165-
config.reporters.push('saucelabs');
128+
config.reporters.push("saucelabs");
166129
config.browsers = Object.keys(config.customLaunchers);
167-
config.concurrency = 1;
130+
// config.concurrency = 1;
168131
config.captureTimeout = 60000;
169132
config.browserDisconnectTolerance = 5,
170133
config.browserDisconnectTimeout = 60000;
171134
config.browserNoActivityTimeout = 60000;
172-
// config.logLevel = 'debug';
135+
// config.logLevel = "debug";
173136

174137
// The following tests tend to fail on SauceLabs,
175138
// probably due to zero-byte files and special characters in the paths.
176139
// So, exclude these tests when running on SauceLabs.
177140
config.exclude = [
178-
'test/specs/__*/**',
179-
'test/specs/blank/**/*.spec.js',
180-
'test/specs/circular*/**/*.spec.js',
181-
'test/specs/empty/**/*.spec.js',
182-
'test/specs/invalid/**/*.spec.js',
183-
'test/specs/parsers/**/*.spec.js',
141+
"test/specs/__*/**",
142+
"test/specs/blank/**/*.spec.js",
143+
"test/specs/circular*/**/*.spec.js",
144+
"test/specs/empty/**/*.spec.js",
145+
"test/specs/invalid/**/*.spec.js",
146+
"test/specs/parsers/**/*.spec.js"
184147
];
185148
}

0 commit comments

Comments
 (0)