Skip to content

Commit 98dee6c

Browse files
committed
test: add test workflows for all 3 jquery projects
1 parent 02e40b8 commit 98dee6c

12 files changed

+2266
-2085
lines changed

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This file is for unifying the coding style for different editors and IDEs
2+
# editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
indent_style = tab
8+
end_of_line = lf
9+
charset = utf-8
10+
trim_trailing_whitespace = true
11+
insert_final_newline = true
12+
13+
[*.{json,yml}]
14+
indent_style = space
15+
indent_size = 2

.github/dependabot.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: "/"
5+
schedule:
6+
interval: monthly
7+
8+
# Group all dependabot version update PRs into one
9+
groups:
10+
github-actions:
11+
applies-to: version-updates
12+
patterns:
13+
- "*"

.github/workflows/jquery-migrate.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: jQuery Migrate
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
env:
10+
NODE_VERSION: 22.x
11+
12+
jobs:
13+
build-and-test:
14+
runs-on: ubuntu-latest
15+
name: Test jQuery Migrate Integration
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
19+
with:
20+
submodules: recursive
21+
22+
- name: Use Node.js ${{ env.NODE_VERSION }}
23+
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
24+
with:
25+
node-version: ${{ env.NODE_VERSION }}
26+
27+
- name: Cache
28+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
29+
with:
30+
path: ~/.npm
31+
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-${{ hashFiles('**/package-lock.json') }}
32+
restore-keys: |
33+
${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-
34+
35+
- name: Install dependencies
36+
run: npm install
37+
38+
- name: Run jQuery Migrate tests
39+
working-directory: test/jquery-migrate
40+
run: npm it

.github/workflows/jquery-ui.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: jQuery UI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
env:
10+
NODE_VERSION: 22.x
11+
12+
jobs:
13+
build-and-test:
14+
runs-on: ubuntu-latest
15+
name: Test jQuery UI Integration
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
19+
with:
20+
submodules: recursive
21+
22+
- name: Use Node.js ${{ env.NODE_VERSION }}
23+
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
24+
with:
25+
node-version: ${{ env.NODE_VERSION }}
26+
27+
- name: Cache
28+
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
29+
with:
30+
path: ~/.npm
31+
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-${{ hashFiles('**/package-lock.json') }}
32+
restore-keys: |
33+
${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-
34+
35+
- name: Install dependencies
36+
run: npm install
37+
38+
- name: Run jQuery UI tests
39+
working-directory: test/jquery-ui
40+
run: npm it

.github/workflows/jquery.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: jQuery
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
env:
10+
NODE_VERSION: 22.x
11+
12+
jobs:
13+
build-and-test:
14+
runs-on: ubuntu-latest
15+
name: Test jQuery Integration
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
19+
with:
20+
submodules: recursive
21+
22+
- name: Use Node.js ${{ env.NODE_VERSION }}
23+
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
24+
with:
25+
node-version: ${{ env.NODE_VERSION }}
26+
27+
- name: Cache
28+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
29+
with:
30+
path: ~/.npm
31+
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-${{ hashFiles('**/package-lock.json') }}
32+
restore-keys: |
33+
${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-
34+
35+
- name: Install dependencies
36+
run: npm install
37+
38+
- name: Run jQuery tests
39+
working-directory: test/jquery
40+
run: npm it

.gitmodules

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[submodule "test/jquery"]
2+
path = test/jquery
3+
url = [email protected]:jquery/jquery.git
4+
[submodule "test/jquery-migrate"]
5+
path = test/jquery-migrate
6+
url = [email protected]:jquery/jquery-migrate.git
7+
[submodule "test/jquery-ui"]
8+
path = test/jquery-ui
9+
url = [email protected]:jquery/jquery-ui.git

lib/readYAML.js

+25-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// The path is expected to either be absolute or relative to the current working directory.
33

44
import { readFile, stat } from "node:fs/promises";
5-
import { resolve } from "node:path";
65
import { parse } from "yaml";
6+
import { resolve } from "node:path";
77

8-
const CONFIG_VERSION = 1;
9-
const DEFAULT_YAML_PATHS = [ "jtr.yml", "jtr.yaml" ];
8+
export const CONFIG_VERSION = 1;
9+
export const DEFAULT_YAML_PATHS = [ "jtr.yml", "jtr.yaml" ];
1010

1111
const rkebab = /-([a-z])/g;
1212

@@ -22,7 +22,28 @@ export default async function readYAML( path ) {
2222
return {};
2323
}
2424

25-
const contents = await readFile( resolve( process.cwd(), path ), "utf8" );
25+
if ( !path.endsWith( ".yml" ) && !path.endsWith( ".yaml" ) ) {
26+
throw new Error( "Invalid configuration file. Expected a YAML file." );
27+
}
28+
29+
let contents;
30+
31+
// Check if path is absolute
32+
if ( path.startsWith( "/" ) || path.startsWith( "\\" ) || path.includes( ":" ) ) {
33+
if ( !await stat( path ).catch( () => false ) ) {
34+
throw new Error( `Configuration file not found: ${ path }` );
35+
}
36+
37+
contents = await readFile( path, "utf8" );
38+
} else {
39+
path = resolve( process.cwd(), path );
40+
41+
if ( !await stat( path ).catch( () => false ) ) {
42+
throw new Error( `Configuration file not found: ${ path }` );
43+
}
44+
45+
contents = await readFile( path, "utf8" );
46+
}
2647
let config = await parse( contents );
2748

2849
if ( config.version !== CONFIG_VERSION ) {

0 commit comments

Comments
 (0)