diff --git a/dist/338.index.js b/dist/338.index.js index e34fb7c1..28951ba9 100644 --- a/dist/338.index.js +++ b/dist/338.index.js @@ -178,8 +178,8 @@ const getMergeQueueCommitHashes = async () => { const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/')); return mergeQueueBranches.map(branch => branch.commit.sha); }; -const getPrNumberFromMergeQueueRef = () => { - const prNumber = Number(_actions_github__WEBPACK_IMPORTED_MODULE_1__.context.ref +const getPrNumberFromMergeQueueRef = (ref = _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.ref) => { + const prNumber = Number(ref .split('/') .find(part => part.includes('pr-')) ?.match(/\d+/)?.[0]); diff --git a/dist/338.index.js.map b/dist/338.index.js.map index 1f463ae2..f38b3f6c 100644 --- a/dist/338.index.js.map +++ b/dist/338.index.js.map @@ -1 +1 @@ -{"version":3,"file":"338.index.js","mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AAEA;AAIA;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;AC7BA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAEA;AACA;;;;;;;;;;;AClBA;;;;;;;;;;;AAWA;AAEA;AAsDA;;;;;;;;;;;;;;ACnEA;;;;;;;;;;;AAWA;AAGA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;ACxCA;;;;;;;;;;;AAWA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACjCA;;;;;;;;;;;AAWA;AAGA;AACA;AAEA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sources":[".././src/helpers/get-changed-files.ts",".././src/octokit.ts",".././src/types/generated.ts",".././src/utils/get-changed-filepaths.ts",".././src/utils/merge-queue.ts",".././src/utils/paginate-all-branches.ts"],"sourcesContent":["/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { HelperInputs } from '../types/generated';\nimport { context } from '@actions/github';\nimport { getChangedFilepaths } from '../utils/get-changed-filepaths';\nimport { getPrNumberFromMergeQueueRef } from '../utils/merge-queue';\n\nexport class GetChangedFiles extends HelperInputs {\n declare pattern?: string;\n declare delimiter?: string;\n declare ignore_deleted?: string;\n}\n\nexport const getChangedFiles = async ({ pattern, delimiter = ',', ignore_deleted }: GetChangedFiles) => {\n const pullNumber = context.eventName === 'merge_group' ? getPrNumberFromMergeQueueRef() : context.issue.number;\n const filePaths = await getChangedFilepaths(pullNumber, Boolean(ignore_deleted));\n const filteredFilePaths = pattern ? filePaths.filter(fileName => fileName.match(pattern)) : filePaths;\n return filteredFilePaths.join(delimiter);\n};\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport * as core from '@actions/core';\nimport * as fetch from '@adobe/node-fetch-retry';\nimport { getOctokit } from '@actions/github';\n\nconst githubToken = core.getInput('github_token', { required: true });\nexport const { rest: octokit, graphql: octokitGraphql } = getOctokit(githubToken, { request: { fetch } });\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nexport class HelperInputs {\n declare helper?: string;\n declare github_token?: string;\n declare body?: string;\n declare project_name?: string;\n declare project_destination_column_name?: string;\n declare note?: string;\n declare project_origin_column_name?: string;\n declare sha?: string;\n declare context?: string;\n declare state?: string;\n declare description?: string;\n declare target_url?: string;\n declare environment?: string;\n declare environment_url?: string;\n declare label?: string;\n declare labels?: string;\n declare paths?: string;\n declare ignore_globs?: string;\n declare override_filter_paths?: string;\n declare batches?: string;\n declare pattern?: string;\n declare teams?: string;\n declare users?: string;\n declare login?: string;\n declare paths_no_filter?: string;\n declare slack_webhook_url?: string;\n declare number_of_assignees?: string;\n declare number_of_reviewers?: string;\n declare globs?: string;\n declare override_filter_globs?: string;\n declare title?: string;\n declare seconds?: string;\n declare pull_number?: string;\n declare base?: string;\n declare head?: string;\n declare days?: string;\n declare no_evict_upon_conflict?: string;\n declare skip_if_already_set?: string;\n declare delimiter?: string;\n declare team?: string;\n declare ignore_deleted?: string;\n declare return_full_payload?: string;\n declare skip_auto_merge?: string;\n declare repo_name?: string;\n declare repo_owner_name?: string;\n declare load_balancing_sizes?: string;\n declare required_review_overrides?: string;\n declare codeowners_overrides?: string;\n declare max_queue_size?: string;\n declare allow_only_for_maintainers?: string;\n declare use_basic_matrix_configuration?: string;\n declare merge_queue_enabled?: string;\n declare packages?: string;\n}\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { ChangedFilesList } from '../types/github';\nimport { context } from '@actions/github';\nimport { octokit } from '../octokit';\n\nexport const getChangedFilepaths = async (pull_number: number, ignore_deleted?: boolean) => {\n const changedFiles = await paginateAllChangedFilepaths(pull_number);\n const renamedPreviousFilenames = changedFiles\n .filter(({ status }) => status === 'renamed')\n .map(({ previous_filename }) => previous_filename)\n .filter(Boolean); // GitHub should always include previous_filename for renamed files, but just in case\n const processedFilenames = (ignore_deleted ? changedFiles.filter(({ status }) => status !== 'removed') : changedFiles).map(\n ({ filename }) => filename\n );\n return processedFilenames.concat(renamedPreviousFilenames);\n};\n\nconst paginateAllChangedFilepaths = async (pull_number: number, page = 1): Promise => {\n const response = await octokit.pulls.listFiles({\n pull_number,\n per_page: 100,\n page,\n ...context.repo\n });\n if (!response.data.length) {\n return [];\n }\n return response.data.concat(await paginateAllChangedFilepaths(pull_number, page + 1));\n};\n","/*\nCopyright 2022 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { paginateAllBranches } from './paginate-all-branches';\nimport { context } from '@actions/github';\n\nexport const getMergeQueueCommitHashes = async () => {\n const branches = await paginateAllBranches();\n const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/'));\n return mergeQueueBranches.map(branch => branch.commit.sha);\n};\n\nexport const getPrNumberFromMergeQueueRef = () => {\n const prNumber = Number(\n context.ref\n .split('/')\n .find(part => part.includes('pr-'))\n ?.match(/\\d+/)?.[0]\n );\n if (isNaN(prNumber)) {\n throw new Error('Could not find PR number in merge queue ref.');\n }\n return prNumber;\n};\n","/*\nCopyright 2022 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { PullRequestBranchesList } from '../types/github';\nimport { octokit } from '../octokit';\nimport { context } from '@actions/github';\n\nexport const paginateAllBranches = async ({\n protectedBranches,\n page = 1\n}: { protectedBranches?: boolean; page?: number } = {}): Promise => {\n const response = await octokit.repos.listBranches({\n protected: protectedBranches,\n per_page: 100,\n page,\n ...context.repo\n });\n if (!response.data.length) {\n return [];\n }\n return [...response.data, ...(await paginateAllBranches({ protectedBranches, page: page + 1 }))];\n};\n"],"names":[],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"338.index.js","mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AAEA;AAIA;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;AC7BA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAEA;AACA;;;;;;;;;;;AClBA;;;;;;;;;;;AAWA;AAEA;AAsDA;;;;;;;;;;;;;;ACnEA;;;;;;;;;;;AAWA;AAGA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;ACxCA;;;;;;;;;;;AAWA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACjCA;;;;;;;;;;;AAWA;AAGA;AACA;AAEA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sources":[".././src/helpers/get-changed-files.ts",".././src/octokit.ts",".././src/types/generated.ts",".././src/utils/get-changed-filepaths.ts",".././src/utils/merge-queue.ts",".././src/utils/paginate-all-branches.ts"],"sourcesContent":["/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { HelperInputs } from '../types/generated';\nimport { context } from '@actions/github';\nimport { getChangedFilepaths } from '../utils/get-changed-filepaths';\nimport { getPrNumberFromMergeQueueRef } from '../utils/merge-queue';\n\nexport class GetChangedFiles extends HelperInputs {\n declare pattern?: string;\n declare delimiter?: string;\n declare ignore_deleted?: string;\n}\n\nexport const getChangedFiles = async ({ pattern, delimiter = ',', ignore_deleted }: GetChangedFiles) => {\n const pullNumber = context.eventName === 'merge_group' ? getPrNumberFromMergeQueueRef() : context.issue.number;\n const filePaths = await getChangedFilepaths(pullNumber, Boolean(ignore_deleted));\n const filteredFilePaths = pattern ? filePaths.filter(fileName => fileName.match(pattern)) : filePaths;\n return filteredFilePaths.join(delimiter);\n};\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport * as core from '@actions/core';\nimport * as fetch from '@adobe/node-fetch-retry';\nimport { getOctokit } from '@actions/github';\n\nconst githubToken = core.getInput('github_token', { required: true });\nexport const { rest: octokit, graphql: octokitGraphql } = getOctokit(githubToken, { request: { fetch } });\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nexport class HelperInputs {\n declare helper?: string;\n declare github_token?: string;\n declare body?: string;\n declare project_name?: string;\n declare project_destination_column_name?: string;\n declare note?: string;\n declare project_origin_column_name?: string;\n declare sha?: string;\n declare context?: string;\n declare state?: string;\n declare description?: string;\n declare target_url?: string;\n declare environment?: string;\n declare environment_url?: string;\n declare label?: string;\n declare labels?: string;\n declare paths?: string;\n declare ignore_globs?: string;\n declare override_filter_paths?: string;\n declare batches?: string;\n declare pattern?: string;\n declare teams?: string;\n declare users?: string;\n declare login?: string;\n declare paths_no_filter?: string;\n declare slack_webhook_url?: string;\n declare number_of_assignees?: string;\n declare number_of_reviewers?: string;\n declare globs?: string;\n declare override_filter_globs?: string;\n declare title?: string;\n declare seconds?: string;\n declare pull_number?: string;\n declare base?: string;\n declare head?: string;\n declare days?: string;\n declare no_evict_upon_conflict?: string;\n declare skip_if_already_set?: string;\n declare delimiter?: string;\n declare team?: string;\n declare ignore_deleted?: string;\n declare return_full_payload?: string;\n declare skip_auto_merge?: string;\n declare repo_name?: string;\n declare repo_owner_name?: string;\n declare load_balancing_sizes?: string;\n declare required_review_overrides?: string;\n declare codeowners_overrides?: string;\n declare max_queue_size?: string;\n declare allow_only_for_maintainers?: string;\n declare use_basic_matrix_configuration?: string;\n declare merge_queue_enabled?: string;\n declare packages?: string;\n}\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { ChangedFilesList } from '../types/github';\nimport { context } from '@actions/github';\nimport { octokit } from '../octokit';\n\nexport const getChangedFilepaths = async (pull_number: number, ignore_deleted?: boolean) => {\n const changedFiles = await paginateAllChangedFilepaths(pull_number);\n const renamedPreviousFilenames = changedFiles\n .filter(({ status }) => status === 'renamed')\n .map(({ previous_filename }) => previous_filename)\n .filter(Boolean); // GitHub should always include previous_filename for renamed files, but just in case\n const processedFilenames = (ignore_deleted ? changedFiles.filter(({ status }) => status !== 'removed') : changedFiles).map(\n ({ filename }) => filename\n );\n return processedFilenames.concat(renamedPreviousFilenames);\n};\n\nconst paginateAllChangedFilepaths = async (pull_number: number, page = 1): Promise => {\n const response = await octokit.pulls.listFiles({\n pull_number,\n per_page: 100,\n page,\n ...context.repo\n });\n if (!response.data.length) {\n return [];\n }\n return response.data.concat(await paginateAllChangedFilepaths(pull_number, page + 1));\n};\n","/*\nCopyright 2022 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { paginateAllBranches } from './paginate-all-branches';\nimport { context } from '@actions/github';\n\nexport const getMergeQueueCommitHashes = async () => {\n const branches = await paginateAllBranches();\n const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/'));\n return mergeQueueBranches.map(branch => branch.commit.sha);\n};\n\nexport const getPrNumberFromMergeQueueRef = (ref = context.ref) => {\n const prNumber = Number(\n ref\n .split('/')\n .find(part => part.includes('pr-'))\n ?.match(/\\d+/)?.[0]\n );\n if (isNaN(prNumber)) {\n throw new Error('Could not find PR number in merge queue ref.');\n }\n return prNumber;\n};\n","/*\nCopyright 2022 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { PullRequestBranchesList } from '../types/github';\nimport { octokit } from '../octokit';\nimport { context } from '@actions/github';\n\nexport const paginateAllBranches = async ({\n protectedBranches,\n page = 1\n}: { protectedBranches?: boolean; page?: number } = {}): Promise => {\n const response = await octokit.repos.listBranches({\n protected: protectedBranches,\n per_page: 100,\n page,\n ...context.repo\n });\n if (!response.data.length) {\n return [];\n }\n return [...response.data, ...(await paginateAllBranches({ protectedBranches, page: page + 1 }))];\n};\n"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/dist/467.index.js b/dist/467.index.js index f0cb52a2..046a431d 100644 --- a/dist/467.index.js +++ b/dist/467.index.js @@ -258,8 +258,8 @@ const getMergeQueueCommitHashes = async () => { const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/')); return mergeQueueBranches.map(branch => branch.commit.sha); }; -const getPrNumberFromMergeQueueRef = () => { - const prNumber = Number(_actions_github__WEBPACK_IMPORTED_MODULE_1__.context.ref +const getPrNumberFromMergeQueueRef = (ref = _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.ref) => { + const prNumber = Number(ref .split('/') .find(part => part.includes('pr-')) ?.match(/\d+/)?.[0]); diff --git a/dist/467.index.js.map b/dist/467.index.js.map index e578977d..1eeee424 100644 --- a/dist/467.index.js.map +++ b/dist/467.index.js.map @@ -1 +1 @@ -{"version":3,"file":"467.index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;AAWA;;;;;;;;;;;;;;;;;;;;;AC1DA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAMA;AAEA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;;;;;;;;;;;;;;;;;AClFA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAEA;AACA;;;;;;;;;;;AClBA;;;;;;;;;;;AAWA;AAEA;AAsDA;;;;;;;;;;;;;;;ACnEA;;;;;;;;;;;AAWA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACjCA;;;;;;;;;;;AAWA;AAGA;AACA;AAEA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sources":[".././src/constants.ts",".././src/helpers/notify-pipeline-complete.ts",".././src/octokit.ts",".././src/types/generated.ts",".././src/utils/merge-queue.ts",".././src/utils/paginate-all-branches.ts"],"sourcesContent":["/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n// These extra headers are for experimental API features on Github Enterprise. See https://docs.github.com/en/enterprise-server@3.0/rest/overview/api-previews for details.\nconst PREVIEWS = ['ant-man', 'flash', 'groot', 'inertia', 'starfox'];\nexport const GITHUB_OPTIONS = {\n headers: {\n accept: PREVIEWS.map(preview => `application/vnd.github.${preview}-preview+json`).join()\n }\n};\n\nexport const SECONDS_IN_A_DAY = 86400000;\nexport const DEFAULT_PIPELINE_STATUS = 'Pipeline Status';\nexport const DEFAULT_PIPELINE_DESCRIPTION = 'Pipeline clear.';\nexport const PRODUCTION_ENVIRONMENT = 'production';\nexport const LATE_REVIEW = 'Late Review';\nexport const OVERDUE_ISSUE = 'Overdue';\nexport const ALMOST_OVERDUE_ISSUE = 'Due Soon';\nexport const PRIORITY_1 = 'Priority: Critical';\nexport const PRIORITY_2 = 'Priority: High';\nexport const PRIORITY_3 = 'Priority: Medium';\nexport const PRIORITY_4 = 'Priority: Low';\nexport const PRIORITY_LABELS = [PRIORITY_1, PRIORITY_2, PRIORITY_3, PRIORITY_4] as const;\nexport const PRIORITY_TO_DAYS_MAP = {\n [PRIORITY_1]: 2,\n [PRIORITY_2]: 14,\n [PRIORITY_3]: 45,\n [PRIORITY_4]: 90\n};\nexport const CORE_APPROVED_PR_LABEL = 'CORE APPROVED';\nexport const PEER_APPROVED_PR_LABEL = 'PEER APPROVED';\nexport const READY_FOR_MERGE_PR_LABEL = 'READY FOR MERGE';\nexport const MERGE_QUEUE_STATUS = 'QUEUE CHECKER';\nexport const QUEUED_FOR_MERGE_PREFIX = 'QUEUED FOR MERGE';\nexport const FIRST_QUEUED_PR_LABEL = `${QUEUED_FOR_MERGE_PREFIX} #1`;\nexport const JUMP_THE_QUEUE_PR_LABEL = 'JUMP THE QUEUE';\nexport const DEFAULT_PR_TITLE_REGEX = '^(build|ci|chore|docs|feat|fix|perf|refactor|style|test|revert|Revert|BREAKING CHANGE)((.*))?: .+$';\nexport const COPYRIGHT_HEADER = `/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/`;\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { DEFAULT_PIPELINE_DESCRIPTION, DEFAULT_PIPELINE_STATUS, GITHUB_OPTIONS, PRODUCTION_ENVIRONMENT } from '../constants';\nimport { HelperInputs } from '../types/generated';\nimport { context as githubContext } from '@actions/github';\nimport { map } from 'bluebird';\nimport { octokit } from '../octokit';\nimport { getMergeQueueCommitHashes } from '../utils/merge-queue';\n\nexport class NotifyPipelineComplete extends HelperInputs {\n declare context?: string;\n declare description?: string;\n declare environment?: string;\n declare target_url?: string;\n declare merge_queue_enabled?: string;\n}\n\nexport const notifyPipelineComplete = async ({\n context = DEFAULT_PIPELINE_STATUS,\n description = DEFAULT_PIPELINE_DESCRIPTION,\n environment = PRODUCTION_ENVIRONMENT,\n target_url,\n merge_queue_enabled\n}: NotifyPipelineComplete) => {\n const { data: deployments } = await octokit.repos.listDeployments({\n environment,\n ...githubContext.repo,\n ...GITHUB_OPTIONS\n });\n const deployment_id = deployments.find(Boolean)?.id;\n if (!deployment_id) return;\n await octokit.repos.createDeploymentStatus({\n environment,\n deployment_id,\n state: 'success',\n description,\n target_url,\n ...githubContext.repo,\n ...GITHUB_OPTIONS\n });\n\n if (merge_queue_enabled === 'true') {\n const mergeQueueCommitHashes = await getMergeQueueCommitHashes();\n return map(mergeQueueCommitHashes, async sha =>\n octokit.repos.createCommitStatus({\n sha,\n context,\n state: 'success',\n description,\n target_url,\n ...githubContext.repo\n })\n );\n }\n\n const { data: pullRequests } = await octokit.pulls.list({\n state: 'open',\n per_page: 100,\n ...githubContext.repo\n });\n const commitHashesForOpenPullRequests = pullRequests.map(pullRequest => pullRequest.head.sha);\n return map(commitHashesForOpenPullRequests, async sha =>\n octokit.repos.createCommitStatus({\n sha,\n context,\n state: 'success',\n description,\n target_url,\n ...githubContext.repo\n })\n );\n};\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport * as core from '@actions/core';\nimport * as fetch from '@adobe/node-fetch-retry';\nimport { getOctokit } from '@actions/github';\n\nconst githubToken = core.getInput('github_token', { required: true });\nexport const { rest: octokit, graphql: octokitGraphql } = getOctokit(githubToken, { request: { fetch } });\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nexport class HelperInputs {\n declare helper?: string;\n declare github_token?: string;\n declare body?: string;\n declare project_name?: string;\n declare project_destination_column_name?: string;\n declare note?: string;\n declare project_origin_column_name?: string;\n declare sha?: string;\n declare context?: string;\n declare state?: string;\n declare description?: string;\n declare target_url?: string;\n declare environment?: string;\n declare environment_url?: string;\n declare label?: string;\n declare labels?: string;\n declare paths?: string;\n declare ignore_globs?: string;\n declare override_filter_paths?: string;\n declare batches?: string;\n declare pattern?: string;\n declare teams?: string;\n declare users?: string;\n declare login?: string;\n declare paths_no_filter?: string;\n declare slack_webhook_url?: string;\n declare number_of_assignees?: string;\n declare number_of_reviewers?: string;\n declare globs?: string;\n declare override_filter_globs?: string;\n declare title?: string;\n declare seconds?: string;\n declare pull_number?: string;\n declare base?: string;\n declare head?: string;\n declare days?: string;\n declare no_evict_upon_conflict?: string;\n declare skip_if_already_set?: string;\n declare delimiter?: string;\n declare team?: string;\n declare ignore_deleted?: string;\n declare return_full_payload?: string;\n declare skip_auto_merge?: string;\n declare repo_name?: string;\n declare repo_owner_name?: string;\n declare load_balancing_sizes?: string;\n declare required_review_overrides?: string;\n declare codeowners_overrides?: string;\n declare max_queue_size?: string;\n declare allow_only_for_maintainers?: string;\n declare use_basic_matrix_configuration?: string;\n declare merge_queue_enabled?: string;\n declare packages?: string;\n}\n","/*\nCopyright 2022 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { paginateAllBranches } from './paginate-all-branches';\nimport { context } from '@actions/github';\n\nexport const getMergeQueueCommitHashes = async () => {\n const branches = await paginateAllBranches();\n const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/'));\n return mergeQueueBranches.map(branch => branch.commit.sha);\n};\n\nexport const getPrNumberFromMergeQueueRef = () => {\n const prNumber = Number(\n context.ref\n .split('/')\n .find(part => part.includes('pr-'))\n ?.match(/\\d+/)?.[0]\n );\n if (isNaN(prNumber)) {\n throw new Error('Could not find PR number in merge queue ref.');\n }\n return prNumber;\n};\n","/*\nCopyright 2022 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { PullRequestBranchesList } from '../types/github';\nimport { octokit } from '../octokit';\nimport { context } from '@actions/github';\n\nexport const paginateAllBranches = async ({\n protectedBranches,\n page = 1\n}: { protectedBranches?: boolean; page?: number } = {}): Promise => {\n const response = await octokit.repos.listBranches({\n protected: protectedBranches,\n per_page: 100,\n page,\n ...context.repo\n });\n if (!response.data.length) {\n return [];\n }\n return [...response.data, ...(await paginateAllBranches({ protectedBranches, page: page + 1 }))];\n};\n"],"names":[],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"467.index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;AAWA;;;;;;;;;;;;;;;;;;;;;AC1DA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAMA;AAEA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;;;;;;;;;;;;;;;;;AClFA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAEA;AACA;;;;;;;;;;;AClBA;;;;;;;;;;;AAWA;AAEA;AAsDA;;;;;;;;;;;;;;;ACnEA;;;;;;;;;;;AAWA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACjCA;;;;;;;;;;;AAWA;AAGA;AACA;AAEA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sources":[".././src/constants.ts",".././src/helpers/notify-pipeline-complete.ts",".././src/octokit.ts",".././src/types/generated.ts",".././src/utils/merge-queue.ts",".././src/utils/paginate-all-branches.ts"],"sourcesContent":["/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n// These extra headers are for experimental API features on Github Enterprise. See https://docs.github.com/en/enterprise-server@3.0/rest/overview/api-previews for details.\nconst PREVIEWS = ['ant-man', 'flash', 'groot', 'inertia', 'starfox'];\nexport const GITHUB_OPTIONS = {\n headers: {\n accept: PREVIEWS.map(preview => `application/vnd.github.${preview}-preview+json`).join()\n }\n};\n\nexport const SECONDS_IN_A_DAY = 86400000;\nexport const DEFAULT_PIPELINE_STATUS = 'Pipeline Status';\nexport const DEFAULT_PIPELINE_DESCRIPTION = 'Pipeline clear.';\nexport const PRODUCTION_ENVIRONMENT = 'production';\nexport const LATE_REVIEW = 'Late Review';\nexport const OVERDUE_ISSUE = 'Overdue';\nexport const ALMOST_OVERDUE_ISSUE = 'Due Soon';\nexport const PRIORITY_1 = 'Priority: Critical';\nexport const PRIORITY_2 = 'Priority: High';\nexport const PRIORITY_3 = 'Priority: Medium';\nexport const PRIORITY_4 = 'Priority: Low';\nexport const PRIORITY_LABELS = [PRIORITY_1, PRIORITY_2, PRIORITY_3, PRIORITY_4] as const;\nexport const PRIORITY_TO_DAYS_MAP = {\n [PRIORITY_1]: 2,\n [PRIORITY_2]: 14,\n [PRIORITY_3]: 45,\n [PRIORITY_4]: 90\n};\nexport const CORE_APPROVED_PR_LABEL = 'CORE APPROVED';\nexport const PEER_APPROVED_PR_LABEL = 'PEER APPROVED';\nexport const READY_FOR_MERGE_PR_LABEL = 'READY FOR MERGE';\nexport const MERGE_QUEUE_STATUS = 'QUEUE CHECKER';\nexport const QUEUED_FOR_MERGE_PREFIX = 'QUEUED FOR MERGE';\nexport const FIRST_QUEUED_PR_LABEL = `${QUEUED_FOR_MERGE_PREFIX} #1`;\nexport const JUMP_THE_QUEUE_PR_LABEL = 'JUMP THE QUEUE';\nexport const DEFAULT_PR_TITLE_REGEX = '^(build|ci|chore|docs|feat|fix|perf|refactor|style|test|revert|Revert|BREAKING CHANGE)((.*))?: .+$';\nexport const COPYRIGHT_HEADER = `/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/`;\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { DEFAULT_PIPELINE_DESCRIPTION, DEFAULT_PIPELINE_STATUS, GITHUB_OPTIONS, PRODUCTION_ENVIRONMENT } from '../constants';\nimport { HelperInputs } from '../types/generated';\nimport { context as githubContext } from '@actions/github';\nimport { map } from 'bluebird';\nimport { octokit } from '../octokit';\nimport { getMergeQueueCommitHashes } from '../utils/merge-queue';\n\nexport class NotifyPipelineComplete extends HelperInputs {\n declare context?: string;\n declare description?: string;\n declare environment?: string;\n declare target_url?: string;\n declare merge_queue_enabled?: string;\n}\n\nexport const notifyPipelineComplete = async ({\n context = DEFAULT_PIPELINE_STATUS,\n description = DEFAULT_PIPELINE_DESCRIPTION,\n environment = PRODUCTION_ENVIRONMENT,\n target_url,\n merge_queue_enabled\n}: NotifyPipelineComplete) => {\n const { data: deployments } = await octokit.repos.listDeployments({\n environment,\n ...githubContext.repo,\n ...GITHUB_OPTIONS\n });\n const deployment_id = deployments.find(Boolean)?.id;\n if (!deployment_id) return;\n await octokit.repos.createDeploymentStatus({\n environment,\n deployment_id,\n state: 'success',\n description,\n target_url,\n ...githubContext.repo,\n ...GITHUB_OPTIONS\n });\n\n if (merge_queue_enabled === 'true') {\n const mergeQueueCommitHashes = await getMergeQueueCommitHashes();\n return map(mergeQueueCommitHashes, async sha =>\n octokit.repos.createCommitStatus({\n sha,\n context,\n state: 'success',\n description,\n target_url,\n ...githubContext.repo\n })\n );\n }\n\n const { data: pullRequests } = await octokit.pulls.list({\n state: 'open',\n per_page: 100,\n ...githubContext.repo\n });\n const commitHashesForOpenPullRequests = pullRequests.map(pullRequest => pullRequest.head.sha);\n return map(commitHashesForOpenPullRequests, async sha =>\n octokit.repos.createCommitStatus({\n sha,\n context,\n state: 'success',\n description,\n target_url,\n ...githubContext.repo\n })\n );\n};\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport * as core from '@actions/core';\nimport * as fetch from '@adobe/node-fetch-retry';\nimport { getOctokit } from '@actions/github';\n\nconst githubToken = core.getInput('github_token', { required: true });\nexport const { rest: octokit, graphql: octokitGraphql } = getOctokit(githubToken, { request: { fetch } });\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nexport class HelperInputs {\n declare helper?: string;\n declare github_token?: string;\n declare body?: string;\n declare project_name?: string;\n declare project_destination_column_name?: string;\n declare note?: string;\n declare project_origin_column_name?: string;\n declare sha?: string;\n declare context?: string;\n declare state?: string;\n declare description?: string;\n declare target_url?: string;\n declare environment?: string;\n declare environment_url?: string;\n declare label?: string;\n declare labels?: string;\n declare paths?: string;\n declare ignore_globs?: string;\n declare override_filter_paths?: string;\n declare batches?: string;\n declare pattern?: string;\n declare teams?: string;\n declare users?: string;\n declare login?: string;\n declare paths_no_filter?: string;\n declare slack_webhook_url?: string;\n declare number_of_assignees?: string;\n declare number_of_reviewers?: string;\n declare globs?: string;\n declare override_filter_globs?: string;\n declare title?: string;\n declare seconds?: string;\n declare pull_number?: string;\n declare base?: string;\n declare head?: string;\n declare days?: string;\n declare no_evict_upon_conflict?: string;\n declare skip_if_already_set?: string;\n declare delimiter?: string;\n declare team?: string;\n declare ignore_deleted?: string;\n declare return_full_payload?: string;\n declare skip_auto_merge?: string;\n declare repo_name?: string;\n declare repo_owner_name?: string;\n declare load_balancing_sizes?: string;\n declare required_review_overrides?: string;\n declare codeowners_overrides?: string;\n declare max_queue_size?: string;\n declare allow_only_for_maintainers?: string;\n declare use_basic_matrix_configuration?: string;\n declare merge_queue_enabled?: string;\n declare packages?: string;\n}\n","/*\nCopyright 2022 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { paginateAllBranches } from './paginate-all-branches';\nimport { context } from '@actions/github';\n\nexport const getMergeQueueCommitHashes = async () => {\n const branches = await paginateAllBranches();\n const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/'));\n return mergeQueueBranches.map(branch => branch.commit.sha);\n};\n\nexport const getPrNumberFromMergeQueueRef = (ref = context.ref) => {\n const prNumber = Number(\n ref\n .split('/')\n .find(part => part.includes('pr-'))\n ?.match(/\\d+/)?.[0]\n );\n if (isNaN(prNumber)) {\n throw new Error('Could not find PR number in merge queue ref.');\n }\n return prNumber;\n};\n","/*\nCopyright 2022 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { PullRequestBranchesList } from '../types/github';\nimport { octokit } from '../octokit';\nimport { context } from '@actions/github';\n\nexport const paginateAllBranches = async ({\n protectedBranches,\n page = 1\n}: { protectedBranches?: boolean; page?: number } = {}): Promise => {\n const response = await octokit.repos.listBranches({\n protected: protectedBranches,\n per_page: 100,\n page,\n ...context.repo\n });\n if (!response.data.length) {\n return [];\n }\n return [...response.data, ...(await paginateAllBranches({ protectedBranches, page: page + 1 }))];\n};\n"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/dist/604.index.js b/dist/604.index.js index d39d48ff..203b18f1 100644 --- a/dist/604.index.js +++ b/dist/604.index.js @@ -145,8 +145,8 @@ const getMergeQueueCommitHashes = async () => { const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/')); return mergeQueueBranches.map(branch => branch.commit.sha); }; -const getPrNumberFromMergeQueueRef = () => { - const prNumber = Number(_actions_github__WEBPACK_IMPORTED_MODULE_1__.context.ref +const getPrNumberFromMergeQueueRef = (ref = _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.ref) => { + const prNumber = Number(ref .split('/') .find(part => part.includes('pr-')) ?.match(/\d+/)?.[0]); diff --git a/dist/604.index.js.map b/dist/604.index.js.map index 9c80ac99..acaed013 100644 --- a/dist/604.index.js.map +++ b/dist/604.index.js.map @@ -1 +1 @@ -{"version":3,"file":"604.index.js","mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAEA;AAEA;AAEA;AAEA;AACA;;AAEA;;AAEA;;;;;;;;;;;AAWA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;AC3CA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAEA;AACA;;;;;;;;;;;AClBA;;;;;;;;;;;AAWA;AAEA;AAsDA;;;;;;;;;;;;;;;ACnEA;;;;;;;;;;;AAWA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACjCA;;;;;;;;;;;AAWA;AAGA;AACA;AAEA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sources":[".././src/helpers/get-merge-queue-position.ts",".././src/octokit.ts",".././src/types/generated.ts",".././src/utils/merge-queue.ts",".././src/utils/paginate-all-branches.ts"],"sourcesContent":["/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\nhttps://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { HelperInputs } from '../types/generated';\nimport { context } from '@actions/github';\nimport { octokitGraphql } from '../octokit';\nimport { Repository } from '@octokit/graphql-schema';\nimport { getPrNumberFromMergeQueueRef } from '../utils/merge-queue';\n\nexport class GetMergeQueuePosition extends HelperInputs {\n declare max_queue_size?: string;\n}\n\nexport const getMergeQueuePosition = async ({ max_queue_size = '10' }: GetMergeQueuePosition) => {\n const { repository } = await octokitGraphql<{ repository: Repository }>(`\nquery {\n repository(owner: \"${context.repo.owner}\", name: \"${context.repo.repo}\") {\n mergeQueue {\n entries(first: ${max_queue_size}) {\n nodes {\n pullRequest {\n number\n }\n position\n }\n }\n }\n }\n}\n`);\n const prNumberFromMergeQueueRef = getPrNumberFromMergeQueueRef();\n const mergeQueueEntries = repository.mergeQueue?.entries?.nodes;\n return mergeQueueEntries?.find(entry => entry?.pullRequest?.number === prNumberFromMergeQueueRef)?.position;\n};\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport * as core from '@actions/core';\nimport * as fetch from '@adobe/node-fetch-retry';\nimport { getOctokit } from '@actions/github';\n\nconst githubToken = core.getInput('github_token', { required: true });\nexport const { rest: octokit, graphql: octokitGraphql } = getOctokit(githubToken, { request: { fetch } });\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nexport class HelperInputs {\n declare helper?: string;\n declare github_token?: string;\n declare body?: string;\n declare project_name?: string;\n declare project_destination_column_name?: string;\n declare note?: string;\n declare project_origin_column_name?: string;\n declare sha?: string;\n declare context?: string;\n declare state?: string;\n declare description?: string;\n declare target_url?: string;\n declare environment?: string;\n declare environment_url?: string;\n declare label?: string;\n declare labels?: string;\n declare paths?: string;\n declare ignore_globs?: string;\n declare override_filter_paths?: string;\n declare batches?: string;\n declare pattern?: string;\n declare teams?: string;\n declare users?: string;\n declare login?: string;\n declare paths_no_filter?: string;\n declare slack_webhook_url?: string;\n declare number_of_assignees?: string;\n declare number_of_reviewers?: string;\n declare globs?: string;\n declare override_filter_globs?: string;\n declare title?: string;\n declare seconds?: string;\n declare pull_number?: string;\n declare base?: string;\n declare head?: string;\n declare days?: string;\n declare no_evict_upon_conflict?: string;\n declare skip_if_already_set?: string;\n declare delimiter?: string;\n declare team?: string;\n declare ignore_deleted?: string;\n declare return_full_payload?: string;\n declare skip_auto_merge?: string;\n declare repo_name?: string;\n declare repo_owner_name?: string;\n declare load_balancing_sizes?: string;\n declare required_review_overrides?: string;\n declare codeowners_overrides?: string;\n declare max_queue_size?: string;\n declare allow_only_for_maintainers?: string;\n declare use_basic_matrix_configuration?: string;\n declare merge_queue_enabled?: string;\n declare packages?: string;\n}\n","/*\nCopyright 2022 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { paginateAllBranches } from './paginate-all-branches';\nimport { context } from '@actions/github';\n\nexport const getMergeQueueCommitHashes = async () => {\n const branches = await paginateAllBranches();\n const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/'));\n return mergeQueueBranches.map(branch => branch.commit.sha);\n};\n\nexport const getPrNumberFromMergeQueueRef = () => {\n const prNumber = Number(\n context.ref\n .split('/')\n .find(part => part.includes('pr-'))\n ?.match(/\\d+/)?.[0]\n );\n if (isNaN(prNumber)) {\n throw new Error('Could not find PR number in merge queue ref.');\n }\n return prNumber;\n};\n","/*\nCopyright 2022 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { PullRequestBranchesList } from '../types/github';\nimport { octokit } from '../octokit';\nimport { context } from '@actions/github';\n\nexport const paginateAllBranches = async ({\n protectedBranches,\n page = 1\n}: { protectedBranches?: boolean; page?: number } = {}): Promise => {\n const response = await octokit.repos.listBranches({\n protected: protectedBranches,\n per_page: 100,\n page,\n ...context.repo\n });\n if (!response.data.length) {\n return [];\n }\n return [...response.data, ...(await paginateAllBranches({ protectedBranches, page: page + 1 }))];\n};\n"],"names":[],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"604.index.js","mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAEA;AAEA;AAEA;AAEA;AACA;;AAEA;;AAEA;;;;;;;;;;;AAWA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;AC3CA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAEA;AACA;;;;;;;;;;;AClBA;;;;;;;;;;;AAWA;AAEA;AAsDA;;;;;;;;;;;;;;;ACnEA;;;;;;;;;;;AAWA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACjCA;;;;;;;;;;;AAWA;AAGA;AACA;AAEA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sources":[".././src/helpers/get-merge-queue-position.ts",".././src/octokit.ts",".././src/types/generated.ts",".././src/utils/merge-queue.ts",".././src/utils/paginate-all-branches.ts"],"sourcesContent":["/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\nhttps://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { HelperInputs } from '../types/generated';\nimport { context } from '@actions/github';\nimport { octokitGraphql } from '../octokit';\nimport { Repository } from '@octokit/graphql-schema';\nimport { getPrNumberFromMergeQueueRef } from '../utils/merge-queue';\n\nexport class GetMergeQueuePosition extends HelperInputs {\n declare max_queue_size?: string;\n}\n\nexport const getMergeQueuePosition = async ({ max_queue_size = '10' }: GetMergeQueuePosition) => {\n const { repository } = await octokitGraphql<{ repository: Repository }>(`\nquery {\n repository(owner: \"${context.repo.owner}\", name: \"${context.repo.repo}\") {\n mergeQueue {\n entries(first: ${max_queue_size}) {\n nodes {\n pullRequest {\n number\n }\n position\n }\n }\n }\n }\n}\n`);\n const prNumberFromMergeQueueRef = getPrNumberFromMergeQueueRef();\n const mergeQueueEntries = repository.mergeQueue?.entries?.nodes;\n return mergeQueueEntries?.find(entry => entry?.pullRequest?.number === prNumberFromMergeQueueRef)?.position;\n};\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport * as core from '@actions/core';\nimport * as fetch from '@adobe/node-fetch-retry';\nimport { getOctokit } from '@actions/github';\n\nconst githubToken = core.getInput('github_token', { required: true });\nexport const { rest: octokit, graphql: octokitGraphql } = getOctokit(githubToken, { request: { fetch } });\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nexport class HelperInputs {\n declare helper?: string;\n declare github_token?: string;\n declare body?: string;\n declare project_name?: string;\n declare project_destination_column_name?: string;\n declare note?: string;\n declare project_origin_column_name?: string;\n declare sha?: string;\n declare context?: string;\n declare state?: string;\n declare description?: string;\n declare target_url?: string;\n declare environment?: string;\n declare environment_url?: string;\n declare label?: string;\n declare labels?: string;\n declare paths?: string;\n declare ignore_globs?: string;\n declare override_filter_paths?: string;\n declare batches?: string;\n declare pattern?: string;\n declare teams?: string;\n declare users?: string;\n declare login?: string;\n declare paths_no_filter?: string;\n declare slack_webhook_url?: string;\n declare number_of_assignees?: string;\n declare number_of_reviewers?: string;\n declare globs?: string;\n declare override_filter_globs?: string;\n declare title?: string;\n declare seconds?: string;\n declare pull_number?: string;\n declare base?: string;\n declare head?: string;\n declare days?: string;\n declare no_evict_upon_conflict?: string;\n declare skip_if_already_set?: string;\n declare delimiter?: string;\n declare team?: string;\n declare ignore_deleted?: string;\n declare return_full_payload?: string;\n declare skip_auto_merge?: string;\n declare repo_name?: string;\n declare repo_owner_name?: string;\n declare load_balancing_sizes?: string;\n declare required_review_overrides?: string;\n declare codeowners_overrides?: string;\n declare max_queue_size?: string;\n declare allow_only_for_maintainers?: string;\n declare use_basic_matrix_configuration?: string;\n declare merge_queue_enabled?: string;\n declare packages?: string;\n}\n","/*\nCopyright 2022 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { paginateAllBranches } from './paginate-all-branches';\nimport { context } from '@actions/github';\n\nexport const getMergeQueueCommitHashes = async () => {\n const branches = await paginateAllBranches();\n const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/'));\n return mergeQueueBranches.map(branch => branch.commit.sha);\n};\n\nexport const getPrNumberFromMergeQueueRef = (ref = context.ref) => {\n const prNumber = Number(\n ref\n .split('/')\n .find(part => part.includes('pr-'))\n ?.match(/\\d+/)?.[0]\n );\n if (isNaN(prNumber)) {\n throw new Error('Could not find PR number in merge queue ref.');\n }\n return prNumber;\n};\n","/*\nCopyright 2022 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { PullRequestBranchesList } from '../types/github';\nimport { octokit } from '../octokit';\nimport { context } from '@actions/github';\n\nexport const paginateAllBranches = async ({\n protectedBranches,\n page = 1\n}: { protectedBranches?: boolean; page?: number } = {}): Promise => {\n const response = await octokit.repos.listBranches({\n protected: protectedBranches,\n per_page: 100,\n page,\n ...context.repo\n });\n if (!response.data.length) {\n return [];\n }\n return [...response.data, ...(await paginateAllBranches({ protectedBranches, page: page + 1 }))];\n};\n"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/dist/654.index.js b/dist/654.index.js index eafb9a8f..95d010ca 100644 --- a/dist/654.index.js +++ b/dist/654.index.js @@ -2,91 +2,6 @@ export const id = 654; export const ids = [654]; export const modules = { -/***/ 7242: -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ E$: () => (/* binding */ PRODUCTION_ENVIRONMENT), -/* harmony export */ E3: () => (/* binding */ DEFAULT_PIPELINE_DESCRIPTION), -/* harmony export */ E5: () => (/* binding */ DEFAULT_PR_TITLE_REGEX), -/* harmony export */ In: () => (/* binding */ ALMOST_OVERDUE_ISSUE), -/* harmony export */ KE: () => (/* binding */ QUEUED_FOR_MERGE_PREFIX), -/* harmony export */ Md: () => (/* binding */ DEFAULT_PIPELINE_STATUS), -/* harmony export */ Nj: () => (/* binding */ OVERDUE_ISSUE), -/* harmony export */ PX: () => (/* binding */ SECONDS_IN_A_DAY), -/* harmony export */ Qc: () => (/* binding */ LATE_REVIEW), -/* harmony export */ Qw: () => (/* binding */ MERGE_QUEUE_STATUS), -/* harmony export */ RB: () => (/* binding */ FIRST_QUEUED_PR_LABEL), -/* harmony export */ XD: () => (/* binding */ PEER_APPROVED_PR_LABEL), -/* harmony export */ ZV: () => (/* binding */ READY_FOR_MERGE_PR_LABEL), -/* harmony export */ hU: () => (/* binding */ JUMP_THE_QUEUE_PR_LABEL), -/* harmony export */ mR: () => (/* binding */ PRIORITY_TO_DAYS_MAP), -/* harmony export */ r0: () => (/* binding */ GITHUB_OPTIONS), -/* harmony export */ uJ: () => (/* binding */ CORE_APPROVED_PR_LABEL), -/* harmony export */ zh: () => (/* binding */ PRIORITY_LABELS) -/* harmony export */ }); -/* unused harmony exports PRIORITY_1, PRIORITY_2, PRIORITY_3, PRIORITY_4, COPYRIGHT_HEADER */ -/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -// These extra headers are for experimental API features on Github Enterprise. See https://docs.github.com/en/enterprise-server@3.0/rest/overview/api-previews for details. -const PREVIEWS = ['ant-man', 'flash', 'groot', 'inertia', 'starfox']; -const GITHUB_OPTIONS = { - headers: { - accept: PREVIEWS.map(preview => `application/vnd.github.${preview}-preview+json`).join() - } -}; -const SECONDS_IN_A_DAY = 86400000; -const DEFAULT_PIPELINE_STATUS = 'Pipeline Status'; -const DEFAULT_PIPELINE_DESCRIPTION = 'Pipeline clear.'; -const PRODUCTION_ENVIRONMENT = 'production'; -const LATE_REVIEW = 'Late Review'; -const OVERDUE_ISSUE = 'Overdue'; -const ALMOST_OVERDUE_ISSUE = 'Due Soon'; -const PRIORITY_1 = 'Priority: Critical'; -const PRIORITY_2 = 'Priority: High'; -const PRIORITY_3 = 'Priority: Medium'; -const PRIORITY_4 = 'Priority: Low'; -const PRIORITY_LABELS = [PRIORITY_1, PRIORITY_2, PRIORITY_3, PRIORITY_4]; -const PRIORITY_TO_DAYS_MAP = { - [PRIORITY_1]: 2, - [PRIORITY_2]: 14, - [PRIORITY_3]: 45, - [PRIORITY_4]: 90 -}; -const CORE_APPROVED_PR_LABEL = 'CORE APPROVED'; -const PEER_APPROVED_PR_LABEL = 'PEER APPROVED'; -const READY_FOR_MERGE_PR_LABEL = 'READY FOR MERGE'; -const MERGE_QUEUE_STATUS = 'QUEUE CHECKER'; -const QUEUED_FOR_MERGE_PREFIX = 'QUEUED FOR MERGE'; -const FIRST_QUEUED_PR_LABEL = `${QUEUED_FOR_MERGE_PREFIX} #1`; -const JUMP_THE_QUEUE_PR_LABEL = 'JUMP THE QUEUE'; -const DEFAULT_PR_TITLE_REGEX = '^(build|ci|chore|docs|feat|fix|perf|refactor|style|test|revert|Revert|BREAKING CHANGE)((.*))?: .+$'; -const COPYRIGHT_HEADER = (/* unused pure expression or super */ null && (`/* -Copyright 2021 Expedia, Inc. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/`)); - - -/***/ }), - /***/ 8654: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { @@ -97,14 +12,13 @@ __webpack_require__.r(__webpack_exports__); /* harmony export */ }); /* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7484); /* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_actions_core__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _types_generated__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(8428); +/* harmony import */ var _types_generated__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8428); /* harmony import */ var _actions_github__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3228); /* harmony import */ var _actions_github__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_actions_github__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var micromatch__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8785); /* harmony import */ var micromatch__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(micromatch__WEBPACK_IMPORTED_MODULE_2__); /* harmony import */ var _octokit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6590); /* harmony import */ var _utils_merge_queue__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5323); -/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7242); /* Copyright 2021 Expedia, Inc. Licensed under the Apache License, Version 2.0 (the "License"); @@ -123,23 +37,40 @@ limitations under the License. - -class FilterPaths extends _types_generated__WEBPACK_IMPORTED_MODULE_6__/* .HelperInputs */ .m { +class FilterPaths extends _types_generated__WEBPACK_IMPORTED_MODULE_5__/* .HelperInputs */ .m { } -const filterPaths = async ({ paths, globs, sha, packages }) => { +const filterPaths = async ({ paths, globs, sha, packages, merge_queue_enabled }) => { if (!paths && !globs && !packages) { _actions_core__WEBPACK_IMPORTED_MODULE_0__.error('Must pass `globs` or `paths` or `packages` for filtering'); return false; } - const listPrsResult = sha - ? await _octokit__WEBPACK_IMPORTED_MODULE_3__/* .octokit */ .A.repos.listPullRequestsAssociatedWithCommit({ + let pull_number; + if (_actions_github__WEBPACK_IMPORTED_MODULE_1__.context.eventName === 'merge_group') { + pull_number = (0,_utils_merge_queue__WEBPACK_IMPORTED_MODULE_4__/* .getPrNumberFromMergeQueueRef */ .M)(); + } + else if (sha && merge_queue_enabled === 'true') { + const branchesResult = sha + ? await _octokit__WEBPACK_IMPORTED_MODULE_3__/* .octokit */ .A.repos.listBranchesForHeadCommit({ + commit_sha: sha, + ..._actions_github__WEBPACK_IMPORTED_MODULE_1__.context.repo + }) + : undefined; + const branchName = branchesResult?.data[0]?.name; + pull_number = (0,_utils_merge_queue__WEBPACK_IMPORTED_MODULE_4__/* .getPrNumberFromMergeQueueRef */ .M)(branchName); + } + else if (sha) { + const listPrsResult = await _octokit__WEBPACK_IMPORTED_MODULE_3__/* .octokit */ .A.repos.listPullRequestsAssociatedWithCommit({ commit_sha: sha, - ..._actions_github__WEBPACK_IMPORTED_MODULE_1__.context.repo, - ..._constants__WEBPACK_IMPORTED_MODULE_5__/* .GITHUB_OPTIONS */ .r0 - }) - : undefined; - const prNumberFromSha = listPrsResult?.data.find(Boolean)?.number; - const pull_number = _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.eventName === 'merge_group' ? (0,_utils_merge_queue__WEBPACK_IMPORTED_MODULE_4__/* .getPrNumberFromMergeQueueRef */ .M)() : (prNumberFromSha ?? _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.issue.number); + ..._actions_github__WEBPACK_IMPORTED_MODULE_1__.context.repo + }); + const prFromSha = listPrsResult?.data.find(Boolean); + if (!prFromSha) + throw new Error(`No PR found for commit ${sha}`); + pull_number = prFromSha.number; + } + else { + pull_number = _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.issue.number; + } const { data } = await _octokit__WEBPACK_IMPORTED_MODULE_3__/* .octokit */ .A.pulls.listFiles({ per_page: 100, pull_number, @@ -257,8 +188,8 @@ const getMergeQueueCommitHashes = async () => { const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/')); return mergeQueueBranches.map(branch => branch.commit.sha); }; -const getPrNumberFromMergeQueueRef = () => { - const prNumber = Number(_actions_github__WEBPACK_IMPORTED_MODULE_1__.context.ref +const getPrNumberFromMergeQueueRef = (ref = _actions_github__WEBPACK_IMPORTED_MODULE_1__.context.ref) => { + const prNumber = Number(ref .split('/') .find(part => part.includes('pr-')) ?.match(/\d+/)?.[0]); diff --git a/dist/654.index.js.map b/dist/654.index.js.map index 4a83577e..5c0c9d53 100644 --- a/dist/654.index.js.map +++ b/dist/654.index.js.map @@ -1 +1 @@ -{"version":3,"file":"654.index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;AAWA;;;;;;;;;;;;;;;;;;;;;;;AC1DA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AAKA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;;;;;;;;;;;;;;;;;;ACxEA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAEA;AACA;;;;;;;;;;;AClBA;;;;;;;;;;;AAWA;AAEA;AAsDA;;;;;;;;;;;;;;;ACnEA;;;;;;;;;;;AAWA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACjCA;;;;;;;;;;;AAWA;AAGA;AACA;AAEA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sources":[".././src/constants.ts",".././src/helpers/filter-paths.ts",".././src/octokit.ts",".././src/types/generated.ts",".././src/utils/merge-queue.ts",".././src/utils/paginate-all-branches.ts"],"sourcesContent":["/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n// These extra headers are for experimental API features on Github Enterprise. See https://docs.github.com/en/enterprise-server@3.0/rest/overview/api-previews for details.\nconst PREVIEWS = ['ant-man', 'flash', 'groot', 'inertia', 'starfox'];\nexport const GITHUB_OPTIONS = {\n headers: {\n accept: PREVIEWS.map(preview => `application/vnd.github.${preview}-preview+json`).join()\n }\n};\n\nexport const SECONDS_IN_A_DAY = 86400000;\nexport const DEFAULT_PIPELINE_STATUS = 'Pipeline Status';\nexport const DEFAULT_PIPELINE_DESCRIPTION = 'Pipeline clear.';\nexport const PRODUCTION_ENVIRONMENT = 'production';\nexport const LATE_REVIEW = 'Late Review';\nexport const OVERDUE_ISSUE = 'Overdue';\nexport const ALMOST_OVERDUE_ISSUE = 'Due Soon';\nexport const PRIORITY_1 = 'Priority: Critical';\nexport const PRIORITY_2 = 'Priority: High';\nexport const PRIORITY_3 = 'Priority: Medium';\nexport const PRIORITY_4 = 'Priority: Low';\nexport const PRIORITY_LABELS = [PRIORITY_1, PRIORITY_2, PRIORITY_3, PRIORITY_4] as const;\nexport const PRIORITY_TO_DAYS_MAP = {\n [PRIORITY_1]: 2,\n [PRIORITY_2]: 14,\n [PRIORITY_3]: 45,\n [PRIORITY_4]: 90\n};\nexport const CORE_APPROVED_PR_LABEL = 'CORE APPROVED';\nexport const PEER_APPROVED_PR_LABEL = 'PEER APPROVED';\nexport const READY_FOR_MERGE_PR_LABEL = 'READY FOR MERGE';\nexport const MERGE_QUEUE_STATUS = 'QUEUE CHECKER';\nexport const QUEUED_FOR_MERGE_PREFIX = 'QUEUED FOR MERGE';\nexport const FIRST_QUEUED_PR_LABEL = `${QUEUED_FOR_MERGE_PREFIX} #1`;\nexport const JUMP_THE_QUEUE_PR_LABEL = 'JUMP THE QUEUE';\nexport const DEFAULT_PR_TITLE_REGEX = '^(build|ci|chore|docs|feat|fix|perf|refactor|style|test|revert|Revert|BREAKING CHANGE)((.*))?: .+$';\nexport const COPYRIGHT_HEADER = `/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/`;\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport * as core from '@actions/core';\nimport { HelperInputs } from '../types/generated';\nimport { context } from '@actions/github';\nimport micromatch from 'micromatch';\nimport { octokit } from '../octokit';\nimport { getPrNumberFromMergeQueueRef } from '../utils/merge-queue';\nimport { GITHUB_OPTIONS } from '../constants';\nimport { ChangedFilesList } from '../types/github';\n\nexport class FilterPaths extends HelperInputs {\n declare paths?: string;\n declare globs?: string;\n declare sha?: string;\n declare packages?: string;\n}\n\nexport const filterPaths = async ({ paths, globs, sha, packages }: FilterPaths) => {\n if (!paths && !globs && !packages) {\n core.error('Must pass `globs` or `paths` or `packages` for filtering');\n return false;\n }\n\n const listPrsResult = sha\n ? await octokit.repos.listPullRequestsAssociatedWithCommit({\n commit_sha: sha,\n ...context.repo,\n ...GITHUB_OPTIONS\n })\n : undefined;\n const prNumberFromSha = listPrsResult?.data.find(Boolean)?.number;\n const pull_number = context.eventName === 'merge_group' ? getPrNumberFromMergeQueueRef() : (prNumberFromSha ?? context.issue.number);\n\n const { data } = await octokit.pulls.listFiles({\n per_page: 100,\n pull_number,\n ...context.repo\n });\n\n if (packages && hasRelevantPackageChanged(data, packages)) {\n return true;\n }\n\n const fileNames = data.map(file => file.filename);\n if (globs) {\n if (paths) core.info('`paths` and `globs` inputs found, defaulting to use `globs` for filtering');\n return micromatch(fileNames, globs.split('\\n')).length > 0;\n } else if (paths) {\n const filePaths = paths.split('\\n');\n return fileNames.some(changedFile => filePaths.some(filePath => changedFile.startsWith(filePath)));\n }\n};\n\nconst hasRelevantPackageChanged = (files: ChangedFilesList, packages: string) => {\n const packageJson = files.find(file => file.filename === 'package.json');\n if (!packageJson) {\n return false;\n }\n\n return packages.split('\\n').some(pkg => new RegExp(`(-|\\\\+)\\\\s*\\\\\"${pkg}\\\\\"`).test(packageJson.patch ?? ''));\n};\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport * as core from '@actions/core';\nimport * as fetch from '@adobe/node-fetch-retry';\nimport { getOctokit } from '@actions/github';\n\nconst githubToken = core.getInput('github_token', { required: true });\nexport const { rest: octokit, graphql: octokitGraphql } = getOctokit(githubToken, { request: { fetch } });\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nexport class HelperInputs {\n declare helper?: string;\n declare github_token?: string;\n declare body?: string;\n declare project_name?: string;\n declare project_destination_column_name?: string;\n declare note?: string;\n declare project_origin_column_name?: string;\n declare sha?: string;\n declare context?: string;\n declare state?: string;\n declare description?: string;\n declare target_url?: string;\n declare environment?: string;\n declare environment_url?: string;\n declare label?: string;\n declare labels?: string;\n declare paths?: string;\n declare ignore_globs?: string;\n declare override_filter_paths?: string;\n declare batches?: string;\n declare pattern?: string;\n declare teams?: string;\n declare users?: string;\n declare login?: string;\n declare paths_no_filter?: string;\n declare slack_webhook_url?: string;\n declare number_of_assignees?: string;\n declare number_of_reviewers?: string;\n declare globs?: string;\n declare override_filter_globs?: string;\n declare title?: string;\n declare seconds?: string;\n declare pull_number?: string;\n declare base?: string;\n declare head?: string;\n declare days?: string;\n declare no_evict_upon_conflict?: string;\n declare skip_if_already_set?: string;\n declare delimiter?: string;\n declare team?: string;\n declare ignore_deleted?: string;\n declare return_full_payload?: string;\n declare skip_auto_merge?: string;\n declare repo_name?: string;\n declare repo_owner_name?: string;\n declare load_balancing_sizes?: string;\n declare required_review_overrides?: string;\n declare codeowners_overrides?: string;\n declare max_queue_size?: string;\n declare allow_only_for_maintainers?: string;\n declare use_basic_matrix_configuration?: string;\n declare merge_queue_enabled?: string;\n declare packages?: string;\n}\n","/*\nCopyright 2022 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { paginateAllBranches } from './paginate-all-branches';\nimport { context } from '@actions/github';\n\nexport const getMergeQueueCommitHashes = async () => {\n const branches = await paginateAllBranches();\n const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/'));\n return mergeQueueBranches.map(branch => branch.commit.sha);\n};\n\nexport const getPrNumberFromMergeQueueRef = () => {\n const prNumber = Number(\n context.ref\n .split('/')\n .find(part => part.includes('pr-'))\n ?.match(/\\d+/)?.[0]\n );\n if (isNaN(prNumber)) {\n throw new Error('Could not find PR number in merge queue ref.');\n }\n return prNumber;\n};\n","/*\nCopyright 2022 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { PullRequestBranchesList } from '../types/github';\nimport { octokit } from '../octokit';\nimport { context } from '@actions/github';\n\nexport const paginateAllBranches = async ({\n protectedBranches,\n page = 1\n}: { protectedBranches?: boolean; page?: number } = {}): Promise => {\n const response = await octokit.repos.listBranches({\n protected: protectedBranches,\n per_page: 100,\n page,\n ...context.repo\n });\n if (!response.data.length) {\n return [];\n }\n return [...response.data, ...(await paginateAllBranches({ protectedBranches, page: page + 1 }))];\n};\n"],"names":[],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"654.index.js","mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AAGA;AAMA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAAA;AACA;AACA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;;;;;;;;;;;;;;;;;;ACtFA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAEA;AACA;;;;;;;;;;;AClBA;;;;;;;;;;;AAWA;AAEA;AAsDA;;;;;;;;;;;;;;;ACnEA;;;;;;;;;;;AAWA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACjCA;;;;;;;;;;;AAWA;AAGA;AACA;AAEA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sources":[".././src/helpers/filter-paths.ts",".././src/octokit.ts",".././src/types/generated.ts",".././src/utils/merge-queue.ts",".././src/utils/paginate-all-branches.ts"],"sourcesContent":["/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport * as core from '@actions/core';\nimport { HelperInputs } from '../types/generated';\nimport { context } from '@actions/github';\nimport micromatch from 'micromatch';\nimport { octokit } from '../octokit';\nimport { getPrNumberFromMergeQueueRef } from '../utils/merge-queue';\nimport { ChangedFilesList } from '../types/github';\n\nexport class FilterPaths extends HelperInputs {\n declare paths?: string;\n declare globs?: string;\n declare sha?: string;\n declare packages?: string;\n declare merge_queue_enabled?: string;\n}\n\nexport const filterPaths = async ({ paths, globs, sha, packages, merge_queue_enabled }: FilterPaths) => {\n if (!paths && !globs && !packages) {\n core.error('Must pass `globs` or `paths` or `packages` for filtering');\n return false;\n }\n\n let pull_number: number;\n if (context.eventName === 'merge_group') {\n pull_number = getPrNumberFromMergeQueueRef();\n } else if (sha && merge_queue_enabled === 'true') {\n const branchesResult = sha\n ? await octokit.repos.listBranchesForHeadCommit({\n commit_sha: sha,\n ...context.repo\n })\n : undefined;\n const branchName = branchesResult?.data[0]?.name;\n pull_number = getPrNumberFromMergeQueueRef(branchName);\n } else if (sha) {\n const listPrsResult = await octokit.repos.listPullRequestsAssociatedWithCommit({\n commit_sha: sha,\n ...context.repo\n });\n const prFromSha = listPrsResult?.data.find(Boolean);\n if (!prFromSha) throw new Error(`No PR found for commit ${sha}`);\n pull_number = prFromSha.number;\n } else {\n pull_number = context.issue.number;\n }\n\n const { data } = await octokit.pulls.listFiles({\n per_page: 100,\n pull_number,\n ...context.repo\n });\n\n if (packages && hasRelevantPackageChanged(data, packages)) {\n return true;\n }\n\n const fileNames = data.map(file => file.filename);\n if (globs) {\n if (paths) core.info('`paths` and `globs` inputs found, defaulting to use `globs` for filtering');\n return micromatch(fileNames, globs.split('\\n')).length > 0;\n } else if (paths) {\n const filePaths = paths.split('\\n');\n return fileNames.some(changedFile => filePaths.some(filePath => changedFile.startsWith(filePath)));\n }\n};\n\nconst hasRelevantPackageChanged = (files: ChangedFilesList, packages: string) => {\n const packageJson = files.find(file => file.filename === 'package.json');\n if (!packageJson) {\n return false;\n }\n\n return packages.split('\\n').some(pkg => new RegExp(`(-|\\\\+)\\\\s*\\\\\"${pkg}\\\\\"`).test(packageJson.patch ?? ''));\n};\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport * as core from '@actions/core';\nimport * as fetch from '@adobe/node-fetch-retry';\nimport { getOctokit } from '@actions/github';\n\nconst githubToken = core.getInput('github_token', { required: true });\nexport const { rest: octokit, graphql: octokitGraphql } = getOctokit(githubToken, { request: { fetch } });\n","/*\nCopyright 2021 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nexport class HelperInputs {\n declare helper?: string;\n declare github_token?: string;\n declare body?: string;\n declare project_name?: string;\n declare project_destination_column_name?: string;\n declare note?: string;\n declare project_origin_column_name?: string;\n declare sha?: string;\n declare context?: string;\n declare state?: string;\n declare description?: string;\n declare target_url?: string;\n declare environment?: string;\n declare environment_url?: string;\n declare label?: string;\n declare labels?: string;\n declare paths?: string;\n declare ignore_globs?: string;\n declare override_filter_paths?: string;\n declare batches?: string;\n declare pattern?: string;\n declare teams?: string;\n declare users?: string;\n declare login?: string;\n declare paths_no_filter?: string;\n declare slack_webhook_url?: string;\n declare number_of_assignees?: string;\n declare number_of_reviewers?: string;\n declare globs?: string;\n declare override_filter_globs?: string;\n declare title?: string;\n declare seconds?: string;\n declare pull_number?: string;\n declare base?: string;\n declare head?: string;\n declare days?: string;\n declare no_evict_upon_conflict?: string;\n declare skip_if_already_set?: string;\n declare delimiter?: string;\n declare team?: string;\n declare ignore_deleted?: string;\n declare return_full_payload?: string;\n declare skip_auto_merge?: string;\n declare repo_name?: string;\n declare repo_owner_name?: string;\n declare load_balancing_sizes?: string;\n declare required_review_overrides?: string;\n declare codeowners_overrides?: string;\n declare max_queue_size?: string;\n declare allow_only_for_maintainers?: string;\n declare use_basic_matrix_configuration?: string;\n declare merge_queue_enabled?: string;\n declare packages?: string;\n}\n","/*\nCopyright 2022 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { paginateAllBranches } from './paginate-all-branches';\nimport { context } from '@actions/github';\n\nexport const getMergeQueueCommitHashes = async () => {\n const branches = await paginateAllBranches();\n const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/'));\n return mergeQueueBranches.map(branch => branch.commit.sha);\n};\n\nexport const getPrNumberFromMergeQueueRef = (ref = context.ref) => {\n const prNumber = Number(\n ref\n .split('/')\n .find(part => part.includes('pr-'))\n ?.match(/\\d+/)?.[0]\n );\n if (isNaN(prNumber)) {\n throw new Error('Could not find PR number in merge queue ref.');\n }\n return prNumber;\n};\n","/*\nCopyright 2022 Expedia, Inc.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n https://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { PullRequestBranchesList } from '../types/github';\nimport { octokit } from '../octokit';\nimport { context } from '@actions/github';\n\nexport const paginateAllBranches = async ({\n protectedBranches,\n page = 1\n}: { protectedBranches?: boolean; page?: number } = {}): Promise => {\n const response = await octokit.repos.listBranches({\n protected: protectedBranches,\n per_page: 100,\n page,\n ...context.repo\n });\n if (!response.data.length) {\n return [];\n }\n return [...response.data, ...(await paginateAllBranches({ protectedBranches, page: page + 1 }))];\n};\n"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/src/helpers/filter-paths.ts b/src/helpers/filter-paths.ts index 560b2cfa..ce59eb23 100644 --- a/src/helpers/filter-paths.ts +++ b/src/helpers/filter-paths.ts @@ -17,7 +17,6 @@ import { context } from '@actions/github'; import micromatch from 'micromatch'; import { octokit } from '../octokit'; import { getPrNumberFromMergeQueueRef } from '../utils/merge-queue'; -import { GITHUB_OPTIONS } from '../constants'; import { ChangedFilesList } from '../types/github'; export class FilterPaths extends HelperInputs { @@ -25,23 +24,38 @@ export class FilterPaths extends HelperInputs { declare globs?: string; declare sha?: string; declare packages?: string; + declare merge_queue_enabled?: string; } -export const filterPaths = async ({ paths, globs, sha, packages }: FilterPaths) => { +export const filterPaths = async ({ paths, globs, sha, packages, merge_queue_enabled }: FilterPaths) => { if (!paths && !globs && !packages) { core.error('Must pass `globs` or `paths` or `packages` for filtering'); return false; } - const listPrsResult = sha - ? await octokit.repos.listPullRequestsAssociatedWithCommit({ - commit_sha: sha, - ...context.repo, - ...GITHUB_OPTIONS - }) - : undefined; - const prNumberFromSha = listPrsResult?.data.find(Boolean)?.number; - const pull_number = context.eventName === 'merge_group' ? getPrNumberFromMergeQueueRef() : (prNumberFromSha ?? context.issue.number); + let pull_number: number; + if (context.eventName === 'merge_group') { + pull_number = getPrNumberFromMergeQueueRef(); + } else if (sha && merge_queue_enabled === 'true') { + const branchesResult = sha + ? await octokit.repos.listBranchesForHeadCommit({ + commit_sha: sha, + ...context.repo + }) + : undefined; + const branchName = branchesResult?.data[0]?.name; + pull_number = getPrNumberFromMergeQueueRef(branchName); + } else if (sha) { + const listPrsResult = await octokit.repos.listPullRequestsAssociatedWithCommit({ + commit_sha: sha, + ...context.repo + }); + const prFromSha = listPrsResult?.data.find(Boolean); + if (!prFromSha) throw new Error(`No PR found for commit ${sha}`); + pull_number = prFromSha.number; + } else { + pull_number = context.issue.number; + } const { data } = await octokit.pulls.listFiles({ per_page: 100, diff --git a/src/utils/merge-queue.ts b/src/utils/merge-queue.ts index 50ded80f..ec014e96 100644 --- a/src/utils/merge-queue.ts +++ b/src/utils/merge-queue.ts @@ -20,9 +20,9 @@ export const getMergeQueueCommitHashes = async () => { return mergeQueueBranches.map(branch => branch.commit.sha); }; -export const getPrNumberFromMergeQueueRef = () => { +export const getPrNumberFromMergeQueueRef = (ref = context.ref) => { const prNumber = Number( - context.ref + ref .split('/') .find(part => part.includes('pr-')) ?.match(/\d+/)?.[0] diff --git a/test/helpers/filter-paths.test.ts b/test/helpers/filter-paths.test.ts index 1c90eff8..a75753e2 100644 --- a/test/helpers/filter-paths.test.ts +++ b/test/helpers/filter-paths.test.ts @@ -22,12 +22,22 @@ jest.mock('@actions/github', () => ({ getOctokit: jest.fn(() => ({ rest: { pulls: { listFiles: jest.fn() }, - repos: { listPullRequestsAssociatedWithCommit: jest.fn(() => ({ data: [{ number: 789 }] })) } + repos: { + listPullRequestsAssociatedWithCommit: jest.fn(() => ({ data: [{ number: 789 }] })), + listBranchesForHeadCommit: jest.fn(() => ({ + data: [{ name: 'gh-readonly-queue/default-branch/pr-999-f0d9a4cb862b13cdaab6522f72d6dc17e4336b7f' }] + })) + } } })) })); describe('filterPaths', () => { + afterEach(() => { + context.eventName = ''; + context.ref = ''; + }); + const paths = 'file/path/1\nfile/path/2'; const globs = '**/*.md\nsomething/**/file1.txt'; @@ -216,6 +226,21 @@ describe('filterPaths', () => { expect(octokit.repos.listPullRequestsAssociatedWithCommit).not.toHaveBeenCalled(); }); + it('should call listFiles with correct pr number in merge queue with sha case', async () => { + await filterPaths({ + paths, + sha: 'sha', + merge_queue_enabled: 'true' + }); + + expect(octokit.pulls.listFiles).toHaveBeenCalledWith({ + per_page: 100, + pull_number: 999, + ...context.repo + }); + expect(octokit.repos.listPullRequestsAssociatedWithCommit).not.toHaveBeenCalled(); + }); + it('should return false when no filtering params are passed', async () => { const result = await filterPaths({});