Merge pull request #4128 from github/mbg/move-changetool

Migrate `changetool` to `pr-checks`
This commit is contained in:
Michael B. Gale
2026-09-10 16:42:38 +00:00
committed by GitHub
12 changed files with 39 additions and 517 deletions

View File

@@ -45,7 +45,7 @@ jobs:
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
cache: 'npm' cache: "npm"
- name: Install dependencies - name: Install dependencies
run: | run: |
@@ -77,33 +77,6 @@ jobs:
sarif_file: eslint.sarif sarif_file: eslint.sarif
category: eslint category: eslint
changetool-tests:
name: changetool unit tests
permissions:
contents: read
runs-on: ubuntu-slim
timeout-minutes: 10
concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request' || false }}
group: pr-checks-changetool-tests-${{ github.ref }}-${{ github.event_name }}
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 24
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run changetool unit tests
run: npm --workspace changetool test
# These checks do not need to be run as part of the same matrix that we use for the `unit-tests` # These checks do not need to be run as part of the same matrix that we use for the `unit-tests`
# job. # job.
other-checks: other-checks:
@@ -126,7 +99,7 @@ jobs:
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with: with:
node-version: 24 node-version: 24
cache: 'npm' cache: "npm"
- name: Install dependencies - name: Install dependencies
id: install-deps id: install-deps
@@ -190,14 +163,14 @@ jobs:
path: ${{ runner.temp }}/repo-size/ path: ${{ runner.temp }}/repo-size/
if-no-files-found: error if-no-files-found: error
- name: 'Backport: Check out base ref' - name: "Backport: Check out base ref"
id: checkout-base id: checkout-base
if: ${{ startsWith(github.head_ref, 'backport-') }} if: ${{ startsWith(github.head_ref, 'backport-') }}
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with: with:
ref: ${{ github.base_ref }} ref: ${{ github.base_ref }}
- name: 'Backport: Verify Node versions unchanged' - name: "Backport: Verify Node versions unchanged"
if: steps.checkout-base.outcome == 'success' if: steps.checkout-base.outcome == 'success'
env: env:
HEAD_VERSION: ${{ steps.head-version.outputs.node_version }} HEAD_VERSION: ${{ steps.head-version.outputs.node_version }}

View File

@@ -180,7 +180,7 @@ export default [
}, },
}, },
{ {
files: ["pr-checks/**/*.ts"], files: ["pr-checks/**/*.ts", "pr-checks/**/*.mts"],
languageOptions: { languageOptions: {
parserOptions: { parserOptions: {
@@ -209,18 +209,4 @@ export default [
], ],
}, },
}, },
{
files: ["scripts/changetool/**/*.ts"],
languageOptions: {
parserOptions: {
project: "./scripts/changetool/tsconfig.json",
},
},
rules: {
"no-console": "off",
"import/extensions": "off",
},
},
]; ];

422
package-lock.json generated
View File

