-
-
Notifications
You must be signed in to change notification settings - Fork 13
157 lines (143 loc) · 8.08 KB
/
minecraft-crash.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: Check Minecraft crash
on:
issues:
types: [opened]
jobs:
check-minecraft-crash:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 #v3.7.0
with:
node-version: 16
- run: npm install axios
- name: Check Minecraft crash
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
with:
script: |
// Strings which indicate that Minecraft is modded
const moddedStrings = [
'net.fabricmc.loader.launch.knot.KnotClient',
'net.fabricmc.loader.impl.launch.knot.KnotClient', // new class name
'--version fabric-loader-',
'--tweakClass optifine.OptiFineTweaker',
// Minecraft Forge
'--launchTarget forgeclient',
'--launchTarget fmlserver',
'--fml.forgeVersion',
]
const axios = require('axios')
async function httpGet(url) {
const result = await axios.get(url, {
responseType: 'text'
})
const status = result.status
const data = result.data
if (status < 200 || status >= 300) {
throw new Error(`GET request to ${url} failed with ${status} '${result.statusText}': ${data}`)
}
return data
}
const issueNumber = context.issue.number
const owner = context.repo.owner
const repo = context.repo.repo
const issueData = (await github.rest.issues.get({
owner: owner,
repo: repo,
issue_number: issueNumber,
})).data
const issueTitle = issueData.title
const issueBody = issueData.body
// Uses negative lookbehind and lookahead to match start and end of string as well
const minecraftRegex = /(?<![a-z])Minecraft(?![a-z])/i
let isMinecraftIssue = minecraftRegex.test(issueTitle) || minecraftRegex.test(issueBody)
const foundModdedStrings = moddedStrings.filter(s => issueBody.includes(s))
if (foundModdedStrings.length === 0) {
console.log('Did not find modded string in issue body, searching attachments')
// Try searching in attachments
// There is currently no API so try to find URL then get attachment content, see https://github.community/t/get-files-attached-in-issue/117443
const attachmentPattern = new RegExp(`https://github\\.com/${owner}/${repo}/files/\\d+/[a-zA-Z0-9_\\-.]+`, 'g')
const attachmentUrls = Array.from(issueBody.matchAll(attachmentPattern), m => m[0])
console.log('Found attachment URLs', attachmentUrls)
for (const url of attachmentUrls) {
let attachment = undefined
try {
attachment = await httpGet(url)
} catch (e) {
// Only log message because complete error is rather verbose
console.log('Failed getting attachment for ' + url, e.message)
continue
}
if (!isMinecraftIssue) {
isMinecraftIssue = minecraftRegex.test(attachment)
if (isMinecraftIssue) {
console.log('Found Minecraft string in attachment')
}
}
moddedStrings.forEach(s => {
if (attachment.includes(s)) {
foundModdedStrings.push(s)
}
})
}
}
let isCrashFromModdedMinecraft = foundModdedStrings.length > 0
if (isCrashFromModdedMinecraft) {
console.log('Found modded strings', foundModdedStrings)
} else {
console.log('Did not find modded strings')
}
isMinecraftIssue = isMinecraftIssue || isCrashFromModdedMinecraft
console.log('Is Minecraft issue: ' + isMinecraftIssue)
if (isMinecraftIssue) {
let commentBody
if (isCrashFromModdedMinecraft) {
// Don't tell user to report modded crashes on Mojang's bug tracker; they will most likely be considered Invalid
commentBody = (
'Thank you for the report!'
+ '\nIt looks like you are using a modified version of Minecraft. The following was detected in your crash report:'
+ '\n```'
+ '\n' + foundModdedStrings.join('\n')
+ '\n```'
+ '\nPlease try the following:'
+ '\n- Update your graphics drivers, see [this Minecraft Help Center article](https://help.minecraft.net/hc/en-us/articles/4409137348877-Minecraft-Java-Edition-Game-Crashes-and-Performance-Issues-FAQ), section "Update your Video Card Drivers";'
+ '\n often Minecraft crashes are caused by outdated graphics drivers'
+ '\n- Try disabling the mods you have installed one by one until you find the mod causing the crash, then report the crash to the mod author'
+ '\n- If you are using a third-party launcher, try the [official launcher](https://www.minecraft.net/download) instead'
+ '\n\nIf none of the above helped, and you are still experiencing the crash with the official launcher and without any mods installed, please submit this issue over at the [Mojang bug tracker](https://bugs.mojang.com/projects/MC/summary).'
+ ' Please search for existing reports first; in case you do not find any, create a new report and let us know about the issue number here (e.g. `MC-123456`).'
+ '\nThe Mojang team will take the first look. If an OpenJDK bug is identified, the Mojang team will contact us to address the issue.'
)
} else {
commentBody = (
'Thank you for the report!'
+ '\nIt looks like you are reporting that the game Minecraft crashed for you. Please try the following:'
+ '\n- Update your graphics drivers, see [this Minecraft Help Center article](https://help.minecraft.net/hc/en-us/articles/4409137348877-Minecraft-Java-Edition-Game-Crashes-and-Performance-Issues-FAQ), section "Update your Video Card Drivers";'
+ '\n often Minecraft crashes are caused by outdated graphics drivers'
+ '\n- In case you are using mods, try disabling them one by one until you find the mod causing the crash, then report the crash to the mod author'
+ '\n- If you are using a third-party launcher, try the [official launcher](https://www.minecraft.net/download) instead'
+ '\n\nIf none of the above helped, and you are still experiencing the crash with the official launcher and without any mods installed, please submit this issue over at the [Mojang bug tracker](https://bugs.mojang.com/projects/MC/summary).'
+ ' Please search for existing reports first; in case you do not find any, create a new report and let us know about the issue number here (e.g. `MC-123456`).'
+ '\nThe Mojang team will take the first look. If an OpenJDK bug is identified, the Mojang team will contact our team to address the issue.'
)
}
github.rest.issues.createComment({
owner: owner,
repo: repo,
issue_number: issueNumber,
body: commentBody
})
// Add Minecraft label
github.rest.issues.addLabels({
owner: owner,
repo: repo,
issue_number: issueNumber,
labels: ['Minecraft']
})
// We will close any Minecraft-related issue automatically
github.rest.issues.update({
owner: owner,
repo: repo,
issue_number: issueNumber,
state: 'closed'
})
}