Skip to content

Commit

Permalink
chore: automate pull-requests for resource updates (#193)
Browse files Browse the repository at this point in the history
This PR uses `peter-evans/create-pull-request` to automate pull requests
for resource updates.
  • Loading branch information
ota-meshi authored Jun 3, 2024
1 parent a98196e commit 625b6ee
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ module.exports = {
"@eslint-community/mysticatea/ts/ban-ts-comment": "off",
"@eslint-community/mysticatea/ts/no-unsafe-assignment": "off",
"@eslint-community/mysticatea/ts/no-unsafe-call": "off",
"@eslint-community/mysticatea/ts/naming-convention": "off",
"@eslint-community/mysticatea/ts/no-require-imports": "off",
"@eslint-community/mysticatea/ts/no-var-requires": "off",
},
},

Expand Down
34 changes: 22 additions & 12 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
name: cron
on:
workflow_dispatch: null
schedule:
- cron: 0 0 * * 0

permissions:
contents: write
pull-requests: write

jobs:
check-resource-update:
name: check-resource-update
update-unicode-resource:
name: update-unicode-resource
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -18,12 +23,15 @@ jobs:
run: npm install
- name: Update
run: npm run update:unicode
- name: Check changes
run: |
git add --all && \
git diff-index --cached HEAD --stat --exit-code
check-extract-test262:
name: check-extract-test262
- uses: peter-evans/create-pull-request@v6
with:
commit-message: "fix: updates unicode resource with latest"
branch: update-unicode-resource
branch-suffix: timestamp
title: "fix: updates unicode resource with latest"

update-test262:
name: update-test262
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -36,7 +44,9 @@ jobs:
run: npm install
- name: Update
run: npm run update:test262:extract
- name: Check changes
run: |
git add --all && \
git diff-index --cached HEAD --stat --exit-code
- uses: peter-evans/create-pull-request@v6
with:
commit-message: "test: updates test cases extracted from test262"
branch: update-test262
branch-suffix: timestamp
title: "test: updates test cases extracted from test262"
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@
"rimraf": "^3.0.2",
"rollup": "^2.79.1",
"rollup-plugin-sourcemaps": "^0.6.3",
"test262": "git+https://github.com/tc39/test262.git",
"test262-stream": "^1.4.0",
"ts-node": "^10.9.1",
"typescript": "~5.0.2"
},
Expand Down
14 changes: 12 additions & 2 deletions scripts/extract-test262.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @ts-ignore -- ignore
import TestStream from "test262-stream"
import path from "path"
import { promises as fs } from "fs"
import { parseRegExpLiteral } from "../src/index"
Expand All @@ -8,6 +6,16 @@ import { cloneWithoutCircular } from "./clone-without-circular"
import type { RegExpSyntaxError } from "../src/regexp-syntax-error"
import { fixturesData } from "../test/fixtures/parser/literal"
import type { Readable } from "stream"
import { execSync } from "child_process"

console.log("Installing test262 and test262-stream...")

execSync(
"npm install --no-save git+https://github.com/tc39/test262.git test262-stream",
{ stdio: "inherit" },
)

console.log("Extracting test262 fixtures...")

const fixturesRoot = path.join(
__dirname,
Expand All @@ -16,6 +24,8 @@ const fixturesRoot = path.join(

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

const TestStream = require("test262-stream")

const stream: Readable = new TestStream(test262Root, { omitRuntime: true })

type Test = {
Expand Down
10 changes: 9 additions & 1 deletion scripts/update-unicode-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,21 @@ const DATA_SOURCES = [
scValues: getLatestUnicodeScriptValues,
},
{
url: "https://tc39.es/ecma262/multipage/text-processing.html",
url: "https://tc39.es/ecma262/2024/multipage/text-processing.html",
version: 2024,
binProperties: "#table-binary-unicode-properties",
gcValues: getLatestUnicodeGeneralCategoryValues,
scValues: getLatestUnicodeScriptValues,
binPropertiesOfStrings: "#table-binary-unicode-properties-of-strings",
},
{
url: "https://tc39.es/ecma262/multipage/text-processing.html",
version: 2025,
binProperties: "#table-binary-unicode-properties",
gcValues: getLatestUnicodeGeneralCategoryValues,
scValues: getLatestUnicodeScriptValues,
binPropertiesOfStrings: "#table-binary-unicode-properties-of-strings",
},
]
const FILE_PATH = "src/unicode/properties.ts"
const logger = console
Expand Down

0 comments on commit 625b6ee

Please sign in to comment.