@@ -9,8 +9,7 @@
"version": "4.38.1", "version": "4.38.1",
"license": "MIT", "license": "MIT",
"workspaces": [ "workspaces": [
"pr-checks", "pr-checks"
"scripts/changetool"
], ],
"dependencies": { "dependencies": {
"@actions/artifact": "^5.0.3", "@actions/artifact": "^5.0.3",
@@ -3085,346 +3084,6 @@
"url": "https://opencollective.com/eslint" "url": "https://opencollective.com/eslint"
} }
}, },
"node_modules/@typescript/typescript-aix-ppc64": {
"version": "7.0.2",
"resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-aix-ppc64/-/typescript-aix-ppc64-7.0.2.tgz",
"integrity": "sha1-zcfOgdYPHgkDSWDd+x+4gNendrY=",
"cpu": [
"ppc64"
],
"dev": true,
"license": "Apache-2.0",
"optional": true,
"os": [
"aix"
],
"engines": {
"node": ">=16.20.0"
}
},
"node_modules/@typescript/typescript-darwin-arm64": {
"version": "7.0.2",
"resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-darwin-arm64/-/typescript-darwin-arm64-7.0.2.tgz",
"integrity": "sha1-pV/fz6WN9Y0n2yI3zealweNacjU=",
"cpu": [
"arm64"
],
"dev": true,
"license": "Apache-2.0",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=16.20.0"
}
},
"node_modules/@typescript/typescript-darwin-x64": {
"version": "7.0.2",
"resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-darwin-x64/-/typescript-darwin-x64-7.0.2.tgz",
"integrity": "sha1-ONHJFygAqR1we+xk0qNwoBZjTbQ=",
"cpu": [
"x64"
],
"dev": true,
"license": "Apache-2.0",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=16.20.0"
}
},
"node_modules/@typescript/typescript-freebsd-arm64": {
"version": "7.0.2",
"resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-freebsd-arm64/-/typescript-freebsd-arm64-7.0.2.tgz",
"integrity": "sha1-8f+IEAMLNdK1vg22otxlBGDqlPo=",
"cpu": [
"arm64"
],
"dev": true,
"license": "Apache-2.0",
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">=16.20.0"
}
},
"node_modules/@typescript/typescript-freebsd-x64": {
"version": "7.0.2",
"resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-freebsd-x64/-/typescript-freebsd-x64-7.0.2.tgz",
"integrity": "sha1-PYawPzU8WxupUWLrbONVM7/ClL0=",
"cpu": [
"x64"
],
"dev": true,
"license": "Apache-2.0",
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">=16.20.0"
}
},
"node_modules/@typescript/typescript-linux-arm": {
"version": "7.0.2",
"resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-linux-arm/-/typescript-linux-arm-7.0.2.tgz",
"integrity": "sha1-rZS0HhruKk3MaimMe2fEM0X94y4=",
"cpu": [
"arm"
],
"dev": true,
"license": "Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=16.20.0"
}
},
"node_modules/@typescript/typescript-linux-arm64": {
"version": "7.0.2",
"resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-linux-arm64/-/typescript-linux-arm64-7.0.2.tgz",
"integrity": "sha1-2TNNltbaxv+F2pyGVYiUjek56R8=",
"cpu": [
"arm64"
],
"dev": true,
"license": "Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=16.20.0"
}
},
"node_modules/@typescript/typescript-linux-loong64": {
"version": "7.0.2",
"resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-linux-loong64/-/typescript-linux-loong64-7.0.2.tgz",
"integrity": "sha1-KWWu5PyHM2ATnYk9qv5jl6KROK0=",
"cpu": [
"loong64"
],
"dev": true,
"license": "Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=16.20.0"
}
},
"node_modules/@typescript/typescript-linux-mips64el": {
"version": "7.0.2",
"resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-linux-mips64el/-/typescript-linux-mips64el-7.0.2.tgz",
"integrity": "sha1-Goh6MRvtOoM/gL/Uqe03wnGTbPA=",
"cpu": [
"mips64el"
],
"dev": true,
"license": "Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=16.20.0"
}
},
"node_modules/@typescript/typescript-linux-ppc64": {
"version": "7.0.2",
"resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-linux-ppc64/-/typescript-linux-ppc64-7.0.2.tgz",
"integrity": "sha1-i2PJsvRFs5PrTkPsIdoiXa3jV30=",
"cpu": [
"ppc64"
],
"dev": true,
"license": "Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=16.20.0"
}
},
"node_modules/@typescript/typescript-linux-riscv64": {
"version": "7.0.2",
"resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-linux-riscv64/-/typescript-linux-riscv64-7.0.2.tgz",
"integrity": "sha1-tuijXCibPql6kqQdRhqu7Q07NuE=",
"cpu": [
"riscv64"
],
"dev": true,
"license": "Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=16.20.0"
}
},
"node_modules/@typescript/typescript-linux-s390x": {
"version": "7.0.2",
"resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-linux-s390x/-/typescript-linux-s390x-7.0.2.tgz",
"integrity": "sha1-Lvlmk75IYfbReWVCflsAnLvtGj4=",
"cpu": [
"s390x"
],
"dev": true,
"license": "Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=16.20.0"
}
},
"node_modules/@typescript/typescript-linux-x64": {
"version": "7.0.2",
"resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-linux-x64/-/typescript-linux-x64-7.0.2.tgz",
"integrity": "sha1-cyacsLq6UK6gygYERaa4jlg/HOI=",
"cpu": [
"x64"
],
"dev": true,
"license": "Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=16.20.0"
}
},
"node_modules/@typescript/typescript-netbsd-arm64": {
"version": "7.0.2",
"resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-netbsd-arm64/-/typescript-netbsd-arm64-7.0.2.tgz",
"integrity": "sha1-OjZJ+X+vohC05uN5jBXgZgXIqQE=",
"cpu": [
"arm64"
],
"dev": true,
"license": "Apache-2.0",
"optional": true,
"os": [
"netbsd"
],
"engines": {
"node": ">=16.20.0"
}
},
"node_modules/@typescript/typescript-netbsd-x64": {
"version": "7.0.2",
"resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-netbsd-x64/-/typescript-netbsd-x64-7.0.2.tgz",
"integrity": "sha1-R+xZSRpAxHDSgH3E0rglUo/Zeas=",
"cpu": [
"x64"
],
"dev": true,
"license": "Apache-2.0",
"optional": true,
"os": [
"netbsd"
],
"engines": {
"node": ">=16.20.0"
}
},
"node_modules/@typescript/typescript-openbsd-arm64": {
"version": "7.0.2",
"resolved": "https://ms-feed-17.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-openbsd-arm64/-/typescript-openbsd-arm64-7.0.2.tgz",
"integrity": "sha1-eWvo2gvZidij+5bygB44qDZbS68=",
"cpu": [
"arm64"
],
"dev": true,
"license": "Apache-2.0",
"optional": true,
"os": [
"openbsd"
],
"engines": {
"node": ">=16.20.0"
}
},
"node_modules/@typescript/typescript-openbsd-x64": {
"version": "7.0.2",
"resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-openbsd-x64/-/typescript-openbsd-x64-7.0.2.tgz",
"integrity": "sha1-03/ipynrlCwHbEVO5/GBX699Vg8=",
"cpu": [
"x64"
],
"dev": true,
"license": "Apache-2.0",
"optional": true,
"os": [
"openbsd"
],
"engines": {
"node": ">=16.20.0"
}
},
"node_modules/@typescript/typescript-sunos-x64": {
"version": "7.0.2",
"resolved": "https://ms-feed-17.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-sunos-x64/-/typescript-sunos-x64-7.0.2.tgz",
"integrity": "sha1-q6jTRkw1ZacER4m6upaRa9SrLIg=",
"cpu": [
"x64"
],
"dev": true,
"license": "Apache-2.0",
"optional": true,
"os": [
"sunos"
],
"engines": {
"node": ">=16.20.0"
}
},
"node_modules/@typescript/typescript-win32-arm64": {
"version": "7.0.2",
"resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-win32-arm64/-/typescript-win32-arm64-7.0.2.tgz",
"integrity": "sha1-ud5QoXGWOD9iYgtfnQovNK07YNc=",
"cpu": [
"arm64"
],
"dev": true,
"license": "Apache-2.0",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=16.20.0"
}
},
"node_modules/@typescript/typescript-win32-x64": {
"version": "7.0.2",
"resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-win32-x64/-/typescript-win32-x64-7.0.2.tgz",
"integrity": "sha1-zzt7DWzlY12spMjgHBic3N5H7Dw=",
"cpu": [
"x64"
],
"dev": true,
"license": "Apache-2.0",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=16.20.0"
}
},
"node_modules/@typespec/ts-http-runtime": { "node_modules/@typespec/ts-http-runtime": {
"version": "0.3.2", "version": "0.3.2",
"resolved": "https://registry.npmjs.org/@typespec/ts-http-runtime/-/ts-http-runtime-0.3.2.tgz", "resolved": "https://registry.npmjs.org/@typespec/ts-http-runtime/-/ts-http-runtime-0.3.2.tgz",
@@ -4571,10 +4230,6 @@
"url": "https://github.com/chalk/chalk?sponsor=1" "url": "https://github.com/chalk/chalk?sponsor=1"
} }
}, },
"node_modules/changetool": {
"resolved": "scripts/changetool",
"link": true
},
"node_modules/character-entities": { "node_modules/character-entities": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/character-entities/-/character-entities-2.0.2.tgz", "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/character-entities/-/character-entities-2.0.2.tgz",
@@ -7658,8 +7313,8 @@
}, },
"node_modules/lite-matter": { "node_modules/lite-matter": {
"version": "0.1.2", "version": "0.1.2",
"resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/lite-matter/-/lite-matter-0.1.2.tgz", "resolved": "https://registry.npmjs.org/lite-matter/-/lite-matter-0.1.2.tgz",
"integrity": "sha1-NlO1r/xDs8OnKQcf/kw4/a4O1Ws=", "integrity": "sha512-cGSYxO6vcipYZBSF5dUtDF3IqbkNxSjVQuvs5Ol3fO35URzHEvG2Ml0KbH5kvXXsx33SgbfwiVp6afwovarD8A==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"yaml": "^2.9.0" "yaml": "^2.9.0"
@@ -7793,8 +7448,8 @@
}, },
"node_modules/mdast-util-from-markdown": { "node_modules/mdast-util-from-markdown": {
"version": "2.0.3", "version": "2.0.3",
"resolved": "https://ms-feed-17.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.3.tgz", "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.3.tgz",
"integrity": "sha1-yVgiuRqrdfGKTL6LL1G4c+0s8Mc=", "integrity": "sha512-W4mAWTvSlKvf8L6J+VN9yLSqQ9AOAAvHuoDAmPkz4dHf553m5gVj2ejadHJhoJmcmxEnOv6Pa8XJhpxE93kb8Q==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@types/mdast": "^4.0.0", "@types/mdast": "^4.0.0",
@@ -10800,6 +10455,8 @@
"@octokit/core": "^7.0.8", "@octokit/core": "^7.0.8",
"@octokit/plugin-paginate-rest": ">=15.0.0", "@octokit/plugin-paginate-rest": ">=15.0.0",
"@octokit/plugin-rest-endpoint-methods": "^18.0.0", "@octokit/plugin-rest-endpoint-methods": "^18.0.0",
"lite-matter": "^0.1.2",
"mdast-util-from-markdown": "^2.0.3",
"semver": "^7.8.5", "semver": "^7.8.5",
"yaml": "^2.9.0" "yaml": "^2.9.0"
}, },
@@ -10807,71 +10464,6 @@
"@types/node": "^20.19.43", "@types/node": "^20.19.43",
"tsx": "^4.23.13" "tsx": "^4.23.13"
} }
},
"scripts/changetool": {
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"lite-matter": "^0.1.2",
"mdast-util-from-markdown": "^2.0.3"
},
"devDependencies": {
"@types/node": "^26.2.0",
"tsx": "^4.23.13",
"typescript": "^7.0.2"
}
},
"scripts/changetool/node_modules/@types/node": {
"version": "26.2.0",
"resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@types/node/-/node-26.2.0.tgz",
"integrity": "sha1-Wkh1qGL9qP3Ffej6pXm7gey6FoU=",
"dev": true,
"license": "MIT",
"dependencies": {
"undici-types": "~8.3.0"
}
},
"scripts/changetool/node_modules/typescript": {
"version": "7.0.2",
"resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/typescript/-/typescript-7.0.2.tgz",
"integrity": "sha1-nsdz15VKjBgsF8xbvVdaoovFFYI=",
"dev": true,
"license": "Apache-2.0",
"bin": {
"tsc": "bin/tsc"
},
"engines": {
"node": ">=16.20.0"
},
"optionalDependencies": {
"@typescript/typescript-aix-ppc64": "7.0.2",
"@typescript/typescript-darwin-arm64": "7.0.2",
"@typescript/typescript-darwin-x64": "7.0.2",
"@typescript/typescript-freebsd-arm64": "7.0.2",
"@typescript/typescript-freebsd-x64": "7.0.2",
"@typescript/typescript-linux-arm": "7.0.2",
"@typescript/typescript-linux-arm64": "7.0.2",
"@typescript/typescript-linux-loong64": "7.0.2",
"@typescript/typescript-linux-mips64el": "7.0.2",
"@typescript/typescript-linux-ppc64": "7.0.2",
"@typescript/typescript-linux-riscv64": "7.0.2",
"@typescript/typescript-linux-s390x": "7.0.2",
"@typescript/typescript-linux-x64": "7.0.2",
"@typescript/typescript-netbsd-arm64": "7.0.2",
"@typescript/typescript-netbsd-x64": "7.0.2",
"@typescript/typescript-openbsd-arm64": "7.0.2",
"@typescript/typescript-openbsd-x64": "7.0.2",
"@typescript/typescript-sunos-x64": "7.0.2",
"@typescript/typescript-win32-arm64": "7.0.2",
"@typescript/typescript-win32-x64": "7.0.2"
}
},
"scripts/changetool/node_modules/undici-types": {
"version": "8.3.0",
"resolved": "https://ms-feed-17.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/undici-types/-/undici-types-8.3.0.tgz",
"integrity": "sha1-ROn8nzJEZIzeo15Pm7LWgelBCAk=",
"dev": true,
"license": "MIT"
} }
} }
} }

