From 45b5da6b1e131c0795ef997754712a00568ab328 Mon Sep 17 00:00:00 2001 From: Martijn Verburg Date: Thu, 30 Mar 2023 10:12:35 +1300 Subject: [PATCH] Add extra support guidance for Minecraft --- .github/ISSUE_TEMPLATE/config.yml | 22 +-- ...inecraft-crash-reported-upstream-check.yml | 58 ++++++++ .github/workflows/minecraft-crash.yml | 140 ++++++++++++++++++ .vscode/settings.json | 7 + 4 files changed, 218 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/minecraft-crash-reported-upstream-check.yml create mode 100644 .github/workflows/minecraft-crash.yml diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 274f165..1eaf311 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,14 +1,18 @@ blank_issues_enabled: false contact_links: -- name: Chat 💬 - url: https://adoptium.net/slack.html - about: "Join our Slack channel #support to get help diagnosing your problems." + - name: Minecraft Java Edition Related Issue 🔐 + url: https://bugs.mojang.com/projects/MC/summary + about: Please submit Minecraft Java Edition related issues to the Mojang Issue Tracker First :-). -- name: Docker 🐋 - url: https://github.com/adoptium/containers/issues/new - about: "Please report issues with the `eclipse-temurin` Docker images here." + - name: Chat 💬 + url: https://adoptium.net/slack.html + about: "Join our Slack channel #support to get help diagnosing your problems." -- name: JDK Bug System ☕ - url: https://bugs.openjdk.java.net/secure/Dashboard.jspa - about: You can search for known bugs in the JDK Bug System. + - name: Docker 🐋 + url: https://github.com/adoptium/containers/issues/new + about: "Please report issues with the `eclipse-temurin` Docker images here." + + - name: JDK Bug System ☕ + url: https://bugs.openjdk.java.net/secure/Dashboard.jspa + about: You can search for known bugs in the JDK Bug System. diff --git a/.github/workflows/minecraft-crash-reported-upstream-check.yml b/.github/workflows/minecraft-crash-reported-upstream-check.yml new file mode 100644 index 0000000..fd9b540 --- /dev/null +++ b/.github/workflows/minecraft-crash-reported-upstream-check.yml @@ -0,0 +1,58 @@ +name: Add Minecraft upstream label +on: + issue_comment: + types: [created, edited] + +jobs: + check-reported-upstream: + runs-on: ubuntu-latest + steps: + - name: Check reported upstream + # Ignore pull request comments, see + # https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#issue_comment + if: ${{ !github.event.issue.pull_request }} + uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 # v6.4.0 + with: + script: | + // See documentation for payload properties + // https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#issue_comment + const issue = context.payload.issue + + const sender = context.payload.sender.login + + if (issue.user.login !== sender) { + console.log('Ignoring comment by user other than author') + return + } + + const reportedUpstreamLabel = 'Reported Upstream' + const issueLabels = issue.labels.map(label => label.name) + + if (issueLabels.includes(reportedUpstreamLabel)) { + console.log('Ignoring issue because it already has upstream label') + return + } + if (!issueLabels.includes('Minecraft')) { + console.log('Ignoring issue because it is not labeled as Minecraft') + return + } + + const commentBody = context.payload.comment.body + // Check if comment mentions Mojira issue key, e.g. MC-123456 + const matchedMojiraIssueKey = /(?= 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 = /(? 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 be considered Invalid + commentBody = ( + 'Thank you for the report!\n' + + 'It 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 report this crash to the mod creator. If you can also reproduce this crash without having 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`).' + ) + } else { + commentBody = ( + 'Thank you for the report!\n' + + '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`). ' + + 'The Mojang team will take the first look. If an OpenJDK bug is identified, the Mojang team will contact the Microsoft Build of OpenJDK 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' + }) + } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index c4af143..725f0df 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,15 @@ { "cSpell.words": [ + "axios", + "fabricmc", "jabba", "jenv", + "Mojang", + "Mojira", + "optifine", "Triaging", + "Tweaker", + "unstale", "Webdev" ] } \ No newline at end of file