Skip to content

Commit ce541a6

Browse files
authored
Build: Switch to GitHub Actions & Karma tests, modernize a few things
Changes: * Switch from Travis to GitHub Actions. * Switch from a broken BrowserStack runner setup to Karma tests. * Switch from bower & bowercopy to npm & npmcopy. For some reason, jQuery 1.7.2 was not working under this new setup so it was dropped. jQuery versions older than 1.11/2.1 are loaded from the `jquery-dist` repository as they're not available on npm Closes gh-131
1 parent 7f87d20 commit ce541a6

File tree

20 files changed

+17986
-15420
lines changed

20 files changed

+17986
-15420
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
bower_component/**
21
dist/**
32
external/**
43
node_modules/**

.eslintrc.json

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
{
22
"extends": "eslint-config-jquery",
3+
34
"root": true,
5+
6+
"parserOptions": {
7+
"ecmaVersion": 2018
8+
},
9+
10+
"env": {
11+
"es6": true,
12+
"node": true
13+
},
14+
415
"rules": {
516

617
// Increase max-len to 150 for now, there are too many violations and the rule
@@ -13,13 +24,41 @@
1324
}
1425
]
1526
},
16-
"env": {
17-
"node": true
18-
},
27+
1928
"globals": {
2029
"jQuery": true,
2130
"define": true,
2231
"require": true,
2332
"module": true
24-
}
33+
},
34+
35+
"overrides": [
36+
{
37+
"files": [
38+
"jquery.color.*",
39+
"test/data/*.js",
40+
"test/unit/*.js"
41+
],
42+
"parserOptions": {
43+
"ecmaVersion": 3
44+
},
45+
"env": {
46+
"es6": false,
47+
"browser": true,
48+
"node": false
49+
}
50+
},
51+
52+
{
53+
"files": [ "test/karma/*.js" ],
54+
"parserOptions": {
55+
"ecmaVersion": 2018
56+
},
57+
"env": {
58+
"es6": true,
59+
"browser": false,
60+
"node": true
61+
}
62+
}
63+
]
2564
}

.github/workflows/node.js.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
# Node.js 10 is required by jQuery infra
12+
NODE_VERSION: [10.x, 16.x]
13+
NPM_SCRIPT: ["ci"]
14+
include:
15+
- NAME: "Browser tests"
16+
NODE_VERSION: "16.x"
17+
NPM_SCRIPT: "browserstack"
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
22+
- name: Cache
23+
uses: actions/cache@v2
24+
with:
25+
path: ~/.npm
26+
key: ${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-npm-lock-${{ hashFiles('**/package-lock.json') }}
27+
restore-keys: |
28+
${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-npm-lock-
29+
30+
- name: Use Node.js ${{ matrix.NODE_VERSION }}
31+
uses: actions/[email protected]
32+
with:
33+
node-version: ${{ matrix.NODE_VERSION }}
34+
35+
- name: Install dependencies
36+
run: |
37+
npm install
38+
39+
- name: Run tests
40+
env:
41+
BROWSER_STACK_USERNAME: ${{ secrets.BROWSER_STACK_USERNAME }}
42+
BROWSER_STACK_ACCESS_KEY: ${{ secrets.BROWSER_STACK_ACCESS_KEY }}
43+
run: |
44+
export PATH=${HOME}/firefox:$PATH
45+
npm run ${{ matrix.NPM_SCRIPT }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.sizecache.json
2-
/bower_components
32
/dist
43
/node_modules
54
/package-lock.json
5+
/*.log
6+
/*.err

.travis.yml

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

Gruntfile.js

Lines changed: 94 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,40 @@
1-
module.exports = function( grunt ) {
1+
module.exports = grunt => {
22

33
"use strict";
44

5-
var max = [ "dist/jquery.color.js", "dist/jquery.color.svg-names.js" ],
6-
min = [ "dist/jquery.color.min.js", "dist/jquery.color.svg-names.min.js", "dist/jquery.color.plus-names.min.js" ],
7-
combined = "dist/jquery.color.plus-names.js",
8-
minify = {
9-
main: {
10-
options: {
11-
banner: "/*! jQuery Color v<%= pkg.version %> http://github.com/jquery/jquery-color | jquery.org/license */\n"
12-
},
13-
files: {}
5+
const isBrowserStack = !!( process.env.BROWSER_STACK_USERNAME &&
6+
process.env.BROWSER_STACK_ACCESS_KEY );
7+
const max = [
8+
"dist/jquery.color.js",
9+
"dist/jquery.color.svg-names.js"
10+
];
11+
const min = [
12+
"dist/jquery.color.min.js",
13+
"dist/jquery.color.svg-names.min.js",
14+
"dist/jquery.color.plus-names.min.js"
15+
];
16+
const combined = "dist/jquery.color.plus-names.js";
17+
const minify = {
18+
main: {
19+
options: {
20+
banner: "/*! jQuery Color v<%= pkg.version %> http://github.com/jquery/jquery-color | jquery.org/license */\n"
1421
},
15-
svg: {
16-
options: {
17-
banner: "/*! jQuery Color v<%= pkg.version %> SVG Color Names http://github.com/jquery/jquery-color | jquery.org/license */\n"
18-
},
19-
files: {}
22+
files: {}
23+
},
24+
svg: {
25+
options: {
26+
banner: "/*! jQuery Color v<%= pkg.version %> SVG Color Names http://github.com/jquery/jquery-color | jquery.org/license */\n"
2027
},
21-
combined: {
22-
options: {
23-
banner: "/*! jQuery Color v<%= pkg.version %> with SVG Color Names http://github.com/jquery/jquery-color | jquery.org/license */\n"
24-
},
25-
files: {}
26-
}
28+
files: {}
2729
},
28-
concat = {};
30+
combined: {
31+
options: {
32+
banner: "/*! jQuery Color v<%= pkg.version %> with SVG Color Names http://github.com/jquery/jquery-color | jquery.org/license */\n"
33+
},
34+
files: {}
35+
}
36+
};
37+
const concat = {};
2938

3039
minify.main.files[ min[ 0 ] ] = [ max[ 0 ] ];
3140
minify.svg.files[ min[ 1 ] ] = [ max[ 1 ] ];
@@ -64,7 +73,7 @@ grunt.initConfig( {
6473
]
6574
},
6675

67-
bowercopy: {
76+
npmcopy: {
6877
all: {
6978
options: {
7079
destPrefix: "external"
@@ -74,9 +83,6 @@ grunt.initConfig( {
7483
"qunit/qunit.css": "qunit/qunit/qunit.css",
7584
"qunit/LICENSE.txt": "qunit/LICENSE.txt",
7685

77-
"jquery-1.7.2/jquery.js": "jquery-1.7.2/jquery.js",
78-
"jquery-1.7.2/MIT-LICENSE.txt": "jquery-1.7.2/MIT-LICENSE.txt",
79-
8086
"jquery-1.8.3/jquery.js": "jquery-1.8.3/jquery.js",
8187
"jquery-1.8.3/MIT-LICENSE.txt": "jquery-1.8.3/MIT-LICENSE.txt",
8288

@@ -120,7 +126,10 @@ grunt.initConfig( {
120126
"jquery-3.5.1/LICENSE.txt": "jquery-3.5.1/LICENSE.txt",
121127

122128
"jquery-3.6.0/jquery.js": "jquery-3.6.0/dist/jquery.js",
123-
"jquery-3.6.0/LICENSE.txt": "jquery-3.6.0/LICENSE.txt"
129+
"jquery-3.6.0/LICENSE.txt": "jquery-3.6.0/LICENSE.txt",
130+
131+
"jquery/jquery.js": "jquery/dist/jquery.js",
132+
"jquery/LICENSE.txt": "jquery/LICENSE.txt"
124133
}
125134
}
126135
},
@@ -143,6 +152,42 @@ grunt.initConfig( {
143152
}
144153
},
145154

155+
karma: {
156+
options: {
157+
configFile: "test/karma/karma.conf.js",
158+
singleRun: true
159+
},
160+
local: {
161+
browsers: [ "ChromeHeadless", "FirefoxHeadless" ]
162+
},
163+
"browserstack-current": {
164+
browsers: [
165+
"bs_chrome-current",
166+
"bs_firefox-current",
167+
"bs_edge-current",
168+
"bs_ie-11",
169+
"bs_opera",
170+
"bs_safari-current",
171+
"bs_ios-current",
172+
"bs_android"
173+
]
174+
},
175+
"browserstack-legacy": {
176+
browsers: [
177+
"bs_chrome-previous",
178+
"bs_firefox-esr",
179+
"bs_firefox-previous",
180+
"bs_edge-18",
181+
"bs_edge-previous",
182+
"bs_ie-9",
183+
"bs_ie-10",
184+
"bs_safari-previous",
185+
"bs_ios-two_versions_back",
186+
"bs_ios-previous"
187+
]
188+
}
189+
},
190+
146191
qunit: {
147192
files: "test/index.html",
148193
options: {
@@ -181,8 +226,8 @@ function gitDate( fn ) {
181226
}
182227

183228
grunt.registerTask( "max", function() {
184-
var done = this.async(),
185-
version = grunt.config( "pkg.version" );
229+
const done = this.async();
230+
let version = grunt.config( "pkg.version" );
186231

187232
if ( process.env.COMMIT ) {
188233
version += " " + process.env.COMMIT;
@@ -209,10 +254,10 @@ grunt.registerTask( "max", function() {
209254

210255
grunt.registerTask( "testswarm", function( commit, configFile, projectName, browserSets,
211256
timeout ) {
212-
var config, tests,
213-
testswarm = require( "testswarm" ),
214-
runs = {},
215-
done = this.async();
257+
let config, tests;
258+
const testswarm = require( "testswarm" );
259+
const runs = {};
260+
const done = this.async();
216261

217262
projectName = projectName || "jquerycolor";
218263
config = grunt.file.readJSON( configFile )[ projectName ];
@@ -228,7 +273,7 @@ grunt.registerTask( "testswarm", function( commit, configFile, projectName, brow
228273
Array.isArray( browserSets ) ? browserSets[ 0 ] : browserSets ||
229274
"jquery" ];
230275

231-
tests.forEach( function( jQueryVersion ) {
276+
tests.forEach( jQueryVersion => {
232277
runs[ jQueryVersion ] = config.testUrl + commit +
233278
"/test/index.html?jquery=" + jQueryVersion;
234279
} );
@@ -248,7 +293,7 @@ grunt.registerTask( "testswarm", function( commit, configFile, projectName, brow
248293
runMax: config.runMax,
249294
browserSets: browserSets,
250295
timeout: timeout
251-
}, function( err, passed ) {
296+
}, ( err, passed ) => {
252297
if ( err ) {
253298
grunt.log.error( err );
254299
}
@@ -257,14 +302,27 @@ grunt.registerTask( "testswarm", function( commit, configFile, projectName, brow
257302
);
258303
} );
259304

305+
grunt.registerTask( "print_no_browserstack_legacy_message", () => {
306+
grunt.log.writeln( "No BrowserStack credentials detected, running " +
307+
"tests on legacy browsers skipped..." );
308+
} );
309+
260310
grunt.registerTask( "default", [
261311
"eslint",
262-
"bowercopy",
312+
"npmcopy",
263313
"qunit",
264314
"build",
265315
"compare_size"
266316
] );
267317
grunt.registerTask( "build", [ "max", "concat", "uglify" ] );
268318
grunt.registerTask( "ci", [ "eslint", "qunit" ] );
319+
grunt.registerTask( "karma-browserstack-current", [
320+
"build",
321+
isBrowserStack ? "karma:browserstack-current" : "karma:local"
322+
] );
323+
grunt.registerTask( "karma-browserstack-legacy", isBrowserStack ? [
324+
"build",
325+
"karma:browserstack-legacy"
326+
] : [ "print_no_browserstack_legacy_message" ] );
269327

270328
};

bower.json

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,5 @@
1414
"Gruntfile.js",
1515
"external",
1616
"test"
17-
],
18-
"devDependencies": {
19-
"qunit": "2.10.0",
20-
"jquery-1.7.2": "jquery#1.7.2",
21-
"jquery-1.8.3": "jquery#1.8.3",
22-
"jquery-1.9.1": "jquery#1.9.1",
23-
"jquery-1.10.2": "jquery#1.10.2",
24-
"jquery-1.11.3": "jquery#1.11.3",
25-
"jquery-1.12.4": "jquery#1.12.4",
26-
"jquery-2.0.3": "jquery#2.0.3",
27-
"jquery-2.1.4": "jquery#2.1.4",
28-
"jquery-2.2.4": "jquery#2.2.4",
29-
"jquery-3.0.0": "jquery#3.0.0",
30-
"jquery-3.1.1": "jquery#3.1.1",
31-
"jquery-3.2.1": "jquery#3.2.1",
32-
"jquery-3.3.1": "jquery#3.3.1",
33-
"jquery-3.4.1": "jquery#3.4.1",
34-
"jquery-3.5.1": "jquery#3.5.1",
35-
"jquery-3.6.0": "jquery#3.6.0"
36-
}
17+
]
3718
}

build/run-browserstack.sh

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

0 commit comments

Comments
 (0)