View File

@@ -17,8 +17,7 @@
}, },
"license": "MIT", "license": "MIT",
"workspaces": [ "workspaces": [
"pr-checks", "pr-checks"
"scripts/changetool"
], ],
"dependencies": { "dependencies": {
"@actions/artifact": "^5.0.3", "@actions/artifact": "^5.0.3",

View File

@@ -10,12 +10,12 @@ import {
isValidChangenoteFilename, isValidChangenoteFilename,
hasValidChangenoteCategory, hasValidChangenoteCategory,
VALID_CHANGE_NOTE_CATEGORIES, VALID_CHANGE_NOTE_CATEGORIES,
} from "./validate.ts"; } from "./validate.mjs";
async function withTmpFile<T>( async function withTmpFile<T>(
baseFileName: string, baseFileName: string,
contents: string, contents: string,
body: (filePath: string) => Promise<T>, body: (filePath: string) => Promise<T> | T,
): Promise<T> { ): Promise<T> {
const tmpDir = fs.mkdtempSync( const tmpDir = fs.mkdtempSync(
path.join(os.tmpdir(), "changetool-validate-test-"), path.join(os.tmpdir(), "changetool-validate-test-"),
@@ -30,7 +30,7 @@ async function withTmpFile<T>(
} }
await describe("isValidChangenoteContent", async () => { await describe("isValidChangenoteContent", async () => {
await it("recognizes an unordered Markdown list", async () => { await it("recognizes an unordered Markdown list", () => {
const inputs = [ const inputs = [
"- One changenote entry", "- One changenote entry",
"- First item\n- Second item", "- First item\n- Second item",
@@ -42,7 +42,7 @@ await describe("isValidChangenoteContent", async () => {
} }
}); });
await it("does not recognize non-Markdown text", async () => { await it("does not recognize non-Markdown text", () => {
const inputs = [ const inputs = [
"This is not a list.", "This is not a list.",
'["this", "is", "JSON"]', '["this", "is", "JSON"]',
@@ -57,7 +57,7 @@ await describe("isValidChangenoteContent", async () => {
} }
}); });
await it("does not recognize ordered Markdown lists", async () => { await it("does not recognize ordered Markdown lists", () => {
const inputs = [ const inputs = [
"1. First item\n2. Second item", "1. First item\n2. Second item",
"\n\n\n1. First item\n1. Second item", "\n\n\n1. First item\n1. Second item",
@@ -68,7 +68,7 @@ await describe("isValidChangenoteContent", async () => {
} }
}); });
await it("requires all list items to use a hyphen bullet", async () => { await it("requires all list items to use a hyphen bullet", () => {
const inputs = [ const inputs = [
"* Fixed a bug\n* Added feature", "* Fixed a bug\n* Added feature",
"+ Fixed a bug\n+ Added feature", "+ Fixed a bug\n+ Added feature",
@@ -85,7 +85,7 @@ await describe("isValidChangenoteContent", async () => {
} }
}); });
await it("does not contain other Markdown elements", async () => { await it("does not contain other Markdown elements", () => {
const inputs = [ const inputs = [
"- Fixed a bug\n\nParagraph of text", "- Fixed a bug\n\nParagraph of text",
"- Fixed a bug\n\n* Added a feature", "- Fixed a bug\n\n* Added a feature",
@@ -100,7 +100,7 @@ await describe("isValidChangenoteContent", async () => {
}); });
await describe("isValidChangenoteFilename", async () => { await describe("isValidChangenoteFilename", async () => {
await it("accepts valid filenames", async () => { await it("accepts valid filenames", () => {
const inputs = [ const inputs = [
"2023-01-01-fix-bug.md", "2023-01-01-fix-bug.md",
"2023-12-31-add-feature.md", "2023-12-31-add-feature.md",
@@ -112,7 +112,7 @@ await describe("isValidChangenoteFilename", async () => {
} }
}); });
await it("rejects invalid filenames", async () => { await it("rejects invalid filenames", () => {
const inputs = [ const inputs = [
"missing-date-from-filename.md", "missing-date-from-filename.md",
"2021-01-01.md", "2021-01-01.md",
@@ -126,14 +126,14 @@ await describe("isValidChangenoteFilename", async () => {
}); });
await describe("hasValidChangenoteCategory", async () => { await describe("hasValidChangenoteCategory", async () => {
await it("accepts valid categories", async () => { await it("accepts valid categories", () => {
for (const category of Object.keys(VALID_CHANGE_NOTE_CATEGORIES)) { for (const category of Object.keys(VALID_CHANGE_NOTE_CATEGORIES)) {
const frontmatter = { category }; const frontmatter = { category };
assert.equal(hasValidChangenoteCategory(frontmatter), true); assert.equal(hasValidChangenoteCategory(frontmatter), true);
} }
}); });
await it("rejects invalid categories", async () => { await it("rejects invalid categories", () => {
const inputs = [ const inputs = [
"", "",
"invalid-category", "invalid-category",
@@ -150,7 +150,7 @@ await describe("hasValidChangenoteCategory", async () => {
} }
}); });
await it("reject missing category", async () => { await it("reject missing category", () => {
assert.equal(hasValidChangenoteCategory({}), false); assert.equal(hasValidChangenoteCategory({}), false);
assert.equal(hasValidChangenoteCategory({ category: null }), false); assert.equal(hasValidChangenoteCategory({ category: null }), false);
assert.equal(hasValidChangenoteCategory({ category: undefined }), false); assert.equal(hasValidChangenoteCategory({ category: undefined }), false);
@@ -162,7 +162,7 @@ await describe("isValidChangenoteFile", async () => {
await withTmpFile( await withTmpFile(
"2026-01-01-fix-bug.md", "2026-01-01-fix-bug.md",
"---\ncategory: fix\n---\n- Fixed a bug\n", "---\ncategory: fix\n---\n- Fixed a bug\n",
async (filePath) => { (filePath) => {
assert.equal(isValidChangenoteFile(filePath), true); assert.equal(isValidChangenoteFile(filePath), true);
}, },
); );
@@ -172,7 +172,7 @@ await describe("isValidChangenoteFile", async () => {
await withTmpFile( await withTmpFile(
"fix-bug.md", "fix-bug.md",
"---\ncategory: fix\n---\n- Fixed a bug\n", "---\ncategory: fix\n---\n- Fixed a bug\n",
async (filePath) => { (filePath) => {
assert.equal(isValidChangenoteFile(filePath), false); assert.equal(isValidChangenoteFile(filePath), false);
}, },
); );
@@ -182,7 +182,7 @@ await describe("isValidChangenoteFile", async () => {
await withTmpFile( await withTmpFile(
"2026-01-01-fix-bug.md", "2026-01-01-fix-bug.md",
"- Fixed a bug\n", "- Fixed a bug\n",
async (filePath) => { (filePath) => {
assert.equal(isValidChangenoteFile(filePath), false); assert.equal(isValidChangenoteFile(filePath), false);
}, },
); );
@@ -192,7 +192,7 @@ await describe("isValidChangenoteFile", async () => {
await withTmpFile( await withTmpFile(
"2026-01-01-fix-bug.md", "2026-01-01-fix-bug.md",
"---\ncategory: fix\n---\n* Fixed a bug\n", "---\ncategory: fix\n---\n* Fixed a bug\n",
async (filePath) => { (filePath) => {
assert.equal(isValidChangenoteFile(filePath), false); assert.equal(isValidChangenoteFile(filePath), false);
}, },
); );

View File

@@ -1,12 +1,14 @@
{ {
"private": true, "private": true,
"description": "Dependencies for the sync.ts", "description": "Dependencies for codeql-action scripts",
"dependencies": { "dependencies": {
"@actions/core": "^2.0.3", "@actions/core": "^2.0.3",
"@actions/github": "^8.0.1", "@actions/github": "^8.0.1",
"@octokit/core": "^7.0.8", "@octokit/core": "^7.0.8",
"@octokit/plugin-paginate-rest": ">=15.0.0", "@octokit/plugin-paginate-rest": ">=15.0.0",
"@octokit/plugin-rest-endpoint-methods": "^18.0.0", "@octokit/plugin-rest-endpoint-methods": "^18.0.0",
"lite-matter": "^0.1.2",
"mdast-util-from-markdown": "^2.0.3",
"semver": "^7.8.5", "semver": "^7.8.5",
"yaml": "^2.9.0" "yaml": "^2.9.0"
}, },

View File

@@ -6,8 +6,8 @@
"module": "preserve", "module": "preserve",
"rootDir": "..", "rootDir": "..",
"sourceMap": false, "sourceMap": false,
"noEmit": true, "noEmit": true
}, },
"include": ["./*.ts", "../src/**/*.ts"], "include": ["./**/*.ts", "./**/*.mts", "../src/**/*.ts"],
"exclude": ["node_modules"] "exclude": ["node_modules"]
} }

View File

@@ -1,7 +1,9 @@
#!/usr/bin/env npx tsx
import { pathToFileURL } from "node:url"; import { pathToFileURL } from "node:url";
import { parseArgs } from "node:util"; import { parseArgs } from "node:util";
import { isValidChangenoteFile } from "./cli/validate.ts"; import { isValidChangenoteFile } from "./changelog/validate.mjs";
const entryPoint = process.argv[1]; const entryPoint = process.argv[1];
if (entryPoint && import.meta.url === pathToFileURL(entryPoint).href) { if (entryPoint && import.meta.url === pathToFileURL(entryPoint).href) {
@@ -32,7 +34,7 @@ function main(): number {
} }
function usage(): number { function usage(): number {
console.log("Usage: changetool validate <path> [<path> ...]"); console.log(`Usage: validate-changelog.mts validate <path> [<path> ...]`);
return 0; return 0;
} }

View File

@@ -1,21 +0,0 @@
{
"name": "changetool",
"version": "1.0.0",
"private": true,
"description": "Validates change-notes and merges them into CHANGELOG.md",
"license": "MIT",
"type": "module",
"scripts": {
"start": "tsx index.ts",
"test": "node --test --experimental-strip-types cli/*.test.ts"
},
"devDependencies": {
"@types/node": "^26.2.0",
"tsx": "^4.23.13",
"typescript": "^7.0.2"
},
"dependencies": {
"lite-matter": "^0.1.2",
"mdast-util-from-markdown": "^2.0.3"
}
}

View File

@@ -1,11 +0,0 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "preserve",
"allowImportingTsExtensions": true,
"rootDir": ".",
"sourceMap": false
},
"include": ["./**/*.ts"],
"exclude": ["node_modules"]
}

View File

@@ -37,5 +37,5 @@
"@octokit/core/dist-types/types": ["./node_modules/@octokit/core/dist-types/types.d.ts"] "@octokit/core/dist-types/types": ["./node_modules/@octokit/core/dist-types/types.d.ts"]
}, },
}, },
"exclude": ["node_modules", "pr-checks", "scripts/changetool"] "exclude": ["node_modules", "pr-checks"]
} }