diff --git a/dist/180.index.js b/dist/180.index.js index 21f8c84e3..48074502c 100644 --- a/dist/180.index.js +++ b/dist/180.index.js @@ -68,9 +68,6 @@ const setMergeSafetyStatus = (pullRequest, inputs) => __awaiter(void 0, void 0, const message = yield getMergeSafetyMessage(pullRequest, inputs); const isSafeToMerge = message === safeMessage; yield (0,_set_commit_status__WEBPACK_IMPORTED_MODULE_5__.setCommitStatus)(Object.assign({ sha: pullRequest.head.sha, state: isSafeToMerge ? 'success' : 'failure', context: 'Merge Safety', description: message }, _actions_github__WEBPACK_IMPORTED_MODULE_0__.context.repo)); - if (!isSafeToMerge) { - _actions_core__WEBPACK_IMPORTED_MODULE_6__.setFailed(message); - } }); const handlePushWorkflow = (inputs) => __awaiter(void 0, void 0, void 0, function* () { const pullRequests = yield (0,_utils_paginate_open_pull_requests__WEBPACK_IMPORTED_MODULE_3__/* .paginateAllOpenPullRequests */ .P)(); @@ -88,7 +85,7 @@ const getMergeSafetyMessage = (pullRequest, { paths, override_filter_paths, over ? fileNamesWhichBranchIsBehindOn.filter(changedFile => override_filter_paths.split(/[\n,]/).includes(changedFile)) : []; if (globalFilesOutdatedOnBranch.length) { - _actions_core__WEBPACK_IMPORTED_MODULE_6__.error(buildErrorMessage(globalFilesOutdatedOnBranch, 'global files')); + _actions_core__WEBPACK_IMPORTED_MODULE_6__.error(buildErrorMessage(globalFilesOutdatedOnBranch, 'global files', `${username}:${ref}`)); return `This branch has one or more outdated global files. Please update with ${default_branch}.`; } const { data: { files: changedFiles } } = yield _octokit__WEBPACK_IMPORTED_MODULE_1__/* .octokit.repos.compareCommitsWithBasehead */ .K.repos.compareCommitsWithBasehead(Object.assign(Object.assign({}, _actions_github__WEBPACK_IMPORTED_MODULE_0__.context.repo), { basehead: `${baseOwner}:${default_branch}...${username}:${ref}` })); @@ -96,14 +93,14 @@ const getMergeSafetyMessage = (pullRequest, { paths, override_filter_paths, over const allProjectDirectories = paths === null || paths === void 0 ? void 0 : paths.split(/[\n,]/); const changedProjectsOutdatedOnBranch = allProjectDirectories === null || allProjectDirectories === void 0 ? void 0 : allProjectDirectories.filter(dir => fileNamesWhichBranchIsBehindOn.some(file => file.includes(dir)) && (changedFileNames === null || changedFileNames === void 0 ? void 0 : changedFileNames.some(file => file.includes(dir)))); if (changedProjectsOutdatedOnBranch === null || changedProjectsOutdatedOnBranch === void 0 ? void 0 : changedProjectsOutdatedOnBranch.length) { - _actions_core__WEBPACK_IMPORTED_MODULE_6__.error(buildErrorMessage(changedProjectsOutdatedOnBranch, 'projects')); + _actions_core__WEBPACK_IMPORTED_MODULE_6__.error(buildErrorMessage(changedProjectsOutdatedOnBranch, 'projects', `${username}:${ref}`)); return `This branch has one or more outdated projects. Please update with ${default_branch}.`; } _actions_core__WEBPACK_IMPORTED_MODULE_6__.info(safeMessage); return safeMessage; }); -const buildErrorMessage = (paths, pathType) => ` -The following ${pathType} are outdated on this branch: +const buildErrorMessage = (paths, pathType, branchName) => ` +The following ${pathType} are outdated on branch ${branchName}: ${paths.map(path => `* ${path}`).join('\n')} `; diff --git a/dist/180.index.js.map b/dist/180.index.js.map index 8da7c8ff2..b23420b66 100644 --- a/dist/180.index.js.map +++ b/dist/180.index.js.map @@ -1 +1 @@ -{"version":3,"file":"180.index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;;;;;;;;;;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAIA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;;AAIA;AAYA;AAMA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAMA;AACA;AAEA;AAIA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAEA;;AAEA;AACA;;;;;;;;;;;;;;;;;;;AC5HA;;;;;;;;;;;AAWA;;;;;;;;;;AAGA;AACA;AACA;AACA;AAEA;AAAA;;AACA;AACA;AACA;AAGA;AAAA;AAEA;AACA;AAGA;AAGA;AAIA;;;;;;;;;;;;;;;;;;ACtCA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAEA;AACA;;;;;;;;;;;AClBA;;;;;;;;;;;AAWA;AAEA;AAoCA;;;;;;;;;;;;;;ACjDA;;;;;;;;;;;AAWA;;;;;;;;;;AAGA;AACA;AAEA;AACA;AAQA;AACA;AACA;AACA;AACA","sources":["webpack://github-helpers/./src/helpers/check-merge-safety.ts","webpack://github-helpers/./src/helpers/set-commit-status.ts","webpack://github-helpers/./src/octokit.ts","webpack://github-helpers/./src/types/generated.ts","webpack://github-helpers/./src/utils/paginate-open-pull-requests.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 { octokit } from '../octokit';\nimport micromatch from 'micromatch';\nimport { PullRequest } from '../types/github';\nimport { paginateAllOpenPullRequests } from '../utils/paginate-open-pull-requests';\nimport { map } from 'bluebird';\nimport { setCommitStatus } from './set-commit-status';\nimport * as core from '@actions/core';\n\nexport class CheckMergeSafety extends HelperInputs {\n paths?: string;\n override_filter_paths?: string;\n override_filter_globs?: string;\n}\n\nexport const checkMergeSafety = async (inputs: CheckMergeSafety) => {\n const isPrWorkflow = Boolean(context.issue.number);\n if (!isPrWorkflow) {\n return handlePushWorkflow(inputs);\n }\n const { data: pullRequest } = await octokit.pulls.get({ pull_number: context.issue.number, ...context.repo });\n\n return setMergeSafetyStatus(pullRequest, inputs);\n};\n\nexport const safeMessage = 'This branch is safe to merge!';\n\nconst setMergeSafetyStatus = async (pullRequest: PullRequest, inputs: CheckMergeSafety) => {\n const message = await getMergeSafetyMessage(pullRequest, inputs);\n const isSafeToMerge = message === safeMessage;\n await setCommitStatus({\n sha: pullRequest.head.sha,\n state: isSafeToMerge ? 'success' : 'failure',\n context: 'Merge Safety',\n description: message,\n ...context.repo\n });\n if (!isSafeToMerge) {\n core.setFailed(message);\n }\n};\n\nconst handlePushWorkflow = async (inputs: CheckMergeSafety) => {\n const pullRequests = await paginateAllOpenPullRequests();\n const filteredPullRequests = pullRequests.filter(({ base, draft }) => !draft && base.ref === base.repo.default_branch);\n return map(filteredPullRequests, pullRequest => setMergeSafetyStatus(pullRequest as PullRequest, inputs));\n};\n\nconst getMergeSafetyMessage = async (\n pullRequest: PullRequest,\n { paths, override_filter_paths, override_filter_globs }: CheckMergeSafety\n) => {\n const {\n base: {\n repo: {\n default_branch,\n owner: { login: baseOwner }\n }\n },\n head: {\n ref,\n user: { login: username }\n }\n } = pullRequest;\n const {\n data: { files: filesWhichBranchIsBehindOn }\n } = await octokit.repos.compareCommitsWithBasehead({\n ...context.repo,\n basehead: `${username}:${ref}...${baseOwner}:${default_branch}`\n });\n const fileNamesWhichBranchIsBehindOn = filesWhichBranchIsBehindOn?.map(file => file.filename) ?? [];\n\n const globalFilesOutdatedOnBranch = override_filter_globs\n ? micromatch(fileNamesWhichBranchIsBehindOn, override_filter_globs.split('\\n'))\n : override_filter_paths\n ? fileNamesWhichBranchIsBehindOn.filter(changedFile => override_filter_paths.split(/[\\n,]/).includes(changedFile))\n : [];\n\n if (globalFilesOutdatedOnBranch.length) {\n core.error(buildErrorMessage(globalFilesOutdatedOnBranch, 'global files'));\n return `This branch has one or more outdated global files. Please update with ${default_branch}.`;\n }\n\n const {\n data: { files: changedFiles }\n } = await octokit.repos.compareCommitsWithBasehead({\n ...context.repo,\n basehead: `${baseOwner}:${default_branch}...${username}:${ref}`\n });\n const changedFileNames = changedFiles?.map(file => file.filename);\n const allProjectDirectories = paths?.split(/[\\n,]/);\n\n const changedProjectsOutdatedOnBranch = allProjectDirectories?.filter(\n dir => fileNamesWhichBranchIsBehindOn.some(file => file.includes(dir)) && changedFileNames?.some(file => file.includes(dir))\n );\n\n if (changedProjectsOutdatedOnBranch?.length) {\n core.error(buildErrorMessage(changedProjectsOutdatedOnBranch, 'projects'));\n return `This branch has one or more outdated projects. Please update with ${default_branch}.`;\n }\n\n core.info(safeMessage);\n return safeMessage;\n};\n\nconst buildErrorMessage = (paths: string[], pathType: 'projects' | 'global files') =>\n `\nThe following ${pathType} are outdated on this branch:\n\n${paths.map(path => `* ${path}`).join('\\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 { PipelineState } from '../types/github';\nimport { HelperInputs } from '../types/generated';\nimport { context as githubContext } from '@actions/github';\nimport { map } from 'bluebird';\nimport { octokit } from '../octokit';\n\nexport class SetCommitStatus extends HelperInputs {\n sha = '';\n context = '';\n state = '';\n description?: string;\n target_url?: string;\n}\n\nexport const setCommitStatus = async ({ sha, context, state, description, target_url }: SetCommitStatus) => {\n await map(context.split('\\n').filter(Boolean), context =>\n octokit.repos.createCommitStatus({\n sha,\n context,\n state: state as PipelineState,\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 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 extensions?: string;\n override_filter_paths?: string;\n batches?: string;\n pattern?: string;\n teams?: string;\n login?: string;\n paths_no_filter?: string;\n slack_webhook_url?: string;\n number_of_assignees?: 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}\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 { PullRequestList } from '../types/github';\nimport { octokit } from '../octokit';\nimport { context } from '@actions/github';\n\nexport const paginateAllOpenPullRequests = async (page = 1): Promise => {\n const response = await octokit.pulls.list({\n state: 'open',\n sort: 'updated',\n direction: 'desc',\n per_page: 100,\n page,\n ...context.repo\n });\n if (!response.data.length) {\n return [];\n }\n return response.data.concat(await paginateAllOpenPullRequests(page + 1));\n};\n"],"names":[],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"180.index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA;;;;;;;;;;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAIA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAOA;AAEA;AACA;AACA;AACA;AACA;AAEA;;AAIA;AAYA;AAMA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAMA;AACA;AAEA;AAIA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAEA;;AAEA;AACA;;;;;;;;;;;;;;;;;;;ACzHA;;;;;;;;;;;AAWA;;;;;;;;;;AAGA;AACA;AACA;AACA;AAEA;AAAA;;AACA;AACA;AACA;AAGA;AAAA;AAEA;AACA;AAGA;AAGA;AAIA;;;;;;;;;;;;;;;;;;ACtCA;;;;;;;;;;;AAWA;AAEA;AACA;AACA;AAEA;AACA;;;;;;;;;;;AClBA;;;;;;;;;;;AAWA;AAEA;AAoCA;;;;;;;;;;;;;;ACjDA;;;;;;;;;;;AAWA;;;;;;;;;;AAGA;AACA;AAEA;AACA;AAQA;AACA;AACA;AACA;AACA","sources":["webpack://github-helpers/./src/helpers/check-merge-safety.ts","webpack://github-helpers/./src/helpers/set-commit-status.ts","webpack://github-helpers/./src/octokit.ts","webpack://github-helpers/./src/types/generated.ts","webpack://github-helpers/./src/utils/paginate-open-pull-requests.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 { octokit } from '../octokit';\nimport micromatch from 'micromatch';\nimport { PullRequest } from '../types/github';\nimport { paginateAllOpenPullRequests } from '../utils/paginate-open-pull-requests';\nimport { map } from 'bluebird';\nimport { setCommitStatus } from './set-commit-status';\nimport * as core from '@actions/core';\n\nexport class CheckMergeSafety extends HelperInputs {\n paths?: string;\n override_filter_paths?: string;\n override_filter_globs?: string;\n}\n\nexport const checkMergeSafety = async (inputs: CheckMergeSafety) => {\n const isPrWorkflow = Boolean(context.issue.number);\n if (!isPrWorkflow) {\n return handlePushWorkflow(inputs);\n }\n const { data: pullRequest } = await octokit.pulls.get({ pull_number: context.issue.number, ...context.repo });\n\n return setMergeSafetyStatus(pullRequest, inputs);\n};\n\nexport const safeMessage = 'This branch is safe to merge!';\n\nconst setMergeSafetyStatus = async (pullRequest: PullRequest, inputs: CheckMergeSafety) => {\n const message = await getMergeSafetyMessage(pullRequest, inputs);\n const isSafeToMerge = message === safeMessage;\n await setCommitStatus({\n sha: pullRequest.head.sha,\n state: isSafeToMerge ? 'success' : 'failure',\n context: 'Merge Safety',\n description: message,\n ...context.repo\n });\n};\n\nconst handlePushWorkflow = async (inputs: CheckMergeSafety) => {\n const pullRequests = await paginateAllOpenPullRequests();\n const filteredPullRequests = pullRequests.filter(({ base, draft }) => !draft && base.ref === base.repo.default_branch);\n return map(filteredPullRequests, pullRequest => setMergeSafetyStatus(pullRequest as PullRequest, inputs));\n};\n\nconst getMergeSafetyMessage = async (\n pullRequest: PullRequest,\n { paths, override_filter_paths, override_filter_globs }: CheckMergeSafety\n) => {\n const {\n base: {\n repo: {\n default_branch,\n owner: { login: baseOwner }\n }\n },\n head: {\n ref,\n user: { login: username }\n }\n } = pullRequest;\n const {\n data: { files: filesWhichBranchIsBehindOn }\n } = await octokit.repos.compareCommitsWithBasehead({\n ...context.repo,\n basehead: `${username}:${ref}...${baseOwner}:${default_branch}`\n });\n const fileNamesWhichBranchIsBehindOn = filesWhichBranchIsBehindOn?.map(file => file.filename) ?? [];\n\n const globalFilesOutdatedOnBranch = override_filter_globs\n ? micromatch(fileNamesWhichBranchIsBehindOn, override_filter_globs.split('\\n'))\n : override_filter_paths\n ? fileNamesWhichBranchIsBehindOn.filter(changedFile => override_filter_paths.split(/[\\n,]/).includes(changedFile))\n : [];\n\n if (globalFilesOutdatedOnBranch.length) {\n core.error(buildErrorMessage(globalFilesOutdatedOnBranch, 'global files', `${username}:${ref}`));\n return `This branch has one or more outdated global files. Please update with ${default_branch}.`;\n }\n\n const {\n data: { files: changedFiles }\n } = await octokit.repos.compareCommitsWithBasehead({\n ...context.repo,\n basehead: `${baseOwner}:${default_branch}...${username}:${ref}`\n });\n const changedFileNames = changedFiles?.map(file => file.filename);\n const allProjectDirectories = paths?.split(/[\\n,]/);\n\n const changedProjectsOutdatedOnBranch = allProjectDirectories?.filter(\n dir => fileNamesWhichBranchIsBehindOn.some(file => file.includes(dir)) && changedFileNames?.some(file => file.includes(dir))\n );\n\n if (changedProjectsOutdatedOnBranch?.length) {\n core.error(buildErrorMessage(changedProjectsOutdatedOnBranch, 'projects', `${username}:${ref}`));\n return `This branch has one or more outdated projects. Please update with ${default_branch}.`;\n }\n\n core.info(safeMessage);\n return safeMessage;\n};\n\nconst buildErrorMessage = (paths: string[], pathType: 'projects' | 'global files', branchName: string) =>\n `\nThe following ${pathType} are outdated on branch ${branchName}:\n\n${paths.map(path => `* ${path}`).join('\\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 { PipelineState } from '../types/github';\nimport { HelperInputs } from '../types/generated';\nimport { context as githubContext } from '@actions/github';\nimport { map } from 'bluebird';\nimport { octokit } from '../octokit';\n\nexport class SetCommitStatus extends HelperInputs {\n sha = '';\n context = '';\n state = '';\n description?: string;\n target_url?: string;\n}\n\nexport const setCommitStatus = async ({ sha, context, state, description, target_url }: SetCommitStatus) => {\n await map(context.split('\\n').filter(Boolean), context =>\n octokit.repos.createCommitStatus({\n sha,\n context,\n state: state as PipelineState,\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 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 extensions?: string;\n override_filter_paths?: string;\n batches?: string;\n pattern?: string;\n teams?: string;\n login?: string;\n paths_no_filter?: string;\n slack_webhook_url?: string;\n number_of_assignees?: 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}\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 { PullRequestList } from '../types/github';\nimport { octokit } from '../octokit';\nimport { context } from '@actions/github';\n\nexport const paginateAllOpenPullRequests = async (page = 1): Promise => {\n const response = await octokit.pulls.list({\n state: 'open',\n sort: 'updated',\n direction: 'desc',\n per_page: 100,\n page,\n ...context.repo\n });\n if (!response.data.length) {\n return [];\n }\n return response.data.concat(await paginateAllOpenPullRequests(page + 1));\n};\n"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/src/helpers/check-merge-safety.ts b/src/helpers/check-merge-safety.ts index 2b81bde4b..a7e89e9f4 100644 --- a/src/helpers/check-merge-safety.ts +++ b/src/helpers/check-merge-safety.ts @@ -49,9 +49,6 @@ const setMergeSafetyStatus = async (pullRequest: PullRequest, inputs: CheckMerge description: message, ...context.repo }); - if (!isSafeToMerge) { - core.setFailed(message); - } }; const handlePushWorkflow = async (inputs: CheckMergeSafety) => { @@ -91,7 +88,7 @@ const getMergeSafetyMessage = async ( : []; if (globalFilesOutdatedOnBranch.length) { - core.error(buildErrorMessage(globalFilesOutdatedOnBranch, 'global files')); + core.error(buildErrorMessage(globalFilesOutdatedOnBranch, 'global files', `${username}:${ref}`)); return `This branch has one or more outdated global files. Please update with ${default_branch}.`; } @@ -109,7 +106,7 @@ const getMergeSafetyMessage = async ( ); if (changedProjectsOutdatedOnBranch?.length) { - core.error(buildErrorMessage(changedProjectsOutdatedOnBranch, 'projects')); + core.error(buildErrorMessage(changedProjectsOutdatedOnBranch, 'projects', `${username}:${ref}`)); return `This branch has one or more outdated projects. Please update with ${default_branch}.`; } @@ -117,9 +114,9 @@ const getMergeSafetyMessage = async ( return safeMessage; }; -const buildErrorMessage = (paths: string[], pathType: 'projects' | 'global files') => +const buildErrorMessage = (paths: string[], pathType: 'projects' | 'global files', branchName: string) => ` -The following ${pathType} are outdated on this branch: +The following ${pathType} are outdated on branch ${branchName}: ${paths.map(path => `* ${path}`).join('\n')} `; diff --git a/test/helpers/check-merge-safety.test.ts b/test/helpers/check-merge-safety.test.ts index 3dd83cb5c..258c13384 100644 --- a/test/helpers/check-merge-safety.test.ts +++ b/test/helpers/check-merge-safety.test.ts @@ -17,7 +17,6 @@ import { checkMergeSafety, safeMessage } from '../../src/helpers/check-merge-saf import { octokit } from '../../src/octokit'; import { setCommitStatus } from '../../src/helpers/set-commit-status'; import { paginateAllOpenPullRequests } from '../../src/utils/paginate-open-pull-requests'; -import * as core from '@actions/core'; const branchName = 'some-branch-name'; const username = 'username'; @@ -77,7 +76,6 @@ describe('checkMergeSafety', () => { repo: 'repo', owner: 'owner' }); - expect(core.setFailed).toHaveBeenCalled(); }); it('should allow merge when branch is only out of date for an unchanged project', async () => { @@ -96,7 +94,6 @@ describe('checkMergeSafety', () => { repo: 'repo', owner: 'owner' }); - expect(core.setFailed).not.toHaveBeenCalled(); }); it('should allow merge when branch is fully up to date', async () => { @@ -116,7 +113,6 @@ describe('checkMergeSafety', () => { repo: 'repo', owner: 'owner' }); - expect(core.setFailed).not.toHaveBeenCalled(); }); it('should prevent merge when branch is out of date on override filter paths, even when changed project paths are up to date', async () => { @@ -136,7 +132,6 @@ describe('checkMergeSafety', () => { repo: 'repo', owner: 'owner' }); - expect(core.setFailed).toHaveBeenCalled(); }); it('should prevent merge when branch is out of date on override glob paths, even when changed project paths are up to date', async () => { @@ -156,7 +151,6 @@ describe('checkMergeSafety', () => { repo: 'repo', owner: 'owner' }); - expect(core.setFailed).toHaveBeenCalled(); }); it('should prevent merge when branch is out of date on override glob paths using negation glob pattern', async () => { @@ -176,7 +170,6 @@ describe('checkMergeSafety', () => { repo: 'repo', owner: 'owner' }); - expect(core.setFailed).toHaveBeenCalled(); }); it('should set merge safety commit status on all open prs', async () => {