diff --git a/.github/actions/release-branches/action.yml b/.github/actions/release-branches/action.yml index 1807c0a3c0..26be726205 100644 --- a/.github/actions/release-branches/action.yml +++ b/.github/actions/release-branches/action.yml @@ -22,7 +22,8 @@ runs: MAJOR_VERSION: ${{ inputs.major_version }} LATEST_TAG: ${{ inputs.latest_tag }} run: | - python ${{ github.action_path }}/release-branches.py \ + npm ci + npx tsx ./pr-checks/release-branches.ts \ --major-version "$MAJOR_VERSION" \ --latest-tag "$LATEST_TAG" shell: bash diff --git a/.github/actions/release-branches/release-branches.py b/.github/actions/release-branches/release-branches.py deleted file mode 100644 index ad941bb0c3..0000000000 --- a/.github/actions/release-branches/release-branches.py +++ /dev/null @@ -1,55 +0,0 @@ -import argparse -import json -import os -import configparser - -# Name of the remote -ORIGIN = 'origin' - -script_dir = os.path.dirname(os.path.realpath(__file__)) -grandparent_dir = os.path.dirname(os.path.dirname(script_dir)) - -config = configparser.ConfigParser() -with open(os.path.join(grandparent_dir, 'releases.ini')) as stream: - config.read_string('[default]\n' + stream.read()) - -OLDEST_SUPPORTED_MAJOR_VERSION = int(config['default']['OLDEST_SUPPORTED_MAJOR_VERSION']) - -def main(): - - parser = argparse.ArgumentParser() - parser.add_argument("--major-version", required=True, type=str, help="The major version of the release") - parser.add_argument("--latest-tag", required=True, type=str, help="The most recent tag published to the repository") - args = parser.parse_args() - - major_version = args.major_version - latest_tag = args.latest_tag - - print("major_version: " + major_version) - print("latest_tag: " + latest_tag) - - # If this is a primary release, we backport to all supported branches, - # so we check whether the major_version taken from the package.json - # is greater than or equal to the latest tag pulled from the repo. - # For example... - # 'v1' >= 'v2' is False # we're operating from an older release branch and should not backport - # 'v2' >= 'v2' is True # the normal case where we're updating the current version - # 'v3' >= 'v2' is True # in this case we are making the first release of a new major version - consider_backports = ( major_version >= latest_tag.split(".")[0] ) - - with open(os.environ["GITHUB_OUTPUT"], "a") as f: - - f.write(f"backport_source_branch=releases/{major_version}\n") - - backport_target_branches = [] - - if consider_backports: - for i in range(int(major_version.strip("v"))-1, 0, -1): - branch_name = f"releases/v{i}" - if i >= OLDEST_SUPPORTED_MAJOR_VERSION: - backport_target_branches.append(branch_name) - - f.write("backport_target_branches="+json.dumps(backport_target_branches)+"\n") - -if __name__ == "__main__": - main() diff --git a/.github/actions/release-initialise/action.yml b/.github/actions/release-initialise/action.yml index c21772b149..2ff616ce4c 100644 --- a/.github/actions/release-initialise/action.yml +++ b/.github/actions/release-initialise/action.yml @@ -15,6 +15,12 @@ runs: run: echo "$GITHUB_CONTEXT" shell: bash + - name: Set up Node + uses: actions/setup-node@v6 + with: + node-version: 20 + cache: 'npm' + - name: Set up Python uses: actions/setup-python@v6 with: diff --git a/.github/releases.ini b/.github/releases.ini deleted file mode 100644 index 69afa026d4..0000000000 --- a/.github/releases.ini +++ /dev/null @@ -1 +0,0 @@ -OLDEST_SUPPORTED_MAJOR_VERSION=3 diff --git a/.github/workflows/script/update-required-checks.sh b/.github/workflows/script/update-required-checks.sh deleted file mode 100755 index f6a4c4f5c8..0000000000 --- a/.github/workflows/script/update-required-checks.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env bash -# Update the required checks based on the current branch. - -set -euo pipefail - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -REPO_DIR="$(dirname "$SCRIPT_DIR")" -GRANDPARENT_DIR="$(dirname "$REPO_DIR")" -source "$GRANDPARENT_DIR/releases.ini" - -if ! gh auth status 2>/dev/null; then - gh auth status - echo "Failed: Not authorized. This script requires admin access to github/codeql-action through the gh CLI." - exit 1 -fi - -if [ "$#" -eq 1 ]; then - # If we were passed an argument, use that as the SHA - GITHUB_SHA="$1" -elif [ "$#" -gt 1 ]; then - echo "Usage: $0 [SHA]" - echo "Update the required checks based on the SHA, or main." - exit 1 -elif [ -z "$GITHUB_SHA" ]; then - # If we don't have a SHA, use main - GITHUB_SHA="$(git rev-parse main)" -fi - -echo "Getting checks for $GITHUB_SHA" - -# Ignore any checks with "https://", CodeQL, LGTM, Update, and ESLint checks. -CHECKS="$(gh api repos/github/codeql-action/commits/"${GITHUB_SHA}"/check-runs --paginate | jq --slurp --compact-output --raw-output '[.[].check_runs.[] | select(.conclusion != "skipped") | .name | select(contains("https://") or . == "CodeQL" or . == "Dependabot" or . == "check-expected-release-files" or contains("Update") or contains("ESLint") or contains("update") or contains("test-setup-python-scripts") or . == "Agent" or . == "Cleanup artifacts" or . == "Prepare" or . == "Upload results" or . == "Label PR with size" | not)] | unique | sort')" - -echo "$CHECKS" | jq - -# Fail if there are no checks -if [ -z "$CHECKS" ] || [ "$(echo "$CHECKS" | jq '. | length')" -eq 0 ]; then - echo "No checks found for $GITHUB_SHA" - exit 1 -fi - -echo "{\"contexts\": ${CHECKS}}" > checks.json - -echo "Updating main" -gh api --silent -X "PATCH" "repos/github/codeql-action/branches/main/protection/required_status_checks" --input checks.json - -# list all branchs on origin remote matching releases/v* -BRANCHES="$(git ls-remote --heads origin 'releases/v*' | sed 's?.*refs/heads/??' | sort -V)" - -for BRANCH in $BRANCHES; do - - # strip exact 'releases/v' prefix from $BRANCH using count of characters - VERSION="${BRANCH:10}" - - if [ "$VERSION" -lt "$OLDEST_SUPPORTED_MAJOR_VERSION" ]; then - echo "Skipping $BRANCH" - continue - fi - - echo "Updating $BRANCH" - gh api --silent -X "PATCH" "repos/github/codeql-action/branches/$BRANCH/protection/required_status_checks" --input checks.json -done - -rm checks.json diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 26e06e30d3..2360f19f9d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -69,12 +69,14 @@ Once the mergeback and backport pull request have been merged, the release is co ## Keeping the PR checks up to date (admin access required) -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: +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: -- 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. -- 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. +- 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. +- 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. +- If you run the script without any other arguments, it will retrieve the set of workflows that ran for the latest commit on `main`. +- 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. -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. +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. 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. @@ -122,7 +124,7 @@ To deprecate an older version of the Action: - Implement an Actions warning for customers using the deprecated version. 1. Wait for the deprecation period to pass. 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. -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. +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. ## Resources diff --git a/eslint.config.mjs b/eslint.config.mjs index bc77329978..34fe49a9df 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -7,7 +7,11 @@ import noAsyncForeach from "eslint-plugin-no-async-foreach"; import jsdoc from "eslint-plugin-jsdoc"; import tseslint from "typescript-eslint"; import globals from "globals"; +import path from "path"; +import { fileURLToPath } from "url"; +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); const githubFlatConfigs = github.getFlatConfigs(); export default [ @@ -43,7 +47,7 @@ export default [ plugins: { "import-x": importX, "no-async-foreach": fixupPluginRules(noAsyncForeach), - "jsdoc": jsdoc, + jsdoc: jsdoc, }, languageOptions: { @@ -67,7 +71,13 @@ export default [ typescript: {}, }, - "import/ignore": ["sinon", "uuid", "@octokit/plugin-retry", "del", "get-folder-size"], + "import/ignore": [ + "sinon", + "uuid", + "@octokit/plugin-retry", + "del", + "get-folder-size", + ], "import-x/resolver-next": [ createTypeScriptImportResolver(), createNodeResolver({ @@ -143,7 +153,7 @@ export default [ // We don't currently require full JSDoc coverage, so this rule // should not error on missing @param annotations. disableMissingParamChecks: true, - } + }, ], }, }, @@ -162,9 +172,9 @@ export default [ "@typescript-eslint/no-unused-vars": [ "error", { - "args": "all", - "argsIgnorePattern": "^_", - } + args: "all", + argsIgnorePattern: "^_", + }, ], "func-style": "off", }, @@ -183,6 +193,11 @@ export default [ // The scripts in `pr-checks` are expected to output to the console. "no-console": "off", + "import/no-extraneous-dependencies": [ + "error", + { packageDir: [__dirname, path.resolve(__dirname, "pr-checks")] }, + ], + "@typescript-eslint/no-floating-promises": [ "error", { diff --git a/lib/analyze-action-post.js b/lib/analyze-action-post.js index 75be56ced1..cbcb7cfaee 100644 --- a/lib/analyze-action-post.js +++ b/lib/analyze-action-post.js @@ -41057,18 +41057,18 @@ var init_dist_src2 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js var VERSION5; var init_version2 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { VERSION5 = "17.0.0"; } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js var Endpoints, endpoints_default; var init_endpoints = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { Endpoints = { actions: { addCustomLabelsToSelfHostedRunnerForOrg: [ @@ -43362,7 +43362,7 @@ var init_endpoints = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js function endpointsToMethods(octokit) { const newMethods = {}; for (const scope of endpointMethodsMap.keys()) { @@ -43413,7 +43413,7 @@ function decorate(octokit, scope, methodName, defaults, decorations) { } var endpointMethodsMap, handler; var init_endpoints_to_methods = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { init_endpoints(); endpointMethodsMap = /* @__PURE__ */ new Map(); for (const [scope, endpoints] of Object.entries(endpoints_default)) { @@ -43491,7 +43491,7 @@ var init_endpoints_to_methods = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js var dist_src_exports2 = {}; __export(dist_src_exports2, { legacyRestEndpointMethods: () => legacyRestEndpointMethods, @@ -43511,7 +43511,7 @@ function legacyRestEndpointMethods(octokit) { }; } var init_dist_src3 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { init_version2(); init_endpoints_to_methods(); restEndpointMethods.VERSION = VERSION5; @@ -43519,7 +43519,7 @@ var init_dist_src3 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js +// node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js var dist_bundle_exports = {}; __export(dist_bundle_exports, { composePaginateRest: () => composePaginateRest, @@ -43645,7 +43645,7 @@ function paginateRest(octokit) { } var VERSION6, composePaginateRest, paginatingEndpoints; var init_dist_bundle5 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { + "node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { VERSION6 = "0.0.0-development"; composePaginateRest = Object.assign(paginate, { iterator diff --git a/lib/analyze-action.js b/lib/analyze-action.js index 268cfad571..017b3cd10e 100644 --- a/lib/analyze-action.js +++ b/lib/analyze-action.js @@ -41057,18 +41057,18 @@ var init_dist_src2 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js var VERSION5; var init_version2 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { VERSION5 = "17.0.0"; } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js var Endpoints, endpoints_default; var init_endpoints = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { Endpoints = { actions: { addCustomLabelsToSelfHostedRunnerForOrg: [ @@ -43362,7 +43362,7 @@ var init_endpoints = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js function endpointsToMethods(octokit) { const newMethods = {}; for (const scope of endpointMethodsMap.keys()) { @@ -43413,7 +43413,7 @@ function decorate(octokit, scope, methodName, defaults, decorations) { } var endpointMethodsMap, handler; var init_endpoints_to_methods = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { init_endpoints(); endpointMethodsMap = /* @__PURE__ */ new Map(); for (const [scope, endpoints] of Object.entries(endpoints_default)) { @@ -43491,7 +43491,7 @@ var init_endpoints_to_methods = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js var dist_src_exports2 = {}; __export(dist_src_exports2, { legacyRestEndpointMethods: () => legacyRestEndpointMethods, @@ -43511,7 +43511,7 @@ function legacyRestEndpointMethods(octokit) { }; } var init_dist_src3 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { init_version2(); init_endpoints_to_methods(); restEndpointMethods.VERSION = VERSION5; @@ -43519,7 +43519,7 @@ var init_dist_src3 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js +// node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js var dist_bundle_exports = {}; __export(dist_bundle_exports, { composePaginateRest: () => composePaginateRest, @@ -43645,7 +43645,7 @@ function paginateRest(octokit) { } var VERSION6, composePaginateRest, paginatingEndpoints; var init_dist_bundle5 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { + "node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { VERSION6 = "0.0.0-development"; composePaginateRest = Object.assign(paginate, { iterator diff --git a/lib/autobuild-action.js b/lib/autobuild-action.js index 7720f03cb0..1f629463ad 100644 --- a/lib/autobuild-action.js +++ b/lib/autobuild-action.js @@ -41057,18 +41057,18 @@ var init_dist_src2 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js var VERSION5; var init_version2 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { VERSION5 = "17.0.0"; } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js var Endpoints, endpoints_default; var init_endpoints = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { Endpoints = { actions: { addCustomLabelsToSelfHostedRunnerForOrg: [ @@ -43362,7 +43362,7 @@ var init_endpoints = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js function endpointsToMethods(octokit) { const newMethods = {}; for (const scope of endpointMethodsMap.keys()) { @@ -43413,7 +43413,7 @@ function decorate(octokit, scope, methodName, defaults, decorations) { } var endpointMethodsMap, handler; var init_endpoints_to_methods = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { init_endpoints(); endpointMethodsMap = /* @__PURE__ */ new Map(); for (const [scope, endpoints] of Object.entries(endpoints_default)) { @@ -43491,7 +43491,7 @@ var init_endpoints_to_methods = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js var dist_src_exports2 = {}; __export(dist_src_exports2, { legacyRestEndpointMethods: () => legacyRestEndpointMethods, @@ -43511,7 +43511,7 @@ function legacyRestEndpointMethods(octokit) { }; } var init_dist_src3 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { init_version2(); init_endpoints_to_methods(); restEndpointMethods.VERSION = VERSION5; @@ -43519,7 +43519,7 @@ var init_dist_src3 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js +// node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js var dist_bundle_exports = {}; __export(dist_bundle_exports, { composePaginateRest: () => composePaginateRest, @@ -43645,7 +43645,7 @@ function paginateRest(octokit) { } var VERSION6, composePaginateRest, paginatingEndpoints; var init_dist_bundle5 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { + "node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { VERSION6 = "0.0.0-development"; composePaginateRest = Object.assign(paginate, { iterator diff --git a/lib/init-action-post.js b/lib/init-action-post.js index 341449f7e1..691734e51a 100644 --- a/lib/init-action-post.js +++ b/lib/init-action-post.js @@ -41057,18 +41057,18 @@ var init_dist_src2 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js var VERSION5; var init_version2 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { VERSION5 = "17.0.0"; } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js var Endpoints, endpoints_default; var init_endpoints = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { Endpoints = { actions: { addCustomLabelsToSelfHostedRunnerForOrg: [ @@ -43362,7 +43362,7 @@ var init_endpoints = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js function endpointsToMethods(octokit) { const newMethods = {}; for (const scope of endpointMethodsMap.keys()) { @@ -43413,7 +43413,7 @@ function decorate(octokit, scope, methodName, defaults, decorations) { } var endpointMethodsMap, handler; var init_endpoints_to_methods = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { init_endpoints(); endpointMethodsMap = /* @__PURE__ */ new Map(); for (const [scope, endpoints] of Object.entries(endpoints_default)) { @@ -43491,7 +43491,7 @@ var init_endpoints_to_methods = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js var dist_src_exports2 = {}; __export(dist_src_exports2, { legacyRestEndpointMethods: () => legacyRestEndpointMethods, @@ -43511,7 +43511,7 @@ function legacyRestEndpointMethods(octokit) { }; } var init_dist_src3 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { init_version2(); init_endpoints_to_methods(); restEndpointMethods.VERSION = VERSION5; @@ -43519,7 +43519,7 @@ var init_dist_src3 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js +// node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js var dist_bundle_exports = {}; __export(dist_bundle_exports, { composePaginateRest: () => composePaginateRest, @@ -43645,7 +43645,7 @@ function paginateRest(octokit) { } var VERSION6, composePaginateRest, paginatingEndpoints; var init_dist_bundle5 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { + "node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { VERSION6 = "0.0.0-development"; composePaginateRest = Object.assign(paginate, { iterator diff --git a/lib/init-action.js b/lib/init-action.js index ec26268cb9..204c408136 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -41057,18 +41057,18 @@ var init_dist_src2 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js var VERSION5; var init_version2 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { VERSION5 = "17.0.0"; } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js var Endpoints, endpoints_default; var init_endpoints = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { Endpoints = { actions: { addCustomLabelsToSelfHostedRunnerForOrg: [ @@ -43362,7 +43362,7 @@ var init_endpoints = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js function endpointsToMethods(octokit) { const newMethods = {}; for (const scope of endpointMethodsMap.keys()) { @@ -43413,7 +43413,7 @@ function decorate(octokit, scope, methodName, defaults, decorations) { } var endpointMethodsMap, handler; var init_endpoints_to_methods = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { init_endpoints(); endpointMethodsMap = /* @__PURE__ */ new Map(); for (const [scope, endpoints] of Object.entries(endpoints_default)) { @@ -43491,7 +43491,7 @@ var init_endpoints_to_methods = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js var dist_src_exports2 = {}; __export(dist_src_exports2, { legacyRestEndpointMethods: () => legacyRestEndpointMethods, @@ -43511,7 +43511,7 @@ function legacyRestEndpointMethods(octokit) { }; } var init_dist_src3 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { init_version2(); init_endpoints_to_methods(); restEndpointMethods.VERSION = VERSION5; @@ -43519,7 +43519,7 @@ var init_dist_src3 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js +// node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js var dist_bundle_exports = {}; __export(dist_bundle_exports, { composePaginateRest: () => composePaginateRest, @@ -43645,7 +43645,7 @@ function paginateRest(octokit) { } var VERSION6, composePaginateRest, paginatingEndpoints; var init_dist_bundle5 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { + "node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { VERSION6 = "0.0.0-development"; composePaginateRest = Object.assign(paginate, { iterator diff --git a/lib/resolve-environment-action.js b/lib/resolve-environment-action.js index cefba2d562..c3ca1c028e 100644 --- a/lib/resolve-environment-action.js +++ b/lib/resolve-environment-action.js @@ -41057,18 +41057,18 @@ var init_dist_src2 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js var VERSION5; var init_version2 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { VERSION5 = "17.0.0"; } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js var Endpoints, endpoints_default; var init_endpoints = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { Endpoints = { actions: { addCustomLabelsToSelfHostedRunnerForOrg: [ @@ -43362,7 +43362,7 @@ var init_endpoints = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js function endpointsToMethods(octokit) { const newMethods = {}; for (const scope of endpointMethodsMap.keys()) { @@ -43413,7 +43413,7 @@ function decorate(octokit, scope, methodName, defaults, decorations) { } var endpointMethodsMap, handler; var init_endpoints_to_methods = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { init_endpoints(); endpointMethodsMap = /* @__PURE__ */ new Map(); for (const [scope, endpoints] of Object.entries(endpoints_default)) { @@ -43491,7 +43491,7 @@ var init_endpoints_to_methods = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js var dist_src_exports2 = {}; __export(dist_src_exports2, { legacyRestEndpointMethods: () => legacyRestEndpointMethods, @@ -43511,7 +43511,7 @@ function legacyRestEndpointMethods(octokit) { }; } var init_dist_src3 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { init_version2(); init_endpoints_to_methods(); restEndpointMethods.VERSION = VERSION5; @@ -43519,7 +43519,7 @@ var init_dist_src3 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js +// node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js var dist_bundle_exports = {}; __export(dist_bundle_exports, { composePaginateRest: () => composePaginateRest, @@ -43645,7 +43645,7 @@ function paginateRest(octokit) { } var VERSION6, composePaginateRest, paginatingEndpoints; var init_dist_bundle5 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { + "node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { VERSION6 = "0.0.0-development"; composePaginateRest = Object.assign(paginate, { iterator diff --git a/lib/setup-codeql-action.js b/lib/setup-codeql-action.js index 8fcb624980..b95b31cfe6 100644 --- a/lib/setup-codeql-action.js +++ b/lib/setup-codeql-action.js @@ -41057,18 +41057,18 @@ var init_dist_src2 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js var VERSION5; var init_version2 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { VERSION5 = "17.0.0"; } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js var Endpoints, endpoints_default; var init_endpoints = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { Endpoints = { actions: { addCustomLabelsToSelfHostedRunnerForOrg: [ @@ -43362,7 +43362,7 @@ var init_endpoints = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js function endpointsToMethods(octokit) { const newMethods = {}; for (const scope of endpointMethodsMap.keys()) { @@ -43413,7 +43413,7 @@ function decorate(octokit, scope, methodName, defaults, decorations) { } var endpointMethodsMap, handler; var init_endpoints_to_methods = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { init_endpoints(); endpointMethodsMap = /* @__PURE__ */ new Map(); for (const [scope, endpoints] of Object.entries(endpoints_default)) { @@ -43491,7 +43491,7 @@ var init_endpoints_to_methods = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js var dist_src_exports2 = {}; __export(dist_src_exports2, { legacyRestEndpointMethods: () => legacyRestEndpointMethods, @@ -43511,7 +43511,7 @@ function legacyRestEndpointMethods(octokit) { }; } var init_dist_src3 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { init_version2(); init_endpoints_to_methods(); restEndpointMethods.VERSION = VERSION5; @@ -43519,7 +43519,7 @@ var init_dist_src3 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js +// node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js var dist_bundle_exports = {}; __export(dist_bundle_exports, { composePaginateRest: () => composePaginateRest, @@ -43645,7 +43645,7 @@ function paginateRest(octokit) { } var VERSION6, composePaginateRest, paginatingEndpoints; var init_dist_bundle5 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { + "node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { VERSION6 = "0.0.0-development"; composePaginateRest = Object.assign(paginate, { iterator diff --git a/lib/start-proxy-action-post.js b/lib/start-proxy-action-post.js index 0160eecbd9..d9c4ba3dd2 100644 --- a/lib/start-proxy-action-post.js +++ b/lib/start-proxy-action-post.js @@ -41057,18 +41057,18 @@ var init_dist_src2 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js var VERSION5; var init_version2 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { VERSION5 = "17.0.0"; } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js var Endpoints, endpoints_default; var init_endpoints = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { Endpoints = { actions: { addCustomLabelsToSelfHostedRunnerForOrg: [ @@ -43362,7 +43362,7 @@ var init_endpoints = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js function endpointsToMethods(octokit) { const newMethods = {}; for (const scope of endpointMethodsMap.keys()) { @@ -43413,7 +43413,7 @@ function decorate(octokit, scope, methodName, defaults, decorations) { } var endpointMethodsMap, handler; var init_endpoints_to_methods = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { init_endpoints(); endpointMethodsMap = /* @__PURE__ */ new Map(); for (const [scope, endpoints] of Object.entries(endpoints_default)) { @@ -43491,7 +43491,7 @@ var init_endpoints_to_methods = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js var dist_src_exports2 = {}; __export(dist_src_exports2, { legacyRestEndpointMethods: () => legacyRestEndpointMethods, @@ -43511,7 +43511,7 @@ function legacyRestEndpointMethods(octokit) { }; } var init_dist_src3 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { init_version2(); init_endpoints_to_methods(); restEndpointMethods.VERSION = VERSION5; @@ -43519,7 +43519,7 @@ var init_dist_src3 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js +// node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js var dist_bundle_exports = {}; __export(dist_bundle_exports, { composePaginateRest: () => composePaginateRest, @@ -43645,7 +43645,7 @@ function paginateRest(octokit) { } var VERSION6, composePaginateRest, paginatingEndpoints; var init_dist_bundle5 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { + "node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { VERSION6 = "0.0.0-development"; composePaginateRest = Object.assign(paginate, { iterator diff --git a/lib/start-proxy-action.js b/lib/start-proxy-action.js index a1b8a027f8..3845eabfdb 100644 --- a/lib/start-proxy-action.js +++ b/lib/start-proxy-action.js @@ -41057,18 +41057,18 @@ var init_dist_src2 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js var VERSION5; var init_version2 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { VERSION5 = "17.0.0"; } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js var Endpoints, endpoints_default; var init_endpoints = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { Endpoints = { actions: { addCustomLabelsToSelfHostedRunnerForOrg: [ @@ -43362,7 +43362,7 @@ var init_endpoints = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js function endpointsToMethods(octokit) { const newMethods = {}; for (const scope of endpointMethodsMap.keys()) { @@ -43413,7 +43413,7 @@ function decorate(octokit, scope, methodName, defaults, decorations) { } var endpointMethodsMap, handler; var init_endpoints_to_methods = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { init_endpoints(); endpointMethodsMap = /* @__PURE__ */ new Map(); for (const [scope, endpoints] of Object.entries(endpoints_default)) { @@ -43491,7 +43491,7 @@ var init_endpoints_to_methods = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js var dist_src_exports2 = {}; __export(dist_src_exports2, { legacyRestEndpointMethods: () => legacyRestEndpointMethods, @@ -43511,7 +43511,7 @@ function legacyRestEndpointMethods(octokit) { }; } var init_dist_src3 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { init_version2(); init_endpoints_to_methods(); restEndpointMethods.VERSION = VERSION5; @@ -43519,7 +43519,7 @@ var init_dist_src3 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js +// node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js var dist_bundle_exports = {}; __export(dist_bundle_exports, { composePaginateRest: () => composePaginateRest, @@ -43645,7 +43645,7 @@ function paginateRest(octokit) { } var VERSION6, composePaginateRest, paginatingEndpoints; var init_dist_bundle5 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { + "node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { VERSION6 = "0.0.0-development"; composePaginateRest = Object.assign(paginate, { iterator diff --git a/lib/upload-lib.js b/lib/upload-lib.js index 3527c53649..2fa5500d56 100644 --- a/lib/upload-lib.js +++ b/lib/upload-lib.js @@ -42354,18 +42354,18 @@ var init_dist_src2 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js var VERSION5; var init_version2 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { VERSION5 = "17.0.0"; } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js var Endpoints, endpoints_default; var init_endpoints = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { Endpoints = { actions: { addCustomLabelsToSelfHostedRunnerForOrg: [ @@ -44659,7 +44659,7 @@ var init_endpoints = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js function endpointsToMethods(octokit) { const newMethods = {}; for (const scope of endpointMethodsMap.keys()) { @@ -44710,7 +44710,7 @@ function decorate(octokit, scope, methodName, defaults, decorations) { } var endpointMethodsMap, handler; var init_endpoints_to_methods = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { init_endpoints(); endpointMethodsMap = /* @__PURE__ */ new Map(); for (const [scope, endpoints] of Object.entries(endpoints_default)) { @@ -44788,7 +44788,7 @@ var init_endpoints_to_methods = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js var dist_src_exports2 = {}; __export(dist_src_exports2, { legacyRestEndpointMethods: () => legacyRestEndpointMethods, @@ -44808,7 +44808,7 @@ function legacyRestEndpointMethods(octokit) { }; } var init_dist_src3 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { init_version2(); init_endpoints_to_methods(); restEndpointMethods.VERSION = VERSION5; @@ -44816,7 +44816,7 @@ var init_dist_src3 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js +// node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js var dist_bundle_exports = {}; __export(dist_bundle_exports, { composePaginateRest: () => composePaginateRest, @@ -44942,7 +44942,7 @@ function paginateRest(octokit) { } var VERSION6, composePaginateRest, paginatingEndpoints; var init_dist_bundle5 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { + "node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { VERSION6 = "0.0.0-development"; composePaginateRest = Object.assign(paginate, { iterator diff --git a/lib/upload-sarif-action-post.js b/lib/upload-sarif-action-post.js index 74a5b57fd9..96f211c050 100644 --- a/lib/upload-sarif-action-post.js +++ b/lib/upload-sarif-action-post.js @@ -41057,18 +41057,18 @@ var init_dist_src2 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js var VERSION5; var init_version2 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { VERSION5 = "17.0.0"; } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js var Endpoints, endpoints_default; var init_endpoints = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { Endpoints = { actions: { addCustomLabelsToSelfHostedRunnerForOrg: [ @@ -43362,7 +43362,7 @@ var init_endpoints = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js function endpointsToMethods(octokit) { const newMethods = {}; for (const scope of endpointMethodsMap.keys()) { @@ -43413,7 +43413,7 @@ function decorate(octokit, scope, methodName, defaults, decorations) { } var endpointMethodsMap, handler; var init_endpoints_to_methods = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { init_endpoints(); endpointMethodsMap = /* @__PURE__ */ new Map(); for (const [scope, endpoints] of Object.entries(endpoints_default)) { @@ -43491,7 +43491,7 @@ var init_endpoints_to_methods = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js var dist_src_exports2 = {}; __export(dist_src_exports2, { legacyRestEndpointMethods: () => legacyRestEndpointMethods, @@ -43511,7 +43511,7 @@ function legacyRestEndpointMethods(octokit) { }; } var init_dist_src3 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { init_version2(); init_endpoints_to_methods(); restEndpointMethods.VERSION = VERSION5; @@ -43519,7 +43519,7 @@ var init_dist_src3 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js +// node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js var dist_bundle_exports = {}; __export(dist_bundle_exports, { composePaginateRest: () => composePaginateRest, @@ -43645,7 +43645,7 @@ function paginateRest(octokit) { } var VERSION6, composePaginateRest, paginatingEndpoints; var init_dist_bundle5 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { + "node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { VERSION6 = "0.0.0-development"; composePaginateRest = Object.assign(paginate, { iterator diff --git a/lib/upload-sarif-action.js b/lib/upload-sarif-action.js index da345bf9a9..d45a09360a 100644 --- a/lib/upload-sarif-action.js +++ b/lib/upload-sarif-action.js @@ -41057,18 +41057,18 @@ var init_dist_src2 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js var VERSION5; var init_version2 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js"() { VERSION5 = "17.0.0"; } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js var Endpoints, endpoints_default; var init_endpoints = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js"() { Endpoints = { actions: { addCustomLabelsToSelfHostedRunnerForOrg: [ @@ -43362,7 +43362,7 @@ var init_endpoints = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js function endpointsToMethods(octokit) { const newMethods = {}; for (const scope of endpointMethodsMap.keys()) { @@ -43413,7 +43413,7 @@ function decorate(octokit, scope, methodName, defaults, decorations) { } var endpointMethodsMap, handler; var init_endpoints_to_methods = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js"() { init_endpoints(); endpointMethodsMap = /* @__PURE__ */ new Map(); for (const [scope, endpoints] of Object.entries(endpoints_default)) { @@ -43491,7 +43491,7 @@ var init_endpoints_to_methods = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js +// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js var dist_src_exports2 = {}; __export(dist_src_exports2, { legacyRestEndpointMethods: () => legacyRestEndpointMethods, @@ -43511,7 +43511,7 @@ function legacyRestEndpointMethods(octokit) { }; } var init_dist_src3 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { + "node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js"() { init_version2(); init_endpoints_to_methods(); restEndpointMethods.VERSION = VERSION5; @@ -43519,7 +43519,7 @@ var init_dist_src3 = __esm({ } }); -// node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js +// node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js var dist_bundle_exports = {}; __export(dist_bundle_exports, { composePaginateRest: () => composePaginateRest, @@ -43645,7 +43645,7 @@ function paginateRest(octokit) { } var VERSION6, composePaginateRest, paginatingEndpoints; var init_dist_bundle5 = __esm({ - "node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { + "node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js"() { VERSION6 = "0.0.0-development"; composePaginateRest = Object.assign(paginate, { iterator diff --git a/package-lock.json b/package-lock.json index fdab827db2..9441340858 100644 --- a/package-lock.json +++ b/package-lock.json @@ -411,36 +411,6 @@ "undici": "^6.23.0" } }, - "node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-14.0.0.tgz", - "integrity": "sha512-fNVRE7ufJiAA3XUrha2omTA39M6IXIc6GIZLvlbsm8QOQCYvpq/LkMNGyFlB1d8hTDzsAXa3OKtybdMAYsV/fw==", - "license": "MIT", - "dependencies": { - "@octokit/types": "^16.0.0" - }, - "engines": { - "node": ">= 20" - }, - "peerDependencies": { - "@octokit/core": ">=6" - } - }, - "node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods": { - "version": "17.0.0", - "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-17.0.0.tgz", - "integrity": "sha512-B5yCyIlOJFPqUUeiD0cnBJwWJO8lkJs5d8+ze9QDP6SvfiXSz1BF+91+0MeI1d2yxgOhU/O+CvtiZ9jSkHhFAw==", - "license": "MIT", - "dependencies": { - "@octokit/types": "^16.0.0" - }, - "engines": { - "node": ">= 20" - }, - "peerDependencies": { - "@octokit/core": ">=6" - } - }, "node_modules/@actions/github/node_modules/undici": { "version": "6.23.0", "resolved": "https://registry.npmjs.org/undici/-/undici-6.23.0.tgz", @@ -2138,6 +2108,21 @@ "integrity": "sha512-whrdktVs1h6gtR+09+QsNk2+FO+49j6ga1c55YZudfEG+oKJVvJLQi3zkOm5JjiUXAagWK2tI2kTGKJ2Ys7MGA==", "license": "MIT" }, + "node_modules/@octokit/plugin-paginate-rest": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-14.0.0.tgz", + "integrity": "sha512-fNVRE7ufJiAA3XUrha2omTA39M6IXIc6GIZLvlbsm8QOQCYvpq/LkMNGyFlB1d8hTDzsAXa3OKtybdMAYsV/fw==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^16.0.0" + }, + "engines": { + "node": ">= 20" + }, + "peerDependencies": { + "@octokit/core": ">=6" + } + }, "node_modules/@octokit/plugin-request-log": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-1.0.4.tgz", @@ -2147,6 +2132,21 @@ "@octokit/core": ">=3" } }, + "node_modules/@octokit/plugin-rest-endpoint-methods": { + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-17.0.0.tgz", + "integrity": "sha512-B5yCyIlOJFPqUUeiD0cnBJwWJO8lkJs5d8+ze9QDP6SvfiXSz1BF+91+0MeI1d2yxgOhU/O+CvtiZ9jSkHhFAw==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^16.0.0" + }, + "engines": { + "node": ">= 20" + }, + "peerDependencies": { + "@octokit/core": ">=6" + } + }, "node_modules/@octokit/plugin-retry": { "version": "8.0.3", "resolved": "https://registry.npmjs.org/@octokit/plugin-retry/-/plugin-retry-8.0.3.tgz", @@ -9917,12 +9917,16 @@ }, "pr-checks": { "dependencies": { + "@actions/core": "^2.0.3", + "@actions/github": "^8.0.1", + "@octokit/core": "^7.0.6", + "@octokit/plugin-paginate-rest": ">=9.2.2", + "@octokit/plugin-rest-endpoint-methods": "^17.0.0", "yaml": "^2.8.2" }, "devDependencies": { "@types/node": "^20.19.9", - "tsx": "^4.21.0", - "typescript": "^5.9.3" + "tsx": "^4.21.0" } } } diff --git a/pr-checks/config.ts b/pr-checks/config.ts new file mode 100644 index 0000000000..7f2826d59c --- /dev/null +++ b/pr-checks/config.ts @@ -0,0 +1,10 @@ +import path from "path"; + +/** The oldest supported major version of the CodeQL Action. */ +export const OLDEST_SUPPORTED_MAJOR_VERSION = 3; + +/** The `pr-checks` directory. */ +export const PR_CHECKS_DIR = __dirname; + +/** The path of the file configuring which checks shouldn't be required. */ +export const PR_CHECK_EXCLUDED_FILE = path.join(PR_CHECKS_DIR, "excluded.yml"); diff --git a/pr-checks/excluded.yml b/pr-checks/excluded.yml new file mode 100644 index 0000000000..104c1009eb --- /dev/null +++ b/pr-checks/excluded.yml @@ -0,0 +1,16 @@ +# PR checks to exclude from required checks +contains: + - "https://" + - "Update" + - "ESLint" + - "update" + - "test-setup-python-scripts" +is: + - "CodeQL" + - "Dependabot" + - "check-expected-release-files" + - "Agent" + - "Cleanup artifacts" + - "Prepare" + - "Upload results" + - "Label PR with size" diff --git a/pr-checks/package.json b/pr-checks/package.json index b323b98b83..bbd4db8733 100644 --- a/pr-checks/package.json +++ b/pr-checks/package.json @@ -2,11 +2,15 @@ "private": true, "description": "Dependencies for the sync.ts", "dependencies": { + "@actions/core": "^2.0.3", + "@actions/github": "^8.0.1", + "@octokit/core": "^7.0.6", + "@octokit/plugin-paginate-rest": ">=9.2.2", + "@octokit/plugin-rest-endpoint-methods": "^17.0.0", "yaml": "^2.8.2" }, "devDependencies": { "@types/node": "^20.19.9", - "tsx": "^4.21.0", - "typescript": "^5.9.3" + "tsx": "^4.21.0" } } diff --git a/pr-checks/release-branches.test.ts b/pr-checks/release-branches.test.ts new file mode 100644 index 0000000000..b33c7b85a7 --- /dev/null +++ b/pr-checks/release-branches.test.ts @@ -0,0 +1,61 @@ +#!/usr/bin/env npx tsx + +/* +Tests for the release-branches.ts script +*/ + +import * as assert from "node:assert/strict"; +import { describe, it } from "node:test"; + +import { computeBackportBranches } from "./release-branches"; + +describe("computeBackportBranches", async () => { + await it("rejects invalid major versions", () => { + // The majorVersion is expected to be in vN format. + assert.throws(() => computeBackportBranches("3", "v4.28.0", 3)); + assert.throws(() => computeBackportBranches("v3.1", "v4.28.0", 3)); + }); + + await it("rejects invalid latest tags", () => { + // The latestTag is expected to be in vN.M.P format. + assert.throws(() => computeBackportBranches("v3", "v4", 3)); + assert.throws(() => computeBackportBranches("v3", "4", 3)); + assert.throws(() => computeBackportBranches("v3", "v4.28", 3)); + assert.throws(() => computeBackportBranches("v3", "4.28", 3)); + assert.throws(() => computeBackportBranches("v3", "4.28.0", 3)); + }); + + await it("sets backport source branch based on major version", () => { + // Test that the backport source branch is releases/v{majorVersion} + const result = computeBackportBranches("v3", "v4.28.0", 3); + assert.equal(result.backportSourceBranch, "releases/v3"); + }); + + await it("no backport targets when major version is the oldest supported", () => { + // When majorVersion equals the major version of latestTag and we do not support older major versions, + // then there are no older supported branches to backport to. + const result = computeBackportBranches("v3", "v3.28.0", 3); + assert.deepEqual(result.backportTargetBranches, []); + }); + + await it("backports to older supported major versions", () => { + const result = computeBackportBranches("v4", "v4.1.0", 3); + assert.equal(result.backportSourceBranch, "releases/v4"); + assert.deepEqual(result.backportTargetBranches, ["releases/v3"]); + }); + + await it("backports to multiple older supported branches", () => { + const result = computeBackportBranches("v5", "v5.0.0", 3); + assert.equal(result.backportSourceBranch, "releases/v5"); + assert.deepEqual(result.backportTargetBranches, [ + "releases/v4", + "releases/v3", + ]); + }); + + await it("does not backport when major version is older than latest tag", () => { + const result = computeBackportBranches("v2", "v3.28.0", 2); + assert.equal(result.backportSourceBranch, "releases/v2"); + assert.deepEqual(result.backportTargetBranches, []); + }); +}); diff --git a/pr-checks/release-branches.ts b/pr-checks/release-branches.ts new file mode 100755 index 0000000000..d0b4702018 --- /dev/null +++ b/pr-checks/release-branches.ts @@ -0,0 +1,121 @@ +#!/usr/bin/env npx tsx + +import { parseArgs } from "node:util"; + +import * as core from "@actions/core"; + +import { OLDEST_SUPPORTED_MAJOR_VERSION } from "./config"; + +/** The results of checking which release branches to backport to. */ +export interface BackportInfo { + /** The source release branch. */ + backportSourceBranch: string; + /** + * The computed release branches we should backport to. + * Will be empty if there are no branches we need to backport to. + */ + backportTargetBranches: string[]; +} + +/** + * Compute the backport source and target branches for a release. + * + * @param majorVersion - The major version string (e.g. "v4"). + * @param latestTag - The most recent tag published to the repository (e.g. "v4.32.6"). + * @param oldestSupportedMajorVersion - The oldest supported major version number. + * @returns The names of the source branch and target branches. + */ +export function computeBackportBranches( + majorVersion: string, + latestTag: string, + oldestSupportedMajorVersion: number, +): BackportInfo { + // Perform some sanity checks on the inputs. + // For `majorVersion`, we expect exactly `vN` for some `N`. + const majorVersionMatch = majorVersion.match(/^v(\d+)$/); + if (!majorVersionMatch) { + throw new Error("--major-version value must be in `vN` format."); + } + + // For latestTag, we expect something starting with `vN.M.P` + const latestTagMatch = latestTag.match(/^v(\d+)\.\d+\.\d+/); + if (!latestTagMatch) { + throw new Error( + `--latest-tag value must be in 'vN.M.P' format, but '${latestTag}' is not.`, + ); + } + + const majorVersionNumber = Number.parseInt(majorVersionMatch[1]); + const latestTagMajor = Number.parseInt(latestTagMatch[1]); + + // If this is a primary release, we backport to all supported branches, + // so we check whether the majorVersion taken from the package.json + // is greater than or equal to the latest tag pulled from the repo. + // For example... + // 'v1' >= 'v2' is False # we're operating from an older release branch and should not backport + // 'v2' >= 'v2' is True # the normal case where we're updating the current version + // 'v3' >= 'v2' is True # in this case we are making the first release of a new major version + const considerBackports = majorVersionNumber >= latestTagMajor; + + const backportSourceBranch = `releases/v${majorVersionNumber}`; + const backportTargetBranches: string[] = []; + + if (considerBackports) { + for (let i = majorVersionNumber - 1; i > 0; i--) { + const branchName = `releases/v${i}`; + if (i >= oldestSupportedMajorVersion) { + backportTargetBranches.push(branchName); + } + } + } + + return { backportSourceBranch, backportTargetBranches }; +} + +async function main() { + const { values: options } = parseArgs({ + options: { + // The major version of the release in `vN` format (e.g. `v4`). + "major-version": { + type: "string", + }, + // The most recent tag published to the repository (e.g. `v4.28.0`). + "latest-tag": { + type: "string", + }, + }, + strict: true, + }); + + if (options["major-version"] === undefined) { + throw Error("--major-version is required"); + } + if (options["latest-tag"] === undefined) { + throw Error("--latest-tag is required"); + } + + const majorVersion = options["major-version"]; + const latestTag = options["latest-tag"]; + + console.log(`Major version: ${majorVersion}`); + console.log(`Latest tag: ${latestTag}`); + + const result = computeBackportBranches( + majorVersion, + latestTag, + OLDEST_SUPPORTED_MAJOR_VERSION, + ); + + core.setOutput("backport_source_branch", result.backportSourceBranch); + core.setOutput( + "backport_target_branches", + JSON.stringify(result.backportTargetBranches), + ); + + process.exit(0); +} + +// Only call `main` if this script was run directly. +if (require.main === module) { + void main(); +} diff --git a/pr-checks/sync-checks.test.ts b/pr-checks/sync-checks.test.ts new file mode 100644 index 0000000000..4d49084cba --- /dev/null +++ b/pr-checks/sync-checks.test.ts @@ -0,0 +1,60 @@ +#!/usr/bin/env npx tsx + +/* +Tests for the sync-checks.ts script +*/ + +import * as assert from "node:assert/strict"; +import { describe, it } from "node:test"; + +import { CheckInfo, Exclusions, Options, removeExcluded } from "./sync-checks"; + +const defaultOptions: Options = { + apply: false, + verbose: false, +}; + +const toCheckInfo = (name: string) => + ({ context: name, app_id: -1 }) satisfies CheckInfo; + +const expectedPartialMatches = ["PR Check - Foo", "https://example.com"].map( + toCheckInfo, +); + +const expectedExactMatches = ["CodeQL", "Update"].map(toCheckInfo); + +const testChecks = expectedExactMatches.concat(expectedPartialMatches); + +const emptyExclusions: Exclusions = { + is: [], + contains: [], +}; + +describe("removeExcluded", async () => { + await it("retains all checks if no exclusions are configured", () => { + const retained = removeExcluded( + defaultOptions, + emptyExclusions, + testChecks, + ); + assert.deepEqual(retained, testChecks); + }); + + await it("removes exact matches", () => { + const retained = removeExcluded( + defaultOptions, + { ...emptyExclusions, is: ["CodeQL", "Update"] }, + testChecks, + ); + assert.deepEqual(retained, expectedPartialMatches); + }); + + await it("removes partial matches", () => { + const retained = removeExcluded( + defaultOptions, + { ...emptyExclusions, contains: ["https://", "PR Check"] }, + testChecks, + ); + assert.deepEqual(retained, expectedExactMatches); + }); +}); diff --git a/pr-checks/sync-checks.ts b/pr-checks/sync-checks.ts new file mode 100755 index 0000000000..5b5b0bd26e --- /dev/null +++ b/pr-checks/sync-checks.ts @@ -0,0 +1,299 @@ +#!/usr/bin/env npx tsx + +/** Update the required checks based on the current branch. */ + +import * as fs from "fs"; +import { parseArgs } from "node:util"; + +import * as githubUtils from "@actions/github/lib/utils"; +import { type Octokit } from "@octokit/core"; +import { type PaginateInterface } from "@octokit/plugin-paginate-rest"; +import { type Api } from "@octokit/plugin-rest-endpoint-methods"; +import * as yaml from "yaml"; + +import { + OLDEST_SUPPORTED_MAJOR_VERSION, + PR_CHECK_EXCLUDED_FILE, +} from "./config"; + +/** Represents the command-line options. */ +export interface Options { + /** The token to use to authenticate to the GitHub API. */ + token?: string; + /** The git ref to use the checks for. */ + ref?: string; + /** Whether to actually apply the changes or not. */ + apply: boolean; + /** Whether to output additional information. */ + verbose: boolean; +} + +/** Identifies the CodeQL Action repository. */ +const codeqlActionRepo = { + owner: "github", + repo: "codeql-action", +}; + +/** Represents a configuration of which checks should not be set up as required checks. */ +export interface Exclusions { + /** A list of strings that, if contained in a check name, are excluded. */ + contains: string[]; + /** A list of check names that are excluded if their name is an exact match. */ + is: string[]; +} + +/** Loads the configuration for which checks to exclude. */ +function loadExclusions(): Exclusions { + return yaml.parse( + fs.readFileSync(PR_CHECK_EXCLUDED_FILE, "utf-8"), + ) as Exclusions; +} + +/** The type of the Octokit client. */ +type ApiClient = Octokit & Api & { paginate: PaginateInterface }; + +/** Constructs an `ApiClient` using `token` for authentication. */ +function getApiClient(token: string): ApiClient { + const opts = githubUtils.getOctokitOptions(token); + return new githubUtils.GitHub(opts); +} + +/** + * Represents information about a check run. We track the `app_id` that generated the check, + * because the API will require it in addition to the name in the future. + */ +export interface CheckInfo { + /** The display name of the check. */ + context: string; + /** The ID of the app that generated the check. */ + app_id: number; +} + +/** Removes entries from `checkInfos` based on the configuration. */ +export function removeExcluded( + options: Options, + exclusions: Exclusions, + checkInfos: CheckInfo[], +): CheckInfo[] { + if (options.verbose) { + console.log(exclusions); + } + + return checkInfos.filter((checkInfo) => { + if (exclusions.is.includes(checkInfo.context)) { + console.info( + `Excluding '${checkInfo.context}' because it is an exact exclusion.`, + ); + return false; + } + + for (const containsStr of exclusions.contains) { + if (checkInfo.context.includes(containsStr)) { + console.info( + `Excluding '${checkInfo.context}' because it contains '${containsStr}'.`, + ); + return false; + } + } + + // Keep. + return true; + }); +} + +/** Gets a list of check run names for `ref`. */ +async function getChecksFor( + options: Options, + client: ApiClient, + ref: string, +): Promise { + console.info(`Getting checks for '${ref}'`); + + const response = await client.paginate( + "GET /repos/{owner}/{repo}/commits/{ref}/check-runs", + { + ...codeqlActionRepo, + ref, + }, + ); + + if (response.length === 0) { + throw new Error(`No checks found for '${ref}'.`); + } + + console.info(`Retrieved ${response.length} check runs.`); + + const notSkipped = response.filter( + (checkRun) => checkRun.conclusion !== "skipped", + ); + console.info(`Of those: ${notSkipped.length} were not skipped.`); + + // We use the ID of the app that generated the check run when returned by the API, + // but default to -1 to tell the API that any check with the given name should be + // required. + const checkInfos = notSkipped.map((check) => ({ + context: check.name, + app_id: check.app?.id || -1, + })); + + // Load the configuration for which checks to exclude and apply it before + // returning the checks. + const exclusions = loadExclusions(); + return removeExcluded(options, exclusions, checkInfos); +} + +/** Gets the current list of release branches. */ +async function getReleaseBranches(client: ApiClient): Promise { + const refs = await client.rest.git.listMatchingRefs({ + ...codeqlActionRepo, + ref: "heads/releases/v", + }); + return refs.data.map((ref) => ref.ref).sort(); +} + +/** Updates the required status checks for `branch` to `checks`. */ +async function patchBranchProtectionRule( + client: ApiClient, + branch: string, + checks: Set, +) { + await client.rest.repos.setStatusCheckContexts({ + ...codeqlActionRepo, + branch, + contexts: Array.from(checks), + }); +} + +/** Sets `checkNames` as required checks for `branch`. */ +async function updateBranch( + options: Options, + client: ApiClient, + branch: string, + checkNames: Set, +) { + console.info(`Updating '${branch}'...`); + + // Query the current set of required checks for this branch. + const currentContexts = await client.rest.repos.getAllStatusCheckContexts({ + ...codeqlActionRepo, + branch, + }); + + // Identify which required checks we will remove and which ones we will add. + const currentCheckNames = new Set(currentContexts.data); + let additions = 0; + let removals = 0; + let unchanged = 0; + + for (const currentCheck of currentCheckNames) { + if (!checkNames.has(currentCheck)) { + console.info(`- Removing '${currentCheck}' for branch '${branch}'`); + removals++; + } else { + unchanged++; + } + } + for (const newCheck of checkNames) { + if (!currentCheckNames.has(newCheck)) { + console.info(`+ Adding '${newCheck}' for branch '${branch}'`); + additions++; + } + } + + console.info( + `For '${branch}': ${removals} removals; ${additions} additions; ${unchanged} unchanged`, + ); + + // Perform the update if there are changes and `--apply` was specified. + if (unchanged === checkNames.size && removals === 0 && additions === 0) { + console.info("Not applying changes because there is nothing to do."); + } else if (options.apply) { + await patchBranchProtectionRule(client, branch, checkNames); + } else { + console.info("Not applying changes because `--apply` was not specified."); + } +} + +async function main(): Promise { + const { values: options } = parseArgs({ + options: { + // The token to use to authenticate to the API. + token: { + type: "string", + }, + // The git ref for which to retrieve the check runs. + ref: { + type: "string", + default: "main", + }, + // By default, we perform a dry-run. Setting `apply` to `true` actually applies the changes. + apply: { + type: "boolean", + default: false, + }, + // Whether to output additional information. + verbose: { + type: "boolean", + default: false, + }, + }, + strict: true, + }); + + if (options.token === undefined) { + throw new Error("Missing --token"); + } + + console.info( + `Oldest supported major version is: ${OLDEST_SUPPORTED_MAJOR_VERSION}`, + ); + + // Initialise the API client. + const client = getApiClient(options.token); + + // Find the check runs for the specified `ref` that we will later set as the required checks + // for the main and release branches. + const checkInfos = await getChecksFor(options, client, options.ref); + const checkNames = new Set(checkInfos.map((info) => info.context)); + + // Update the main branch. + await updateBranch(options, client, "main", checkNames); + + // Retrieve the refs of the release branches. + const releaseBranches = await getReleaseBranches(client); + console.info( + `Found ${releaseBranches.length} release branches: ${releaseBranches.join(", ")}`, + ); + + for (const releaseBranchRef of releaseBranches) { + // Sanity check that the ref name is in the expected format and extract the major version. + const releaseBranchMatch = releaseBranchRef.match( + /^refs\/heads\/(releases\/v(\d+))/, + ); + if (!releaseBranchMatch) { + console.warn( + `Branch ref '${releaseBranchRef}' not in the expected format.`, + ); + continue; + } + const releaseBranch = releaseBranchMatch[1]; + const releaseBranchMajor = Number.parseInt(releaseBranchMatch[2]); + + // Update the required checks for this major version if it is still supported. + if (releaseBranchMajor < OLDEST_SUPPORTED_MAJOR_VERSION) { + console.info( + `Skipping '${releaseBranch}' since it is older than v${OLDEST_SUPPORTED_MAJOR_VERSION}`, + ); + continue; + } else { + await updateBranch(options, client, releaseBranch, checkNames); + } + } + + process.exit(0); +} + +// Only call `main` if this script was run directly. +if (require.main === module) { + void main(); +}