diff --git a/dist/264.index.js b/dist/264.index.js index 406af148..187384a9 100644 --- a/dist/264.index.js +++ b/dist/264.index.js @@ -244,7 +244,7 @@ limitations under the License. const getMergeQueueCommitHashes = async () => { const branches = await (0,_paginate_all_branches__WEBPACK_IMPORTED_MODULE_0__/* .paginateAllBranches */ .h)(); - const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/merge-queue/')); + const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/')); return mergeQueueBranches.map(branch => branch.commit.sha); }; diff --git a/dist/264.index.js.map b/dist/264.index.js.map index 1d5238f9..a1ab018a 100644 --- a/dist/264.index.js.map +++ b/dist/264.index.js.map @@ -1 +1 @@ -{"version":3,"file":"264.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;AAGA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;;AACA;AACA;AAKA;AAAA;AAEA;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;;;;;;;;;;;;;;;;;;ACzEA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAEA;AACA;;;;;;;;;;;AClBA;;;;;;;;;;;AAWA;AAEA;AAoDA;;;;;;;;;;;;ACjEA;;;;;;;;;;;AAWA;AAEA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACnBA;;;;;;;;;;;AAWA;AAGA;AACA;AAEA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sources":[".././src/constants.ts",".././src/helpers/initiate-deployment.ts",".././src/octokit.ts",".././src/types/generated.ts",".././src/utils/get-merge-queue-commit-hashes.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 { DeploymentState } from '../types/github';\nimport { DEFAULT_PIPELINE_STATUS, GITHUB_OPTIONS } from '../constants';\nimport { HelperInputs } from '../types/generated';\nimport { context as githubContext } from '@actions/github';\nimport { octokit } from '../octokit';\nimport { map } from 'bluebird';\nimport { getMergeQueueCommitHashes } from '../utils/get-merge-queue-commit-hashes';\n\nexport class InitiateDeployment extends HelperInputs {\n sha = '';\n environment = '';\n state?: DeploymentState;\n environment_url?: string;\n description?: string;\n target_url?: string;\n}\n\nexport const initiateDeployment = async ({\n sha,\n state = 'in_progress',\n context = DEFAULT_PIPELINE_STATUS,\n environment,\n environment_url,\n description,\n target_url\n}: InitiateDeployment) => {\n const { data } = await octokit.repos.createDeployment({\n ref: sha,\n environment,\n auto_merge: false,\n required_contexts: [],\n ...githubContext.repo,\n ...GITHUB_OPTIONS\n });\n const deployment_id = 'ref' in data ? data.id : undefined;\n if (!deployment_id) return;\n\n await octokit.repos.createDeploymentStatus({\n state,\n deployment_id,\n description,\n environment_url,\n target_url,\n ...githubContext.repo,\n ...GITHUB_OPTIONS\n });\n\n const commitHashesForMergeQueueBranches = await getMergeQueueCommitHashes();\n await map(commitHashesForMergeQueueBranches, async sha =>\n octokit.repos.createCommitStatus({\n sha,\n context,\n state: 'pending',\n description,\n target_url,\n ...githubContext.repo\n })\n );\n\n return deployment_id;\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 helper?: string;\n github_token?: string;\n body?: string;\n project_name?: string;\n project_destination_column_name?: string;\n note?: string;\n project_origin_column_name?: string;\n sha?: string;\n context?: string;\n state?: string;\n description?: string;\n target_url?: string;\n environment?: string;\n environment_url?: string;\n label?: string;\n labels?: string;\n paths?: string;\n ignore_globs?: string;\n extensions?: string;\n override_filter_paths?: string;\n batches?: string;\n pattern?: string;\n teams?: string;\n users?: string;\n login?: string;\n paths_no_filter?: string;\n slack_webhook_url?: string;\n number_of_assignees?: string;\n number_of_reviewers?: string;\n globs?: string;\n override_filter_globs?: string;\n title?: string;\n seconds?: string;\n pull_number?: string;\n base?: string;\n head?: string;\n days?: string;\n no_evict_upon_conflict?: string;\n skip_if_already_set?: string;\n delimiter?: string;\n team?: string;\n ignore_deleted?: string;\n return_full_payload?: string;\n skip_auto_merge?: string;\n repo_name?: string;\n repo_owner_name?: string;\n load_balancing_sizes?: string;\n required_review_overrides?: string;\n max_queue_size?: string;\n allow_only_for_maintainers?: string;\n use_basic_matrix_configuration?: 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';\n\nexport const getMergeQueueCommitHashes = async () => {\n const branches = await paginateAllBranches();\n const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/merge-queue/'));\n return mergeQueueBranches.map(branch => branch.commit.sha);\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":"264.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;AAGA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;;AACA;AACA;AAKA;AAAA;AAEA;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;;;;;;;;;;;;;;;;;;ACzEA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAEA;AACA;;;;;;;;;;;AClBA;;;;;;;;;;;AAWA;AAEA;AAoDA;;;;;;;;;;;;ACjEA;;;;;;;;;;;AAWA;AAEA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACnBA;;;;;;;;;;;AAWA;AAGA;AACA;AAEA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sources":[".././src/constants.ts",".././src/helpers/initiate-deployment.ts",".././src/octokit.ts",".././src/types/generated.ts",".././src/utils/get-merge-queue-commit-hashes.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 { DeploymentState } from '../types/github';\nimport { DEFAULT_PIPELINE_STATUS, GITHUB_OPTIONS } from '../constants';\nimport { HelperInputs } from '../types/generated';\nimport { context as githubContext } from '@actions/github';\nimport { octokit } from '../octokit';\nimport { map } from 'bluebird';\nimport { getMergeQueueCommitHashes } from '../utils/get-merge-queue-commit-hashes';\n\nexport class InitiateDeployment extends HelperInputs {\n sha = '';\n environment = '';\n state?: DeploymentState;\n environment_url?: string;\n description?: string;\n target_url?: string;\n}\n\nexport const initiateDeployment = async ({\n sha,\n state = 'in_progress',\n context = DEFAULT_PIPELINE_STATUS,\n environment,\n environment_url,\n description,\n target_url\n}: InitiateDeployment) => {\n const { data } = await octokit.repos.createDeployment({\n ref: sha,\n environment,\n auto_merge: false,\n required_contexts: [],\n ...githubContext.repo,\n ...GITHUB_OPTIONS\n });\n const deployment_id = 'ref' in data ? data.id : undefined;\n if (!deployment_id) return;\n\n await octokit.repos.createDeploymentStatus({\n state,\n deployment_id,\n description,\n environment_url,\n target_url,\n ...githubContext.repo,\n ...GITHUB_OPTIONS\n });\n\n const commitHashesForMergeQueueBranches = await getMergeQueueCommitHashes();\n await map(commitHashesForMergeQueueBranches, async sha =>\n octokit.repos.createCommitStatus({\n sha,\n context,\n state: 'pending',\n description,\n target_url,\n ...githubContext.repo\n })\n );\n\n return deployment_id;\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 helper?: string;\n github_token?: string;\n body?: string;\n project_name?: string;\n project_destination_column_name?: string;\n note?: string;\n project_origin_column_name?: string;\n sha?: string;\n context?: string;\n state?: string;\n description?: string;\n target_url?: string;\n environment?: string;\n environment_url?: string;\n label?: string;\n labels?: string;\n paths?: string;\n ignore_globs?: string;\n extensions?: string;\n override_filter_paths?: string;\n batches?: string;\n pattern?: string;\n teams?: string;\n users?: string;\n login?: string;\n paths_no_filter?: string;\n slack_webhook_url?: string;\n number_of_assignees?: string;\n number_of_reviewers?: string;\n globs?: string;\n override_filter_globs?: string;\n title?: string;\n seconds?: string;\n pull_number?: string;\n base?: string;\n head?: string;\n days?: string;\n no_evict_upon_conflict?: string;\n skip_if_already_set?: string;\n delimiter?: string;\n team?: string;\n ignore_deleted?: string;\n return_full_payload?: string;\n skip_auto_merge?: string;\n repo_name?: string;\n repo_owner_name?: string;\n load_balancing_sizes?: string;\n required_review_overrides?: string;\n max_queue_size?: string;\n allow_only_for_maintainers?: string;\n use_basic_matrix_configuration?: 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';\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","/*\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 81a12290..65de40e8 100644 --- a/dist/467.index.js +++ b/dist/467.index.js @@ -242,7 +242,7 @@ limitations under the License. const getMergeQueueCommitHashes = async () => { const branches = await (0,_paginate_all_branches__WEBPACK_IMPORTED_MODULE_0__/* .paginateAllBranches */ .h)(); - const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/merge-queue/')); + const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/')); return mergeQueueBranches.map(branch => branch.commit.sha); }; diff --git a/dist/467.index.js.map b/dist/467.index.js.map index fa1bdd0c..1697850c 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;AAKA;AAEA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;;;;;;;;;;;;;;;;;;ACpEA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAEA;AACA;;;;;;;;;;;AClBA;;;;;;;;;;;AAWA;AAEA;AAoDA;;;;;;;;;;;;ACjEA;;;;;;;;;;;AAWA;AAEA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACnBA;;;;;;;;;;;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/get-merge-queue-commit-hashes.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/get-merge-queue-commit-hashes';\n\nexport class NotifyPipelineComplete extends HelperInputs {\n context?: string;\n description?: string;\n environment?: string;\n target_url?: 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}: NotifyPipelineComplete) => {\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 const mergeQueueCommitHashes = await getMergeQueueCommitHashes();\n const commitHashes = mergeQueueCommitHashes.length ? mergeQueueCommitHashes : commitHashesForOpenPullRequests;\n await map(commitHashes, async sha =>\n octokit.repos.createCommitStatus({\n sha,\n context,\n state: 'success',\n description,\n target_url,\n ...githubContext.repo\n })\n );\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) {\n return 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};\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 helper?: string;\n github_token?: string;\n body?: string;\n project_name?: string;\n project_destination_column_name?: string;\n note?: string;\n project_origin_column_name?: string;\n sha?: string;\n context?: string;\n state?: string;\n description?: string;\n target_url?: string;\n environment?: string;\n environment_url?: string;\n label?: string;\n labels?: string;\n paths?: string;\n ignore_globs?: string;\n extensions?: string;\n override_filter_paths?: string;\n batches?: string;\n pattern?: string;\n teams?: string;\n users?: string;\n login?: string;\n paths_no_filter?: string;\n slack_webhook_url?: string;\n number_of_assignees?: string;\n number_of_reviewers?: string;\n globs?: string;\n override_filter_globs?: string;\n title?: string;\n seconds?: string;\n pull_number?: string;\n base?: string;\n head?: string;\n days?: string;\n no_evict_upon_conflict?: string;\n skip_if_already_set?: string;\n delimiter?: string;\n team?: string;\n ignore_deleted?: string;\n return_full_payload?: string;\n skip_auto_merge?: string;\n repo_name?: string;\n repo_owner_name?: string;\n load_balancing_sizes?: string;\n required_review_overrides?: string;\n max_queue_size?: string;\n allow_only_for_maintainers?: string;\n use_basic_matrix_configuration?: 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';\n\nexport const getMergeQueueCommitHashes = async () => {\n const branches = await paginateAllBranches();\n const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/merge-queue/'));\n return mergeQueueBranches.map(branch => branch.commit.sha);\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;AAKA;AAEA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;;;;;;;;;;;;;;;;;;ACpEA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAEA;AACA;;;;;;;;;;;AClBA;;;;;;;;;;;AAWA;AAEA;AAoDA;;;;;;;;;;;;ACjEA;;;;;;;;;;;AAWA;AAEA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACnBA;;;;;;;;;;;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/get-merge-queue-commit-hashes.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/get-merge-queue-commit-hashes';\n\nexport class NotifyPipelineComplete extends HelperInputs {\n context?: string;\n description?: string;\n environment?: string;\n target_url?: 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}: NotifyPipelineComplete) => {\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 const mergeQueueCommitHashes = await getMergeQueueCommitHashes();\n const commitHashes = mergeQueueCommitHashes.length ? mergeQueueCommitHashes : commitHashesForOpenPullRequests;\n await map(commitHashes, async sha =>\n octokit.repos.createCommitStatus({\n sha,\n context,\n state: 'success',\n description,\n target_url,\n ...githubContext.repo\n })\n );\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) {\n return 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};\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 helper?: string;\n github_token?: string;\n body?: string;\n project_name?: string;\n project_destination_column_name?: string;\n note?: string;\n project_origin_column_name?: string;\n sha?: string;\n context?: string;\n state?: string;\n description?: string;\n target_url?: string;\n environment?: string;\n environment_url?: string;\n label?: string;\n labels?: string;\n paths?: string;\n ignore_globs?: string;\n extensions?: string;\n override_filter_paths?: string;\n batches?: string;\n pattern?: string;\n teams?: string;\n users?: string;\n login?: string;\n paths_no_filter?: string;\n slack_webhook_url?: string;\n number_of_assignees?: string;\n number_of_reviewers?: string;\n globs?: string;\n override_filter_globs?: string;\n title?: string;\n seconds?: string;\n pull_number?: string;\n base?: string;\n head?: string;\n days?: string;\n no_evict_upon_conflict?: string;\n skip_if_already_set?: string;\n delimiter?: string;\n team?: string;\n ignore_deleted?: string;\n return_full_payload?: string;\n skip_auto_merge?: string;\n repo_name?: string;\n repo_owner_name?: string;\n load_balancing_sizes?: string;\n required_review_overrides?: string;\n max_queue_size?: string;\n allow_only_for_maintainers?: string;\n use_basic_matrix_configuration?: 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';\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","/*\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 e184c9c3..dd5e7c99 100644 --- a/dist/604.index.js +++ b/dist/604.index.js @@ -30,12 +30,8 @@ limitations under the License. class GetMergeQueuePosition extends _types_generated__WEBPACK_IMPORTED_MODULE_2__/* .HelperInputs */ .m { - constructor() { - super(...arguments); - this.sha = ''; - } } -const getMergeQueuePosition = async ({ sha, max_queue_size = '10' }) => { +const getMergeQueuePosition = async ({ max_queue_size = '10' }) => { const { repository } = await (0,_octokit__WEBPACK_IMPORTED_MODULE_1__/* .octokitGraphql */ .n)(` query { repository(owner: "${_actions_github__WEBPACK_IMPORTED_MODULE_0__.context.repo.owner}", name: "${_actions_github__WEBPACK_IMPORTED_MODULE_0__.context.repo.repo}") { @@ -52,13 +48,12 @@ query { } } `); - const { data: pullRequests } = await _octokit__WEBPACK_IMPORTED_MODULE_1__/* .octokit */ .A.repos.listPullRequestsAssociatedWithCommit({ - commit_sha: sha, - ..._actions_github__WEBPACK_IMPORTED_MODULE_0__.context.repo - }); - const pullRequestNumber = pullRequests.find(Boolean)?.number; + const prNumberFromMergeQueueRef = Number(_actions_github__WEBPACK_IMPORTED_MODULE_0__.context.ref + .split('/') + .find(part => part.includes('pr-')) + ?.match(/\d+/)?.[0]); const mergeQueueEntries = repository.mergeQueue?.entries?.nodes; - return mergeQueueEntries?.find(entry => entry?.pullRequest?.number === Number(pullRequestNumber))?.position; + return mergeQueueEntries?.find(entry => entry?.pullRequest?.number === prNumberFromMergeQueueRef)?.position; }; diff --git a/dist/604.index.js.map b/dist/604.index.js.map index a8e6e303..32e63334 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;AAGA;AAAA;;AACA;AAEA;AAAA;AAEA;AACA;;AAEA;;AAEA;;;;;;;;;;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;AC/CA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAEA;AACA;;;;;;;;;;;AClBA;;;;;;;;;;;AAWA;AAEA;AAoDA","sources":[".././src/helpers/get-merge-queue-position.ts",".././src/octokit.ts",".././src/types/generated.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 { octokit, octokitGraphql } from '../octokit';\nimport { Repository } from '@octokit/graphql-schema';\n\nexport class GetMergeQueuePosition extends HelperInputs {\n sha = '';\n max_queue_size?: string;\n}\n\nexport const getMergeQueuePosition = async ({ sha, 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 { data: pullRequests } = await octokit.repos.listPullRequestsAssociatedWithCommit({\n commit_sha: sha,\n ...context.repo\n });\n const pullRequestNumber = pullRequests.find(Boolean)?.number;\n const mergeQueueEntries = repository.mergeQueue?.entries?.nodes;\n return mergeQueueEntries?.find(entry => entry?.pullRequest?.number === Number(pullRequestNumber))?.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 helper?: string;\n github_token?: string;\n body?: string;\n project_name?: string;\n project_destination_column_name?: string;\n note?: string;\n project_origin_column_name?: string;\n sha?: string;\n context?: string;\n state?: string;\n description?: string;\n target_url?: string;\n environment?: string;\n environment_url?: string;\n label?: string;\n labels?: string;\n paths?: string;\n ignore_globs?: string;\n extensions?: string;\n override_filter_paths?: string;\n batches?: string;\n pattern?: string;\n teams?: string;\n users?: string;\n login?: string;\n paths_no_filter?: string;\n slack_webhook_url?: string;\n number_of_assignees?: string;\n number_of_reviewers?: string;\n globs?: string;\n override_filter_globs?: string;\n title?: string;\n seconds?: string;\n pull_number?: string;\n base?: string;\n head?: string;\n days?: string;\n no_evict_upon_conflict?: string;\n skip_if_already_set?: string;\n delimiter?: string;\n team?: string;\n ignore_deleted?: string;\n return_full_payload?: string;\n skip_auto_merge?: string;\n repo_name?: string;\n repo_owner_name?: string;\n load_balancing_sizes?: string;\n required_review_overrides?: string;\n max_queue_size?: string;\n allow_only_for_maintainers?: string;\n use_basic_matrix_configuration?: string;\n}\n"],"names":[],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"604.index.js","mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAGA;AAEA;AAEA;AACA;;AAEA;;AAEA;;;;;;;;;;;AAWA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;AC/CA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAEA;AACA;;;;;;;;;;;AClBA;;;;;;;;;;;AAWA;AAEA;AAoDA","sources":[".././src/helpers/get-merge-queue-position.ts",".././src/octokit.ts",".././src/types/generated.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';\n\nexport class GetMergeQueuePosition extends HelperInputs {\n 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 = Number(\n context.ref\n .split('/')\n .find(part => part.includes('pr-'))\n ?.match(/\\d+/)?.[0]\n );\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 helper?: string;\n github_token?: string;\n body?: string;\n project_name?: string;\n project_destination_column_name?: string;\n note?: string;\n project_origin_column_name?: string;\n sha?: string;\n context?: string;\n state?: string;\n description?: string;\n target_url?: string;\n environment?: string;\n environment_url?: string;\n label?: string;\n labels?: string;\n paths?: string;\n ignore_globs?: string;\n extensions?: string;\n override_filter_paths?: string;\n batches?: string;\n pattern?: string;\n teams?: string;\n users?: string;\n login?: string;\n paths_no_filter?: string;\n slack_webhook_url?: string;\n number_of_assignees?: string;\n number_of_reviewers?: string;\n globs?: string;\n override_filter_globs?: string;\n title?: string;\n seconds?: string;\n pull_number?: string;\n base?: string;\n head?: string;\n days?: string;\n no_evict_upon_conflict?: string;\n skip_if_already_set?: string;\n delimiter?: string;\n team?: string;\n ignore_deleted?: string;\n return_full_payload?: string;\n skip_auto_merge?: string;\n repo_name?: string;\n repo_owner_name?: string;\n load_balancing_sizes?: string;\n required_review_overrides?: string;\n max_queue_size?: string;\n allow_only_for_maintainers?: string;\n use_basic_matrix_configuration?: string;\n}\n"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/src/helpers/get-merge-queue-position.ts b/src/helpers/get-merge-queue-position.ts index ecfb3e87..281cf24f 100644 --- a/src/helpers/get-merge-queue-position.ts +++ b/src/helpers/get-merge-queue-position.ts @@ -13,15 +13,14 @@ limitations under the License. import { HelperInputs } from '../types/generated'; import { context } from '@actions/github'; -import { octokit, octokitGraphql } from '../octokit'; +import { octokitGraphql } from '../octokit'; import { Repository } from '@octokit/graphql-schema'; export class GetMergeQueuePosition extends HelperInputs { - sha = ''; max_queue_size?: string; } -export const getMergeQueuePosition = async ({ sha, max_queue_size = '10' }: GetMergeQueuePosition) => { +export const getMergeQueuePosition = async ({ max_queue_size = '10' }: GetMergeQueuePosition) => { const { repository } = await octokitGraphql<{ repository: Repository }>(` query { repository(owner: "${context.repo.owner}", name: "${context.repo.repo}") { @@ -38,11 +37,12 @@ query { } } `); - const { data: pullRequests } = await octokit.repos.listPullRequestsAssociatedWithCommit({ - commit_sha: sha, - ...context.repo - }); - const pullRequestNumber = pullRequests.find(Boolean)?.number; + const prNumberFromMergeQueueRef = Number( + context.ref + .split('/') + .find(part => part.includes('pr-')) + ?.match(/\d+/)?.[0] + ); const mergeQueueEntries = repository.mergeQueue?.entries?.nodes; - return mergeQueueEntries?.find(entry => entry?.pullRequest?.number === Number(pullRequestNumber))?.position; + return mergeQueueEntries?.find(entry => entry?.pullRequest?.number === prNumberFromMergeQueueRef)?.position; }; diff --git a/src/utils/get-merge-queue-commit-hashes.ts b/src/utils/get-merge-queue-commit-hashes.ts index 427d7b64..bc95f442 100644 --- a/src/utils/get-merge-queue-commit-hashes.ts +++ b/src/utils/get-merge-queue-commit-hashes.ts @@ -15,6 +15,6 @@ import { paginateAllBranches } from './paginate-all-branches'; export const getMergeQueueCommitHashes = async () => { const branches = await paginateAllBranches(); - const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/merge-queue/')); + const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/')); return mergeQueueBranches.map(branch => branch.commit.sha); }; diff --git a/test/helpers/filter-paths.test.ts b/test/helpers/filter-paths.test.ts index 0188811d..f2f189bc 100644 --- a/test/helpers/filter-paths.test.ts +++ b/test/helpers/filter-paths.test.ts @@ -211,7 +211,7 @@ describe('filterPaths', () => { it('should not call listPullRequestsAssociatedWithCommit if sha is omitted', async () => { context.eventName = 'merge_group'; - context.ref = 'refs/heads/gh-readonly-queue/branch-name/pr-12345-f0d9a4cb862b13cdaab6522f72d6dc17e4336b7f'; + context.ref = 'refs/heads/gh-readonly-queue/default-branch/pr-12345-f0d9a4cb862b13cdaab6522f72d6dc17e4336b7f'; await filterPaths({ paths }); diff --git a/test/helpers/get-merge-queue-position.test.ts b/test/helpers/get-merge-queue-position.test.ts index 7c34ddae..26267376 100644 --- a/test/helpers/get-merge-queue-position.test.ts +++ b/test/helpers/get-merge-queue-position.test.ts @@ -15,16 +15,12 @@ import { Mocktokit } from '../types'; import { getMergeQueuePosition } from '../../src/helpers/get-merge-queue-position'; import { octokitGraphql } from '../../src/octokit'; import { MergeQueueEntry } from '@octokit/graphql-schema'; +import { context } from '@actions/github'; jest.mock('@actions/core'); jest.mock('@actions/github', () => ({ - context: { repo: { repo: 'repo', owner: 'owner' }, issue: { number: 123 } }, + context: { repo: { repo: 'repo', owner: 'owner' } }, getOctokit: jest.fn(() => ({ - rest: { - repos: { - listPullRequestsAssociatedWithCommit: jest.fn(({ commit_sha }) => ({ data: [{ number: Number(commit_sha.split('sha')[1]) }] })) - } - }, graphql: jest.fn() })) })); @@ -46,21 +42,23 @@ function mockGraphQLResponse(mergeQueueEntries: RecursivePartial { it('should return 1 for PR 1st in the queue', async () => { + context.ref = 'refs/heads/gh-readonly-queue/default-branch/pr-123-f0d9a4cb862b13cdaab6522f72d6dc17e4336b7f'; mockGraphQLResponse([ { position: 1, pullRequest: { number: 123 } }, { position: 2, pullRequest: { number: 456 } } ]); - const result = await getMergeQueuePosition({ sha: 'sha123' }); + const result = await getMergeQueuePosition({}); expect(result).toBe(1); }); it('should return 3 for PR 3rd in the queue', async () => { + context.ref = 'refs/heads/gh-readonly-queue/default-branch/pr-789-f0d9a4cb862b13cdaab6522f72d6dc17e4336b7f'; mockGraphQLResponse([ { position: 1, pullRequest: { number: 123 } }, { position: 2, pullRequest: { number: 456 } }, { position: 3, pullRequest: { number: 789 } } ]); - const result = await getMergeQueuePosition({ sha: 'sha789' }); + const result = await getMergeQueuePosition({}); expect(result).toBe(3); }); }); diff --git a/test/helpers/initiate-deployment.test.ts b/test/helpers/initiate-deployment.test.ts index 05336363..f5f8c8d3 100644 --- a/test/helpers/initiate-deployment.test.ts +++ b/test/helpers/initiate-deployment.test.ts @@ -125,11 +125,11 @@ describe('initiateDeployment', () => { commit: { sha: 'normal sha 1' } }, { - name: 'gh-readonly-queue/merge-queue/pr-123-79a5ad2b1a46f6b5d77e02573937667979635f27', + name: 'gh-readonly-queue/default-branch/pr-123-79a5ad2b1a46f6b5d77e02573937667979635f27', commit: { sha: 'merge queue sha 1' } }, { - name: 'gh-readonly-queue/merge-queue/pr-456-79a5ad2b1a46f6b5d77e02573937667979635f27', + name: 'gh-readonly-queue/default-branch/pr-456-79a5ad2b1a46f6b5d77e02573937667979635f27', commit: { sha: 'merge queue sha 2' } } ] diff --git a/test/helpers/notify-pipeline-complete.test.ts b/test/helpers/notify-pipeline-complete.test.ts index a9ab5b6b..56f18842 100644 --- a/test/helpers/notify-pipeline-complete.test.ts +++ b/test/helpers/notify-pipeline-complete.test.ts @@ -114,11 +114,11 @@ describe('notify-pipeline-complete', () => { commit: { sha: 'normal sha 1' } }, { - name: 'gh-readonly-queue/merge-queue/pr-123-79a5ad2b1a46f6b5d77e02573937667979635f27', + name: 'gh-readonly-queue/default-branch/pr-123-79a5ad2b1a46f6b5d77e02573937667979635f27', commit: { sha: 'merge queue sha 1' } }, { - name: 'gh-readonly-queue/merge-queue/pr-456-79a5ad2b1a46f6b5d77e02573937667979635f27', + name: 'gh-readonly-queue/default-branch/pr-456-79a5ad2b1a46f6b5d77e02573937667979635f27', commit: { sha: 'merge queue sha 2' } } ]