diff --git a/scripts/workflow/test-route/identify.js b/scripts/workflow/test-route/identify.js index 548155add3..02073600c8 100644 --- a/scripts/workflow/test-route/identify.js +++ b/scripts/workflow/test-route/identify.js @@ -1,11 +1,11 @@ -const noFound = 'Auto: Route No Found' +const noFound = 'Auto: Route No Found'; module.exports = ({github, context, core}, body, number) => { - core.debug(`body: ${body}`) - const m = body.match(/```routes\r\n((.|\r\n)*)```/) - core.debug(`match: ${m}`) - let res = null + core.debug(`body: ${body}`); + const m = body.match(/```routes\r\n((.|\r\n)*)```/); + core.debug(`match: ${m}`); + let res = null; const removeLabel = () => { github.issues.removeLabel({ @@ -13,39 +13,39 @@ module.exports = ({github, context, core}, body, number) => { owner: context.repo.owner, repo: context.repo.repo, name: noFound - }).catch(() => {}) - } + }).catch(() => {}); + }; if (m && m[1]) { - res = m[1].trim().split("\r\n") - core.info(`routes detected: ${res}`) + res = m[1].trim().split("\r\n"); + core.info(`routes detected: ${res}`); if (res.length > 0 && res[0] === "NOROUTE") { - core.info("PR stated no route, passing") - removeLabel() + core.info("PR stated no route, passing"); + removeLabel(); github.issues.addLabels({ issue_number: number, owner: context.repo.owner, repo: context.repo.repo, labels: ['Auto: No Route Needed'] - }) + }); - return + return; } else if (res.length > 0) { - core.exportVariable('TEST_CONTINUE', true) - removeLabel() - return res + core.exportVariable('TEST_CONTINUE', true); + removeLabel(); + return res; } } - core.info("seems no route found, failing") + core.info("seems no route found, failing"); github.issues.addLabels({ issue_number: number, owner: context.repo.owner, repo: context.repo.repo, labels: [noFound] - }) + }); - throw "Please follow the PR rules: failed to detect route" -} \ No newline at end of file + throw "Please follow the PR rules: failed to detect route"; +}; \ No newline at end of file diff --git a/scripts/workflow/test-route/test.js b/scripts/workflow/test-route/test.js index c32d8e306c..d5e6f19259 100644 --- a/scripts/workflow/test-route/test.js +++ b/scripts/workflow/test-route/test.js @@ -1,19 +1,19 @@ module.exports = async ({github, context}, baseUrl, routes, number) => { if (routes[0] === 'NOROUTE') { - return + return; } - const links = routes.map(e => { - const l = e.startsWith('/') ? e : `/${e}` - return `${baseUrl}${l}` - }) + const links = routes.map((e) => { + const l = e.startsWith('/') ? e : `/${e}`; + return `${baseUrl}${l}`; + }); - let com = 'Successfully generated as following:\n\n' + let com = 'Successfully generated as following:\n\n'; for (const lks of links) { - console.log("testing route: ", lks) - const res = await github.request(`GET ${lks}`).catch(err => { - com+= ` + console.log("testing route: ", lks); + const res = await github.request(`GET ${lks}`).catch((err) => { + com += `
${lks} - **Failed** @@ -23,10 +23,10 @@ module.exports = async ({github, context}, baseUrl, routes, number) => { \`\`\`
-` - }) +`; + }); if (res && res.data) { - const { data } = res + const { data } = res; com += `
${lks} - Success @@ -36,7 +36,7 @@ module.exports = async ({github, context}, baseUrl, routes, number) => { \`\`\`
-` +`; } } github.issues.addLabels({ @@ -44,11 +44,11 @@ module.exports = async ({github, context}, baseUrl, routes, number) => { owner: context.repo.owner, repo: context.repo.repo, labels: ['Auto: Route Test Complete'] - }) + }); github.issues.createComment({ issue_number: number, owner: context.repo.owner, repo: context.repo.repo, body: com }); -} \ No newline at end of file +}; \ No newline at end of file