Skip to content

Commit 3ff82aa

Browse files
authored
Merge pull request #3575 from github/mbg/ts/sync-checks
Convert `release-branches.py` and `update-required-checks.sh` to TypeScript
2 parents 4bdd4e7 + 972365e commit 3ff82aa

27 files changed

+765
-286
lines changed

.github/actions/release-branches/action.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ runs:
2222
MAJOR_VERSION: ${{ inputs.major_version }}
2323
LATEST_TAG: ${{ inputs.latest_tag }}
2424
run: |
25-
python ${{ github.action_path }}/release-branches.py \
25+
npm ci
26+
npx tsx ./pr-checks/release-branches.ts \
2627
--major-version "$MAJOR_VERSION" \
2728
--latest-tag "$LATEST_TAG"
2829
shell: bash

.github/actions/release-branches/release-branches.py

Lines changed: 0 additions & 55 deletions
This file was deleted.

.github/actions/release-initialise/action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ runs:
1515
run: echo "$GITHUB_CONTEXT"
1616
shell: bash
1717

18+
- name: Set up Node
19+
uses: actions/setup-node@v6
20+
with:
21+
node-version: 20
22+
cache: 'npm'
23+
1824
- name: Set up Python
1925
uses: actions/setup-python@v6
2026
with:

.github/releases.ini

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/script/update-required-checks.sh

Lines changed: 0 additions & 64 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,14 @@ Once the mergeback and backport pull request have been merged, the release is co
6969

7070
## Keeping the PR checks up to date (admin access required)
7171

72-
Since the `codeql-action` runs most of its testing through individual Actions workflows, there are over two hundred required jobs that need to pass in order for a PR to turn green. It would be too tedious to maintain that list manually. You can regenerate the set of required checks automatically by running the [update-required-checks.sh](.github/workflows/script/update-required-checks.sh) script:
72+
Since the `codeql-action` runs most of its testing through individual Actions workflows, there are over two hundred required jobs that need to pass in order for a PR to turn green. It would be too tedious to maintain that list manually. You can regenerate the set of required checks automatically by running the [sync-checks.ts](pr-checks/sync-checks.ts) script:
7373

74-
- If you run the script without an argument, it will retrieve the set of workflows that ran for the latest commit on `main`. Make sure that your local `main` branch is up to date before running the script.
75-
- You can specify a commit SHA as argument to retrieve the set of workflows for that commit instead. You will likely want to use this if you have a PR that removes or adds PR checks.
74+
- At a minimum, you must provide an argument for the `--token` input. For example, `--token "$(gh auth token)"` to use the same token that `gh` uses. If no token is provided or the token has insufficient permissions, the script will fail.
75+
- By default, the script performs a dry run and outputs information about the changes it would make to the branch protection rules. To actually apply the changes, specify the `--apply` flag.
76+
- If you run the script without any other arguments, it will retrieve the set of workflows that ran for the latest commit on `main`.
77+
- You can specify a different git ref with the `--ref` input. You will likely want to use this if you have a PR that removes or adds PR checks. For example, `--ref "some/branch/name"` to use the HEAD of the `some/branch/name` branch.
7678

77-
After running, go to the [branch protection rules settings page](https://github.com/github/codeql-action/settings/branches) and validate that the rules for `main`, `v3`, and any other currently supported major versions have been updated.
79+
After running, go to the [branch protection rules settings page](https://github.com/github/codeql-action/settings/branches) and validate that the rules for `main`, `v4`, and any other currently supported major versions have been updated.
7880

7981
Note that any updates to checks on `main` need to be backported to all currently supported major version branches, in order to maintain the same set of names for required checks.
8082

@@ -122,7 +124,7 @@ To deprecate an older version of the Action:
122124
- Implement an Actions warning for customers using the deprecated version.
123125
1. Wait for the deprecation period to pass.
124126
1. Upgrade the Actions warning for customers using the deprecated version to a non-fatal error, and mention that this version of the Action is no longer supported.
125-
1. Make a PR to bump the `OLDEST_SUPPORTED_MAJOR_VERSION` in [releases.ini](.github/releases.ini). Once this PR is merged, the release process will no longer backport changes to the deprecated release version.
127+
1. Make a PR to bump the `OLDEST_SUPPORTED_MAJOR_VERSION` in [config.ts](pr-checks/config.ts). Once this PR is merged, the release process will no longer backport changes to the deprecated release version.
126128

127129
## Resources
128130

eslint.config.mjs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ import noAsyncForeach from "eslint-plugin-no-async-foreach";
77
import jsdoc from "eslint-plugin-jsdoc";
88
import tseslint from "typescript-eslint";
99
import globals from "globals";
10+
import path from "path";
11+
import { fileURLToPath } from "url";
1012

13+
const __filename = fileURLToPath(import.meta.url);
14+
const __dirname = path.dirname(__filename);
1115
const githubFlatConfigs = github.getFlatConfigs();
1216

1317
export default [
@@ -43,7 +47,7 @@ export default [
4347
plugins: {
4448
"import-x": importX,
4549
"no-async-foreach": fixupPluginRules(noAsyncForeach),
46-
"jsdoc": jsdoc,
50+
jsdoc: jsdoc,
4751
},
4852

4953
languageOptions: {
@@ -67,7 +71,13 @@ export default [
6771

6872
typescript: {},
6973
},
70-
"import/ignore": ["sinon", "uuid", "@octokit/plugin-retry", "del", "get-folder-size"],
74+
"import/ignore": [
75+
"sinon",
76+
"uuid",
77+
"@octokit/plugin-retry",
78+
"del",
79+
"get-folder-size",
80+
],
7181
"import-x/resolver-next": [
7282
createTypeScriptImportResolver(),
7383
createNodeResolver({
@@ -143,7 +153,7 @@ export default [
143153
// We don't currently require full JSDoc coverage, so this rule
144154
// should not error on missing @param annotations.
145155
disableMissingParamChecks: true,
146-
}
156+
},
147157
],
148158
},
149159
},
@@ -162,9 +172,9 @@ export default [
162172
"@typescript-eslint/no-unused-vars": [
163173
"error",
164174
{
165-
"args": "all",
166-
"argsIgnorePattern": "^_",
167-
}
175+
args: "all",
176+
argsIgnorePattern: "^_",
177+
},
168178
],
169179
"func-style": "off",
170180
},
@@ -183,6 +193,11 @@ export default [
183193
// The scripts in `pr-checks` are expected to output to the console.
184194
"no-console": "off",
185195

196+
"import/no-extraneous-dependencies": [
197+
"error",
198+
{ packageDir: [__dirname, path.resolve(__dirname, "pr-checks")] },
199+
],
200+
186201
"@typescript-eslint/no-floating-promises": [
187202
"error",
188203
{

lib/analyze-action-post.js

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/analyze-action.js

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)