Skip to content

Commit cc677d1

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

12 files changed

+2278
-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

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

.github/workflows/jquery-ui.yml

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

.github/workflows/jquery.yml

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