chore(*): migrate to GHA-based PR route test (#9683)

Signed-off-by: Rongrong <i@rong.moe>
This commit is contained in:
Rongrong
2022-05-03 19:24:27 +08:00
committed by GitHub
parent 569b7d8db1
commit 7b6589cafa
4 changed files with 89 additions and 36 deletions
+4 -4
View File
@@ -1,8 +1,8 @@
const noFound = 'Auto: Route No Found';
const whiteListedUser = ['dependabot[bot]'];
module.exports = async ({ github, context, core }, body, number) => {
core.debug(`sender: ${context.payload.sender.login}`);
module.exports = async ({ github, context, core }, body, number, sender) => {
core.debug(`sender: ${sender}`);
core.debug(`body: ${body}`);
const m = body.match(/```routes\r\n((.|\r\n)*)```/);
core.debug(`match: ${m}`);
@@ -20,7 +20,7 @@ module.exports = async ({ github, context, core }, body, number) => {
core.warning(e);
});
if (whiteListedUser.includes(context.payload.sender.login)) {
if (whiteListedUser.includes(sender)) {
core.info('PR created by a whitelisted user, passing');
await removeLabel();
await github.rest.issues
@@ -35,7 +35,7 @@ module.exports = async ({ github, context, core }, body, number) => {
});
return;
} else {
core.debug('PR created by ' + context.payload.sender.login);
core.debug('PR created by ' + sender);
}
if (m && m[1]) {
+9 -10
View File
@@ -1,6 +1,6 @@
/* eslint-disable */
module.exports = async ({ github, context, core }, baseUrl, routes, number) => {
module.exports = async ({ github, context, core, got }, baseUrl, routes, number) => {
if (routes[0] === 'NOROUTE') {
return;
}
@@ -15,27 +15,26 @@ module.exports = async ({ github, context, core }, baseUrl, routes, number) => {
for (const lks of links) {
core.info(`testing route: ${lks}`);
// Intended, one at a time
const res = await github.request(`GET ${lks}`).catch((err) => {
const res = await got(lks).catch((err) => {
com += `
<details>
<summary><a href="${lks}">${lks}</a> - **Failed**</summary>
<summary><a href="${lks}">${lks}</a> - <b>Failed</b></summary>
\`\`\`
${err}
${err}
\`\`\`
</details>
`;
});
if (res && res.data) {
const { data } = res;
if (res && res.body) {
const { body } = res;
com += `
<details>
<summary><a href="${lks}">${lks}</a> - Success</summary>
<summary><a href="${lks}">${lks}</a> - Success</summary>
\`\`\`
${data.split('\n').slice(0, 30).join('\n')}
\`\`\`rss
${body.replace(/\s+(\n|$)/g, '\n')}
\`\`\`
</details>