Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically close bug report issues that don't have valid log files #1994

Open
wants to merge 32 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d7c8be6
ci: start work on autocloser
AstreaTSS Aug 12, 2023
6c33ed6
idk
AstreaTSS Aug 12, 2023
366708d
\
AstreaTSS Aug 12, 2023
96d2a5e
Replace github insert with loose regex
AstreaTSS Aug 12, 2023
690f31c
Update moderate-issue.yml
AstreaTSS Aug 12, 2023
e05ffb1
Update moderate-issue.yml
AstreaTSS Aug 12, 2023
722ab74
screw it, js
AstreaTSS Aug 12, 2023
db18a92
Update moderate-issue.yml
AstreaTSS Aug 12, 2023
50903e8
Update moderate-issue.yml
AstreaTSS Aug 12, 2023
e053543
Update moderate-issue.yml
AstreaTSS Aug 12, 2023
483702e
Update moderate-issue.yml
AstreaTSS Aug 12, 2023
062ea6d
Update moderate-issue.yml
AstreaTSS Aug 12, 2023
f4460a2
Update moderate-issue.yml
AstreaTSS Aug 12, 2023
bd66ec2
Update moderate-issue.yml
AstreaTSS Aug 12, 2023
97c1bdb
Update moderate-issue.yml
AstreaTSS Aug 12, 2023
82005f7
Update moderate-issue.yml
AstreaTSS Aug 12, 2023
1addd99
Update moderate-issue.yml
AstreaTSS Aug 12, 2023
15a67d6
Update moderate-issue.yml
AstreaTSS Aug 12, 2023
b73ada2
Update moderate-issue.yml
AstreaTSS Aug 12, 2023
53402a3
Update moderate-issue.yml
AstreaTSS Aug 12, 2023
367f31a
Update moderate-issue.yml
AstreaTSS Aug 12, 2023
ecd0a23
Update moderate-issue.yml
AstreaTSS Aug 12, 2023
3b5e706
Update moderate-issue.yml
AstreaTSS Aug 12, 2023
f332488
Update moderate-issue.yml
AstreaTSS Aug 12, 2023
067ed8e
Update moderate-issue.yml
AstreaTSS Aug 12, 2023
333f44e
Update moderate-issue.yml
AstreaTSS Aug 12, 2023
db1c32f
Update moderate-issue.yml
AstreaTSS Aug 12, 2023
6b415b8
Rename moderate-issue.yml to verify-issue.yml
AstreaTSS Aug 12, 2023
19e223c
Update verify-issue.yml
AstreaTSS Aug 12, 2023
2e58c85
Update verify-issue.yml
AstreaTSS Aug 12, 2023
01125e1
Update verify-issue.yml
AstreaTSS Aug 13, 2023
9d5496e
Add notes about the need to use attachments for logs
AstreaTSS Aug 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ body:
label: Log File
description: >-
Attach the most recent log file from your client (`logs/latest.log`). This file should always be present.

**Important:** Upload the file to this issue as an attachment by first selecting the text box below and then dragging your file onto it.
GitHub will upload the file as an attachment and generate a link to it. This issue will be automatically closed if you omit a log
file or copy-paste its content here.
placeholder: >-
Upload the log file here...
validations:
Expand All @@ -58,7 +62,7 @@ body:
attributes:
label: Crash Report
description: >-
Attach the most recent crash report from the `crash-reports` folder. This is different from the log file above, and it contains
Attach the most recent crash report from the `crash-reports` folder in the same manner as before. This is different from the log file above, and it contains
important information about your hardware and software configuration.

**Important:** If your game is not crashing as a result of your problem, then you need to obtain a crash report manually. This can be done
Expand Down
74 changes: 74 additions & 0 deletions .github/workflows/verify-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Verify Issue
on:
issues:
types:
- opened
- edited
- reopened
jobs:
moderate:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
id: verify-issue
with:
result-encoding: string
script: |
const issue_payload = context.payload.issue;
const issue_content = issue_payload.body;
if (issue_payload.pull_request != null || !issue_content.startsWith("### Bug Description")) {
return;
}

const author_name = issue_payload.user ? issue_payload.user.login : context.payload.sender.login;
const LOG_FILE_REGEX = /### Log File[^]+?\[.+\.(txt|log)\]\(https:\/\/github\.com\/\w+\/sodium-fabric\/files\/\d+\/.+\.(txt|log)\)/;
const CRASH_REPORT_REGEX = /### Crash Report[^]+?\[.+\.(txt|log)\]\(https:\/\/github\.com\/\w+\/sodium-fabric\/files\/\d+\/.+\.(txt|log)\)/;

if (issue_payload.state == "open") {
let match = LOG_FILE_REGEX.exec(issue_content);
if (!match || match[0].includes("### Crash Report")) {
await github.rest.issues.update({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
state: "closed",
state_reason: "not_planned",
labels: ["E-invalid"],
})
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `@${author_name}, this issue was automatically closed because it did not follow the issue template. You either did not upload a log file or didn't upload it in the required format. Attach a log file and a crashlog as described in the issue template by dragging and dropping the file and letting GitHub create an attachment. Do not copy-paste the content of the log file into the area. Please edit your issue to add the required data and the issue will be automatically be reopened.`,
});
} else if (!CRASH_REPORT_REGEX.test(issue_content)) {
await github.rest.issues.update({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
state: "closed",
state_reason: "not_planned",
labels: ["E-invalid"],
})
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `@${author_name}, this issue was automatically closed because it did not follow the issue template. You either did not upload a crash log or didn't upload it in the required format. Attach a log file and a crash log as described in the issue template by dragging and dropping the file and letting GitHub create an attachment. Do not copy-paste the content of the log file into the area. Please edit your issue to add the required data and the issue will be automatically be reopened.`,
});
}
} else if (issue_payload.labels.some(label => label.name == "E-invalid") && LOG_FILE_REGEX.test(issue_content) && CRASH_REPORT_REGEX.test(issue_content)) {
await github.rest.issues.update({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
state: "open",
labels: ["S-needs-triage"],
})
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "Reopened because the issue now follows the issue template.",
});
}