Merge pull request #4200 from github/mbg/esm/migrate-pr-checks

Fully migrate `pr-checks` to ESM
This commit is contained in:
Michael B. Gale
2026-10-06 19:24:52 +00:00
committed by GitHub
21 changed files with 55 additions and 29 deletions
+2 -2
View File
@@ -128,9 +128,9 @@ jobs:
working-directory: pr-checks
run: npx tsx --test
- name: Run `pr-checks/changenotes.mts` to ensure that all unreleased change notes are valid
- name: Run `pr-checks/changenotes.ts` to ensure that all unreleased change notes are valid
if: ${{ !cancelled() && steps.install-deps.outcome == 'success' }}
run: npx tsx pr-checks/changenotes.mts validate
run: npx tsx pr-checks/changenotes.ts validate
- name: Verify all Actions use the same Node version
id: head-version
+2 -2
View File
@@ -158,7 +158,7 @@ export default [
},
},
{
files: ["**/*.ts", "**/*.js", "**/*.mts"],
files: ["**/*.ts", "**/*.js"],
rules: {
"@typescript-eslint/no-explicit-any": "off",
@@ -180,7 +180,7 @@ export default [
},
},
{
files: ["pr-checks/**/*.ts", "pr-checks/**/*.mts"],
files: ["pr-checks/**/*.ts"],
languageOptions: {
parserOptions: {
+18 -1
View File
@@ -10508,9 +10508,26 @@
"yaml": "^2.9.1"
},
"devDependencies": {
"@types/node": "^20.19.43",
"@types/node": "^24.19.0",
"tsx": "^4.23.15"
}
},
"pr-checks/node_modules/@types/node": {
"version": "24.19.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.19.0.tgz",
"integrity": "sha512-zY+5tKxXdhGh1PYI0ac+7juvEu4OI6vWtVVoj5i2m42jxAY1U+zHGt6QCyOFwykdP62sM3MJ9stoYYUw5aCWew==",
"dev": true,
"license": "MIT",
"dependencies": {
"undici-types": ">=7.24.0 <7.24.7"
}
},
"pr-checks/node_modules/undici-types": {
"version": "7.24.6",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.24.6.tgz",
"integrity": "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==",
"dev": true,
"license": "MIT"
}
}
}
+1
View File
@@ -0,0 +1 @@
24
+1 -1
View File
@@ -122,6 +122,6 @@ function main() {
}
// Only call `main` if this script was run directly.
if (require.main === module) {
if (import.meta.main) {
process.exit(main());
}
+1 -1
View File
@@ -43,6 +43,6 @@ async function main() {
}
// Only call `main` if this script was run directly.
if (require.main === module) {
if (import.meta.main) {
void main();
}
@@ -9,7 +9,7 @@ import {
isValidChangenoteFile,
isValidChangenoteFilename,
VALID_CHANGE_NOTE_CATEGORIES,
} from "./validate.mjs";
} from "./validate";
await describe("isValidChangenoteContent", async () => {
await it("recognizes an unordered Markdown list", () => {
@@ -14,7 +14,7 @@ import {
renderChangelog,
withChangelog,
} from "./changelog";
import { isValidChangenoteFile } from "./changelog/validate.mjs";
import { isValidChangenoteFile } from "./changelog/validate";
import { CHANGENOTES_DIR } from "./config";
/**
@@ -82,9 +82,9 @@ function main(): ExitCode {
function usage(): ExitCode {
const message =
"Usage: changenotes.mts assemble\n" +
" changenotes.mts validate\n" +
" changenotes.mts help";
"Usage: changenotes.ts assemble\n" +
" changenotes.ts validate\n" +
" changenotes.ts help";
console.log(message);
return ExitCode.Success;
}
+1 -1
View File
@@ -218,6 +218,6 @@ async function run(): Promise<void> {
}
}
if (require.main === module) {
if (import.meta.main) {
void run();
}
+5
View File
@@ -1,4 +1,9 @@
import path from "path";
import { fileURLToPath } from "url";
// For backwards-compatibility.
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
/** The oldest supported major version of the CodeQL Action. */
export const OLDEST_SUPPORTED_MAJOR_VERSION = 3;
+2 -1
View File
@@ -1,6 +1,7 @@
{
"private": true,
"description": "Dependencies for codeql-action scripts",
"type": "module",
"dependencies": {
"@actions/core": "^2.0.3",
"@actions/github": "^8.0.1",
@@ -13,7 +14,7 @@
"yaml": "^2.9.1"
},
"devDependencies": {
"@types/node": "^20.19.43",
"@types/node": "^24.19.0",
"tsx": "^4.23.15"
}
}
+1 -1
View File
@@ -77,6 +77,6 @@ function main() {
}
// Only call `main` if this script was run directly.
if (require.main === module) {
if (import.meta.main) {
process.exit(main());
}
+1 -1
View File
@@ -116,6 +116,6 @@ async function main() {
}
// Only call `main` if this script was run directly.
if (require.main === module) {
if (import.meta.main) {
void main();
}
+1 -1
View File
@@ -79,6 +79,6 @@ function main() {
}
// Only call `main` if this script was run directly.
if (require.main === module) {
if (import.meta.main) {
process.exit(main());
}
+6 -5
View File
@@ -21,10 +21,11 @@ import * as fs from "fs";
import { parseArgs } from "node:util";
import * as path from "path";
const THIS_DIR = __dirname;
const CHECKS_DIR = path.join(THIS_DIR, "checks");
const WORKFLOW_DIR = path.join(THIS_DIR, "..", ".github", "workflows");
const SYNC_TS_PATH = path.join(THIS_DIR, "sync.ts");
import { PR_CHECKS_DIR, REPO_ROOT } from "./config";
const CHECKS_DIR = path.join(PR_CHECKS_DIR, "checks");
const WORKFLOW_DIR = path.join(REPO_ROOT, ".github", "workflows");
const SYNC_TS_PATH = path.join(PR_CHECKS_DIR, "sync.ts");
/**
* Scan generated workflow files to extract the latest action versions.
@@ -232,6 +233,6 @@ function main(): number {
}
// Only call `main` if this script was run directly.
if (require.main === module) {
if (import.meta.main) {
process.exit(main());
}
+1 -1
View File
@@ -342,6 +342,6 @@ async function main(): Promise<void> {
}
// Only call `main` if this script was run directly.
if (require.main === module) {
if (import.meta.main) {
void main();
}
+4 -3
View File
@@ -7,6 +7,8 @@ import * as yaml from "yaml";
import { BuiltInLanguage } from "../src/languages";
import { PR_CHECKS_DIR, REPO_ROOT } from "./config";
/**
* Returns a `uses` value for `action` pinned to a commit SHA, with the
* human-readable version recorded in a trailing comment.
@@ -312,9 +314,8 @@ const languageSetups: LanguageSetups = {
// See https://github.com/github/codeql-action/pull/3423
const YQ_VERSION = "v4.50.1";
const THIS_DIR = __dirname;
const CHECKS_DIR = path.join(THIS_DIR, "checks");
const OUTPUT_DIR = path.join(THIS_DIR, "..", ".github", "workflows");
const CHECKS_DIR = path.join(PR_CHECKS_DIR, "checks");
const OUTPUT_DIR = path.join(REPO_ROOT, ".github", "workflows");
/**
* Loads and parses a YAML file.
+1 -1
View File
@@ -8,6 +8,6 @@
"sourceMap": false,
"noEmit": true
},
"include": ["./**/*.ts", "./**/*.mts", "../src/**/*.ts"],
"include": ["./**/*.ts", "../src/**/*.ts"],
"exclude": ["node_modules"]
}
+1 -1
View File
@@ -238,6 +238,6 @@ function main() {
}
// Only call `main` if this script was run directly.
if (require.main === module) {
if (import.meta.main) {
main();
}
+1 -1
View File
@@ -835,6 +835,6 @@ async function main(): Promise<void> {
}
// Only call `main` if this script was run directly.
if (require.main === module) {
if (import.meta.main) {
void main();
}