Skip to content

Commit afb83c3

Browse files
committed
Build: Test on Node 10, 16 & 18; fix CI in Node <16
Ref gh-2157
1 parent f36fe9e commit afb83c3

File tree

3 files changed

+121
-97
lines changed

3 files changed

+121
-97
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
node-version: [12.x, 14.x]
15+
# Node.js 10 is required by jQuery infra
16+
node-version: [10.x, 16.x, 18.x]
1617

1718
steps:
1819
- uses: actions/checkout@v3

Gruntfile.js

Lines changed: 119 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -2,92 +2,98 @@
22

33
module.exports = function( grunt ) {
44

5-
var
6-
glob = require( "glob" ),
7-
8-
// files
9-
coreFiles = [
10-
"core.js",
11-
"widget.js",
12-
"widgets/mouse.js",
13-
"widgets/draggable.js",
14-
"widgets/droppable.js",
15-
"widgets/resizable.js",
16-
"widgets/selectable.js",
17-
"widgets/sortable.js",
18-
"effect.js"
19-
],
20-
21-
uiFiles = coreFiles.map( function( file ) {
22-
return "ui/" + file;
23-
} ).concat( expandFiles( "ui/**/*.js" ).filter( function( file ) {
24-
return coreFiles.indexOf( file.substring( 3 ) ) === -1;
25-
} ) ),
26-
27-
allI18nFiles = expandFiles( "ui/i18n/*.js" ),
28-
29-
cssFiles = [
30-
"core",
31-
"accordion",
32-
"autocomplete",
33-
"button",
34-
"checkboxradio",
35-
"controlgroup",
36-
"datepicker",
37-
"dialog",
38-
"draggable",
39-
"menu",
40-
"progressbar",
41-
"resizable",
42-
"selectable",
43-
"selectmenu",
44-
"sortable",
45-
"slider",
46-
"spinner",
47-
"tabs",
48-
"tooltip",
49-
"theme"
50-
].map( function( component ) {
51-
return "themes/base/" + component + ".css";
52-
} ),
53-
54-
// minified files
55-
minify = {
5+
// files
6+
const coreFiles = [
7+
"core.js",
8+
"widget.js",
9+
"widgets/mouse.js",
10+
"widgets/draggable.js",
11+
"widgets/droppable.js",
12+
"widgets/resizable.js",
13+
"widgets/selectable.js",
14+
"widgets/sortable.js",
15+
"effect.js"
16+
];
17+
18+
const uiFiles = coreFiles.map( function( file ) {
19+
return "ui/" + file;
20+
} ).concat( expandFiles( "ui/**/*.js" ).filter( function( file ) {
21+
return coreFiles.indexOf( file.substring( 3 ) ) === -1;
22+
} ) );
23+
24+
const allI18nFiles = expandFiles( "ui/i18n/*.js" );
25+
26+
const cssFiles = [
27+
"core",
28+
"accordion",
29+
"autocomplete",
30+
"button",
31+
"checkboxradio",
32+
"controlgroup",
33+
"datepicker",
34+
"dialog",
35+
"draggable",
36+
"menu",
37+
"progressbar",
38+
"resizable",
39+
"selectable",
40+
"selectmenu",
41+
"sortable",
42+
"slider",
43+
"spinner",
44+
"tabs",
45+
"tooltip",
46+
"theme"
47+
].map( function( component ) {
48+
return "themes/base/" + component + ".css";
49+
} );
50+
51+
// minified files
52+
const minify = {
53+
options: {
54+
preserveComments: false
55+
},
56+
main: {
5657
options: {
57-
preserveComments: false
58+
banner: createBanner( uiFiles )
5859
},
59-
main: {
60-
options: {
61-
banner: createBanner( uiFiles )
62-
},
63-
files: {
64-
"dist/jquery-ui.min.js": "dist/jquery-ui.js"
65-
}
66-
},
67-
i18n: {
68-
options: {
69-
banner: createBanner( allI18nFiles )
70-
},
71-
files: {
72-
"dist/i18n/jquery-ui-i18n.min.js": "dist/i18n/jquery-ui-i18n.js"
73-
}
60+
files: {
61+
"dist/jquery-ui.min.js": "dist/jquery-ui.js"
7462
}
7563
},
64+
i18n: {
65+
options: {
66+
banner: createBanner( allI18nFiles )
67+
},
68+
files: {
69+
"dist/i18n/jquery-ui-i18n.min.js": "dist/i18n/jquery-ui-i18n.js"
70+
}
71+
}
72+
};
7673

77-
compareFiles = {
78-
all: [
79-
"dist/jquery-ui.js",
80-
"dist/jquery-ui.min.js"
81-
]
82-
},
83-
component = grunt.option( "component" ) || "**",
84-
85-
htmllintBad = [
86-
"demos/tabs/ajax/content*.html",
87-
"demos/tooltip/ajax/content*.html",
88-
"tests/unit/core/core.html",
89-
"tests/unit/tabs/data/test.html"
90-
];
74+
const compareFiles = {
75+
all: [
76+
"dist/jquery-ui.js",
77+
"dist/jquery-ui.min.js"
78+
]
79+
};
80+
const component = grunt.option( "component" ) || "**";
81+
82+
const htmllintBad = [
83+
"demos/tabs/ajax/content*.html",
84+
"demos/tooltip/ajax/content*.html",
85+
"tests/unit/core/core.html",
86+
"tests/unit/tabs/data/test.html"
87+
];
88+
89+
const nodeV16OrNewer = !/^v1[0-5]\./.test( process.version );
90+
91+
// Support: Node.js <16
92+
// Skip running tasks that dropped support for Node.js 10-15
93+
// in this Node version.
94+
function runIfNewNode( task ) {
95+
return nodeV16OrNewer ? task : "print_old_node_message:" + task;
96+
}
9197

9298
function mapMinFile( file ) {
9399
return "dist/" + file.replace( /ui\//, "minified/" );
@@ -115,20 +121,14 @@ uiFiles.forEach( function( file ) {
115121
compareFiles[ file ] = [ file, mapMinFile( file ) ];
116122
} );
117123

118-
// grunt plugins
119-
require( "load-grunt-tasks" )( grunt );
120-
121-
// local testswarm and build tasks
122-
grunt.loadTasks( "build/tasks" );
123-
124124
function stripDirectory( file ) {
125125
return file.replace( /.+\/(.+?)>?$/, "$1" );
126126
}
127127

128128
function createBanner( files ) {
129129

130130
// strip folders
131-
var fileNames = files && files.map( stripDirectory );
131+
const fileNames = files && files.map( stripDirectory );
132132
return "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " +
133133
"<%= grunt.template.today('isoDate') %>\n" +
134134
"<%= pkg.homepage ? '* ' + pkg.homepage + '\\n' : '' %>" +
@@ -184,9 +184,10 @@ grunt.initConfig( {
184184
ignore: [
185185
/The text content of element script was not in the required format: Expected space, tab, newline, or slash but found . instead/
186186
] },
187-
src: glob.sync( "{demos,tests}/**/*.html", {
188-
ignore: htmllintBad
189-
} )
187+
src: [
188+
"{demos,tests}/**/*.html",
189+
...htmllintBad.map( pattern => `!${ pattern }` )
190+
]
190191
},
191192
bad: {
192193
options: {
@@ -469,9 +470,22 @@ grunt.initConfig( {
469470
}
470471
} );
471472

473+
// grunt plugins
474+
require( "load-grunt-tasks" )( grunt, {
475+
pattern: nodeV16OrNewer ? [ "grunt-*" ] : [
476+
"grunt-*",
477+
"!grunt-contrib-qunit",
478+
"!grunt-eslint",
479+
"!grunt-html"
480+
]
481+
} );
482+
483+
// local testswarm and build tasks
484+
grunt.loadTasks( "build/tasks" );
485+
472486
grunt.registerTask( "update-authors", function() {
473-
var getAuthors = require( "grunt-git-authors" ).getAuthors,
474-
done = this.async();
487+
const getAuthors = require( "grunt-git-authors" ).getAuthors;
488+
const done = this.async();
475489

476490
getAuthors( {
477491
priorAuthors: grunt.config( "authors.prior" )
@@ -499,11 +513,21 @@ grunt.registerTask( "update-authors", function() {
499513
} );
500514
} );
501515

516+
grunt.registerTask( "print_old_node_message", ( ...args ) => {
517+
const task = args.join( ":" );
518+
grunt.log.writeln( "Old Node.js detected, running the task \"" + task + "\" skipped..." );
519+
} );
520+
502521
// Keep this task list in sync with the testing steps in our GitHub action test workflow file!
503522
grunt.registerTask( "default", [ "lint", "requirejs", "test" ] );
504523
grunt.registerTask( "jenkins", [ "default", "concat" ] );
505-
grunt.registerTask( "lint", [ "asciilint", "eslint", "csslint", "htmllint" ] );
506-
grunt.registerTask( "test", [ "qunit" ] );
524+
grunt.registerTask( "lint", [
525+
"asciilint",
526+
runIfNewNode( "eslint" ),
527+
"csslint",
528+
runIfNewNode( "htmllint" )
529+
] );
530+
grunt.registerTask( "test", [ runIfNewNode( "qunit" ) ] );
507531
grunt.registerTask( "sizer", [ "requirejs:js", "uglify:main", "compare_size:all" ] );
508532
grunt.registerTask( "sizer_all", [ "requirejs:js", "uglify", "compare_size" ] );
509533

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
"devDependencies": {
5454
"commitplease": "3.2.0",
5555
"eslint-config-jquery": "3.0.0",
56-
"glob": "7.2.0",
5756
"grunt": "1.5.3",
5857
"grunt-bowercopy": "1.2.5",
5958
"grunt-cli": "1.4.3",

0 commit comments

Comments
 (0)