Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: replace grunt-contrib-qunit with jQuery test runner #2221

Merged
merged 4 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.yml]
indent_style = space
indent_size = 2

[external/**]
trim_trailing_whitespace = false
insert_final_newline = varies
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/filestash.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Filestash

on:
push:
branches:
- main

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
update:
runs-on: ubuntu-latest
environment: filestash
env:
NODE_VERSION: 20.x
name: Update Filestash
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ env.NODE_VERSION }}

- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-

- name: Install dependencies
run: npm install

- name: Build
run: npm run build

- name: Set up SSH
run: |
install --directory ~/.ssh --mode 700
base64 --decode <<< "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -t ed25519 -H "${{ secrets.FILESTASH_SERVER }}" >> ~/.ssh/known_hosts

- name: Upload to Filestash
run: |
rsync dist/jquery-ui.js filestash@"${{ secrets.FILESTASH_SERVER }}":ui/jquery-ui-git.js
rsync dist/jquery-ui.css filestash@"${{ secrets.FILESTASH_SERVER }}":ui/jquery-ui-git.css
163 changes: 163 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
name: Node

on:
pull_request:
push:
branches-ignore: "dependabot/**"
# Once a week every Monday
schedule:
- cron: "42 1 * * 1"

permissions:
contents: read

env:
NODE_VERSION: 20.x

jobs:
build-and-test:
runs-on: ubuntu-latest
name: ${{ matrix.BROWSER }} - jQuery ${{ matrix.JQUERY }}
strategy:
fail-fast: false
matrix:
BROWSER: [chrome, firefox]
JQUERY:
- "git"
- "3.x-git"
- "3.7.1"
- "2.2.4"
- "1.12.4"
mgol marked this conversation as resolved.
Show resolved Hide resolved

steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ env.NODE_VERSION }}

- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-

- name: Install npm dependencies
run: npm install

- name: Lint
run: npm run lint

- name: Build
run: npm run build

- name: Test
run: npm run test:unit -- -h -b ${{ matrix.BROWSER }} --jquery ${{ matrix.JQUERY }} --retries 3

edge:
runs-on: windows-latest
name: edge - jQuery ${{ matrix.JQUERY }}
strategy:
fail-fast: false
matrix:
JQUERY:
- "git"
- "3.x-git"
- "3.7.1"
- "2.2.4"
- "1.12.4"
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ env.NODE_VERSION }}

- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-

- name: Install dependencies
run: npm install

- name: Build
run: npm run build

- name: Test
run: npm run test:unit -- -h -b edge --jquery ${{ matrix.JQUERY }} --retries 3

safari:
runs-on: macos-latest
name: safari - jQuery ${{ matrix.JQUERY }}
strategy:
fail-fast: false
matrix:
JQUERY:
- "git"
- "3.x-git"
- "3.7.1"
- "2.2.4"
- "1.12.4"
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ env.NODE_VERSION }}

- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-

- name: Install dependencies
run: npm install

- name: Build
run: npm run build

- name: Test
run: npm run test:unit -- -b safari --jquery ${{ matrix.JQUERY }} --retries 3

legacy-build:
runs-on: ubuntu-latest
name: Build on Node 10.x
env:
NODE_VERSION: 10.x
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ env.NODE_VERSION }}

- name: Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-

- name: Install npm dependencies
run: npm install

- name: Build
run: npm run build
63 changes: 0 additions & 63 deletions .github/workflows/test.yml

This file was deleted.

1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact=true
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ The tests require a local web server and the samples contain some PHP, so a PHP

### Running the Tests

To lint the JavaScript, HTML, and CSS, as well as run a smoke test in PhantomJS, run the full test suite through npm:
To lint the JavaScript, HTML, and CSS, as well as run the full test suite in Headless Chrome:

```bash
npm test
Expand Down
37 changes: 7 additions & 30 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ const compareFiles = {
"dist/jquery-ui.min.js"
]
};
const component = grunt.option( "component" ) || "**";

const htmllintBad = [
"demos/tabs/ajax/content*.html",
Expand Down Expand Up @@ -205,30 +204,6 @@ grunt.initConfig( {
src: htmllintBad
}
},
qunit: {
files: expandFiles( "tests/unit/" + component + "/*.html" ).filter( function( file ) {
return !( /(all|index|test)\.html$/ ).test( file );
} ),
options: {
puppeteer: {
args: [
"--allow-file-access-from-files"
]
},
inject: [
require.resolve(
"./tests/lib/grunt-contrib-qunit-bridges/bridge-wrapper.js.intro"
),
require.resolve( "grunt-contrib-qunit/chrome/bridge" ),
require.resolve(
"./tests/lib/grunt-contrib-qunit-bridges/bridge-wrapper.js.outro"
)
],
page: {
viewportSize: { width: 700, height: 500 }
}
}
},
eslint: {
all: [
"ui/**/*.js",
Expand Down Expand Up @@ -430,6 +405,9 @@ grunt.initConfig( {
"jquery-3.7.0/jquery.js": "jquery-3.7.0/dist/jquery.js",
"jquery-3.7.0/LICENSE.txt": "jquery-3.7.0/LICENSE.txt",

"jquery-3.7.1/jquery.js": "jquery-3.7.1/dist/jquery.js",
"jquery-3.7.1/LICENSE.txt": "jquery-3.7.1/LICENSE.txt",

"jquery-migrate-1.4.1/jquery-migrate.js":
"jquery-migrate-1.4.1/dist/jquery-migrate.js",
"jquery-migrate-1.4.1/LICENSE.txt": "jquery-migrate-1.4.1/LICENSE.txt",
Expand Down Expand Up @@ -473,13 +451,12 @@ grunt.initConfig( {
require( "load-grunt-tasks" )( grunt, {
pattern: nodeV16OrNewer ? [ "grunt-*" ] : [
"grunt-*",
"!grunt-contrib-qunit",
"!grunt-eslint",
"!grunt-html"
]
} );

// local testswarm and build tasks
// local tasks
grunt.loadTasks( "build/tasks" );

grunt.registerTask( "update-authors", function() {
Expand Down Expand Up @@ -518,15 +495,15 @@ grunt.registerTask( "print_old_node_message", ( ...args ) => {
} );

// Keep this task list in sync with the testing steps in our GitHub action test workflow file!
grunt.registerTask( "default", [ "lint", "requirejs", "test" ] );
grunt.registerTask( "jenkins", [ "default", "concat" ] );
grunt.registerTask( "lint", [
"asciilint",
runIfNewNode( "eslint" ),
"csslint",
runIfNewNode( "htmllint" )
] );
grunt.registerTask( "test", [ runIfNewNode( "qunit" ) ] );
grunt.registerTask( "build", [ "requirejs", "concat" ] );
grunt.registerTask( "default", [ "lint", "build" ] );
grunt.registerTask( "jenkins", [ "build" ] );
grunt.registerTask( "sizer", [ "requirejs:js", "uglify:main", "compare_size:all" ] );
grunt.registerTask( "sizer_all", [ "requirejs:js", "uglify", "compare_size" ] );

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ For more information, see the [contributing page](CONTRIBUTING.md).

Run the unit tests manually with appropriate browsers and any local web server. See our [environment setup](CONTRIBUTING.md#environment-minimum-required) and [information on running tests](CONTRIBUTING.md#running-the-tests).

You can also run the unit tests inside phantomjs by [setting up your environment](CONTRIBUTING.md#user-content-environment-recommended-setup).
You can also run the unit tests `npm run test:unit -- --help`.
Loading