From 625b6ee28f2887fd5eadeb7be1f5f76745cc5cba Mon Sep 17 00:00:00 2001 From: Yosuke Ota Date: Mon, 3 Jun 2024 17:53:20 +0900 Subject: [PATCH] chore: automate pull-requests for resource updates (#193) This PR uses `peter-evans/create-pull-request` to automate pull requests for resource updates. --- .eslintrc.js | 3 +++ .github/workflows/cron.yml | 34 ++++++++++++++++++---------- package.json | 2 -- scripts/extract-test262.ts | 14 ++++++++++-- scripts/update-unicode-properties.ts | 10 +++++++- 5 files changed, 46 insertions(+), 17 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 397edc5..7e6d446 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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", }, }, diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index 6c3f95f..2ac950b 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -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 @@ -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 @@ -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" diff --git a/package.json b/package.json index dad2275..90dcf3b 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/scripts/extract-test262.ts b/scripts/extract-test262.ts index b5e3bd6..0874c0a 100644 --- a/scripts/extract-test262.ts +++ b/scripts/extract-test262.ts @@ -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" @@ -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, @@ -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 = { diff --git a/scripts/update-unicode-properties.ts b/scripts/update-unicode-properties.ts index 941b40b..4ef5f72 100644 --- a/scripts/update-unicode-properties.ts +++ b/scripts/update-unicode-properties.ts @@ -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