Skip to content

Commit 625b6ee

Browse files
authored
chore: automate pull-requests for resource updates (#193)
This PR uses `peter-evans/create-pull-request` to automate pull requests for resource updates.
1 parent a98196e commit 625b6ee

File tree

5 files changed

+46
-17
lines changed

5 files changed

+46
-17
lines changed

.eslintrc.js

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ module.exports = {
5656
"@eslint-community/mysticatea/ts/ban-ts-comment": "off",
5757
"@eslint-community/mysticatea/ts/no-unsafe-assignment": "off",
5858
"@eslint-community/mysticatea/ts/no-unsafe-call": "off",
59+
"@eslint-community/mysticatea/ts/naming-convention": "off",
60+
"@eslint-community/mysticatea/ts/no-require-imports": "off",
61+
"@eslint-community/mysticatea/ts/no-var-requires": "off",
5962
},
6063
},
6164

.github/workflows/cron.yml

+22-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
name: cron
22
on:
3+
workflow_dispatch: null
34
schedule:
45
- cron: 0 0 * * 0
56

7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
611
jobs:
7-
check-resource-update:
8-
name: check-resource-update
12+
update-unicode-resource:
13+
name: update-unicode-resource
914
runs-on: ubuntu-latest
1015
steps:
1116
- name: Checkout
@@ -18,12 +23,15 @@ jobs:
1823
run: npm install
1924
- name: Update
2025
run: npm run update:unicode
21-
- name: Check changes
22-
run: |
23-
git add --all && \
24-
git diff-index --cached HEAD --stat --exit-code
25-
check-extract-test262:
26-
name: check-extract-test262
26+
- uses: peter-evans/create-pull-request@v6
27+
with:
28+
commit-message: "fix: updates unicode resource with latest"
29+
branch: update-unicode-resource
30+
branch-suffix: timestamp
31+
title: "fix: updates unicode resource with latest"
32+
33+
update-test262:
34+
name: update-test262
2735
runs-on: ubuntu-latest
2836
steps:
2937
- name: Checkout
@@ -36,7 +44,9 @@ jobs:
3644
run: npm install
3745
- name: Update
3846
run: npm run update:test262:extract
39-
- name: Check changes
40-
run: |
41-
git add --all && \
42-
git diff-index --cached HEAD --stat --exit-code
47+
- uses: peter-evans/create-pull-request@v6
48+
with:
49+
commit-message: "test: updates test cases extracted from test262"
50+
branch: update-test262
51+
branch-suffix: timestamp
52+
title: "test: updates test cases extracted from test262"

package.json

-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@
8282
"rimraf": "^3.0.2",
8383
"rollup": "^2.79.1",
8484
"rollup-plugin-sourcemaps": "^0.6.3",
85-
"test262": "git+https://github.com/tc39/test262.git",
86-
"test262-stream": "^1.4.0",
8785
"ts-node": "^10.9.1",
8886
"typescript": "~5.0.2"
8987
},

scripts/extract-test262.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @ts-ignore -- ignore
2-
import TestStream from "test262-stream"
31
import path from "path"
42
import { promises as fs } from "fs"
53
import { parseRegExpLiteral } from "../src/index"
@@ -8,6 +6,16 @@ import { cloneWithoutCircular } from "./clone-without-circular"
86
import type { RegExpSyntaxError } from "../src/regexp-syntax-error"
97
import { fixturesData } from "../test/fixtures/parser/literal"
108
import type { Readable } from "stream"
9+
import { execSync } from "child_process"
10+
11+
console.log("Installing test262 and test262-stream...")
12+
13+
execSync(
14+
"npm install --no-save git+https://github.com/tc39/test262.git test262-stream",
15+
{ stdio: "inherit" },
16+
)
17+
18+
console.log("Extracting test262 fixtures...")
1119

1220
const fixturesRoot = path.join(
1321
__dirname,
@@ -16,6 +24,8 @@ const fixturesRoot = path.join(
1624

1725
const test262Root = path.dirname(require.resolve("test262/package.json"))
1826

27+
const TestStream = require("test262-stream")
28+
1929
const stream: Readable = new TestStream(test262Root, { omitRuntime: true })
2030

2131
type Test = {

scripts/update-unicode-properties.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,21 @@ const DATA_SOURCES = [
4949
scValues: getLatestUnicodeScriptValues,
5050
},
5151
{
52-
url: "https://tc39.es/ecma262/multipage/text-processing.html",
52+
url: "https://tc39.es/ecma262/2024/multipage/text-processing.html",
5353
version: 2024,
5454
binProperties: "#table-binary-unicode-properties",
5555
gcValues: getLatestUnicodeGeneralCategoryValues,
5656
scValues: getLatestUnicodeScriptValues,
5757
binPropertiesOfStrings: "#table-binary-unicode-properties-of-strings",
5858
},
59+
{
60+
url: "https://tc39.es/ecma262/multipage/text-processing.html",
61+
version: 2025,
62+
binProperties: "#table-binary-unicode-properties",
63+
gcValues: getLatestUnicodeGeneralCategoryValues,
64+
scValues: getLatestUnicodeScriptValues,
65+
binPropertiesOfStrings: "#table-binary-unicode-properties-of-strings",
66+
},
5967
]
6068
const FILE_PATH = "src/unicode/properties.ts"
6169
const logger = console

0 commit comments

Comments
 (0)