mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 14:40:23 +08:00
chore: reopen and test pr/issue after edited
This commit is contained in:
6
.github/workflows/comment-on-issue.yml
vendored
6
.github/workflows/comment-on-issue.yml
vendored
@@ -2,7 +2,7 @@ name: Comment on Issue
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
issues:
|
issues:
|
||||||
types: [opened]
|
types: [opened, edited, reopened]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
testRoute:
|
testRoute:
|
||||||
@@ -11,11 +11,11 @@ jobs:
|
|||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v3 # just need its cache
|
- uses: actions/setup-node@v3 # just need its cache
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 18
|
||||||
cache: 'yarn'
|
cache: 'yarn'
|
||||||
- name: Install dependencies (yarn) # needed since we need to parse markdown, so we also use got instead
|
- name: Install dependencies (yarn) # needed since we need to parse markdown, so we also use got instead
|
||||||
run: yarn
|
run: yarn
|
||||||
- name: Generate feedback
|
- name: Generate feedback
|
||||||
uses: actions/github-script@v6
|
uses: actions/github-script@v6
|
||||||
|
|||||||
1
.github/workflows/docker-test.yml
vendored
1
.github/workflows/docker-test.yml
vendored
@@ -15,6 +15,7 @@ on:
|
|||||||
- 'Dockerfile'
|
- 'Dockerfile'
|
||||||
- 'package.json'
|
- 'package.json'
|
||||||
- 'yarn.lock'
|
- 'yarn.lock'
|
||||||
|
types: [opened, reopened, synchronize, edited]
|
||||||
# Please, always create a pull request instead of push to master.
|
# Please, always create a pull request instead of push to master.
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
|
|||||||
2
.github/workflows/pr-deploy-route-test.yml
vendored
2
.github/workflows/pr-deploy-route-test.yml
vendored
@@ -1,7 +1,7 @@
|
|||||||
name: PR - route test
|
name: PR - route test
|
||||||
on:
|
on:
|
||||||
workflow_run:
|
workflow_run:
|
||||||
workflows: [ PR - Docker build test ] # open, reopen, synchronized included
|
workflows: [ PR - Docker build test ] # open, reopen, synchronized, edited included
|
||||||
types: [ completed ]
|
types: [ completed ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ async function parseBodyRoutes(body, core) {
|
|||||||
return dedup;
|
return dedup;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw 'unable to parse the issue body: route does not exist';
|
throw Error('unable to parse the issue body: route does not exist');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getMaintainersByRoutes(routes, core) {
|
async function getMaintainersByRoutes(routes, core) {
|
||||||
@@ -64,6 +64,17 @@ module.exports = async ({ github, context, core }) => {
|
|||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (context.payload.issue.state === 'closed') {
|
||||||
|
await github.rest.issues
|
||||||
|
.update({
|
||||||
|
...issue_facts,
|
||||||
|
state: 'open',
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
core.warning(e);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const routes = await parseBodyRoutes(body, core).catch((e) => {
|
const routes = await parseBodyRoutes(body, core).catch((e) => {
|
||||||
core.warning(e);
|
core.warning(e);
|
||||||
});
|
});
|
||||||
@@ -155,15 +166,15 @@ module.exports = async ({ github, context, core }) => {
|
|||||||
|
|
||||||
> To maintainers: if you are not willing to be disturbed, list your username in \`scripts/workflow/test-issue/call-maintainer.js\`. In this way, your username will be wrapped in an inline code block when tagged so you will not be notified.
|
> To maintainers: if you are not willing to be disturbed, list your username in \`scripts/workflow/test-issue/call-maintainer.js\`. In this way, your username will be wrapped in an inline code block when tagged so you will not be notified.
|
||||||
|
|
||||||
如果有任何路由无法匹配,issue 将会被自动关闭。如果 issue 和路由无关,请使用 \`NOROUTE\` 关键词,或者留下评论。我们会重新审核。
|
如果所有路由都无法匹配,issue 将会被自动关闭。如果 issue 和路由无关,请使用 \`NOROUTE\` 关键词,或者留下评论。我们会重新审核。
|
||||||
If there is any route not found, the issue will be closed automatically. Please use \`NOROUTE\` for a route-irrelevant issue or leave a comment if it is a mistake.
|
If all routes can not be found, the issue will be closed automatically. Please use \`NOROUTE\` for a route-irrelevant issue or leave a comment if it is a mistake.
|
||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
core.warning(e);
|
core.warning(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (failedCount > 0) {
|
if (failedCount && emptyCount === 0 && successCount === 0) {
|
||||||
await github.rest.issues
|
await github.rest.issues
|
||||||
.update({
|
.update({
|
||||||
...issue_facts,
|
...issue_facts,
|
||||||
|
|||||||
@@ -8,26 +8,44 @@ module.exports = async ({ github, context, core }, body, number, sender) => {
|
|||||||
core.debug(`match: ${m}`);
|
core.debug(`match: ${m}`);
|
||||||
let res = null;
|
let res = null;
|
||||||
|
|
||||||
|
const issue_facts = {
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: number,
|
||||||
|
};
|
||||||
|
const pr_facts = {
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
pull_number: number,
|
||||||
|
};
|
||||||
|
|
||||||
const removeLabel = () =>
|
const removeLabel = () =>
|
||||||
github.rest.issues
|
github.rest.issues
|
||||||
.removeLabel({
|
.removeLabel({
|
||||||
issue_number: number,
|
...issue_facts,
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
name: noFound,
|
name: noFound,
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
core.warning(e);
|
core.warning(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (context.payload.pull_request.state === 'closed') {
|
||||||
|
await github.rest.pulls
|
||||||
|
.update({
|
||||||
|
...pr_facts,
|
||||||
|
state: 'open',
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
core.warning(e);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (whiteListedUser.includes(sender)) {
|
if (whiteListedUser.includes(sender)) {
|
||||||
core.info('PR created by a whitelisted user, passing');
|
core.info('PR created by a whitelisted user, passing');
|
||||||
await removeLabel();
|
await removeLabel();
|
||||||
await github.rest.issues
|
await github.rest.issues
|
||||||
.addLabels({
|
.addLabels({
|
||||||
issue_number: number,
|
...issue_facts,
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
labels: ['Auto: whitelisted'],
|
labels: ['Auto: whitelisted'],
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
@@ -47,9 +65,7 @@ module.exports = async ({ github, context, core }, body, number, sender) => {
|
|||||||
await removeLabel();
|
await removeLabel();
|
||||||
await github.rest.issues
|
await github.rest.issues
|
||||||
.addLabels({
|
.addLabels({
|
||||||
issue_number: number,
|
...issue_facts,
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
labels: ['Auto: No Route Needed'],
|
labels: ['Auto: No Route Needed'],
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
@@ -68,9 +84,7 @@ module.exports = async ({ github, context, core }, body, number, sender) => {
|
|||||||
|
|
||||||
await github.rest.issues
|
await github.rest.issues
|
||||||
.addLabels({
|
.addLabels({
|
||||||
issue_number: number,
|
...issue_facts,
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
labels: [noFound],
|
labels: [noFound],
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
@@ -78,9 +92,7 @@ module.exports = async ({ github, context, core }, body, number, sender) => {
|
|||||||
});
|
});
|
||||||
await github.rest.issues
|
await github.rest.issues
|
||||||
.createComment({
|
.createComment({
|
||||||
issue_number: number,
|
...issue_facts,
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
body: `自动检测失败, 请确认PR正文部分符合格式规范并重新开启, 详情请检查日志
|
body: `自动检测失败, 请确认PR正文部分符合格式规范并重新开启, 详情请检查日志
|
||||||
Auto Route test failed, please check your PR body format and reopen pull request. Check logs for more details`,
|
Auto Route test failed, please check your PR body format and reopen pull request. Check logs for more details`,
|
||||||
})
|
})
|
||||||
@@ -89,14 +101,12 @@ Auto Route test failed, please check your PR body format and reopen pull request
|
|||||||
});
|
});
|
||||||
await github.rest.pulls
|
await github.rest.pulls
|
||||||
.update({
|
.update({
|
||||||
owner: context.repo.owner,
|
...pr_facts,
|
||||||
repo: context.repo.repo,
|
|
||||||
pull_number: number,
|
|
||||||
state: 'closed',
|
state: 'closed',
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
core.warning(e);
|
core.warning(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
throw 'Please follow the PR rules: failed to detect route';
|
throw Error('Please follow the PR rules: failed to detect route');
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ describe('router', () => {
|
|||||||
},
|
},
|
||||||
message: 'request returned 1 route',
|
message: 'request returned 1 route',
|
||||||
});
|
});
|
||||||
}, 30000);
|
}, 40000);
|
||||||
it(`/api/routes`, async () => {
|
it(`/api/routes`, async () => {
|
||||||
const response = await request.get('/api/routes');
|
const response = await request.get('/api/routes');
|
||||||
expect(response.status).toBe(200);
|
expect(response.status).toBe(200);
|
||||||
|
|||||||
Reference in New Issue
Block a user