From f5587256c3a9a2f2b7fb1d9f0b2163ff367a677e Mon Sep 17 00:00:00 2001 From: Blue Date: Mon, 25 Mar 2024 20:53:03 +0000 Subject: [PATCH] Run WTI to automatically triage github issues (#11329) * Experiment with WTI and GH actions * Remove condition * Yml && git push origin wti * Yml * Yml * Yml * Yml * Test integration * Test integration * Test integration * Test integration * Test integration * Test integration * Test integration * Test integration * Test integration * Cleanup * Test integration * Test integration * Test integration * Test integration * Test integration * Test integration * Test integration * Test integration * Test integration * Test integration * Test integration * Test integration * Test integration * Test integration * Test integration * Test integration * Test integration * Test integration * Test integration * Test integration * Test integration * Reduce message size * Reduce message size * Clean up download logic * Yaml * Yaml * Yaml * Yaml * Yaml * Yaml * Yaml * Update .github/workflows/new_issue.yml Co-authored-by: Craig Loewen * Update triage/config.yml Co-authored-by: Craig Loewen * Review feedback * Update triggers --------- Co-authored-by: Craig Loewen --- .github/actions/triage/action.yml | 44 +++ .github/workflows/new_issue.yml | 38 +++ .github/workflows/new_issue_comment.yml | 22 ++ .github/workflows/similarissues.yml | 34 --- triage/config.yml | 193 ++++++++++++ triage/no-filter.wpaProfile | 374 ++++++++++++++++++++++++ triage/wti.yml | 37 +++ 7 files changed, 708 insertions(+), 34 deletions(-) create mode 100644 .github/actions/triage/action.yml create mode 100644 .github/workflows/new_issue.yml create mode 100644 .github/workflows/new_issue_comment.yml delete mode 100644 .github/workflows/similarissues.yml create mode 100644 triage/config.yml create mode 100644 triage/no-filter.wpaProfile create mode 100644 triage/wti.yml diff --git a/.github/actions/triage/action.yml b/.github/actions/triage/action.yml new file mode 100644 index 0000000..c39569e --- /dev/null +++ b/.github/actions/triage/action.yml @@ -0,0 +1,44 @@ +name: Run automated triage + + +inputs: + issue: + required: false + type: string + similar_issues_text: + required: false + type: string + comment: + required: false + type: string + token: + required: false + type: string + +runs: + using: "composite" + steps: + - name: 'Run WTI' + if: ${{ !contains(inputs.similar_issues_text, '''@') }} # Skip this step if the description contains a string that will break the here document + shell: pwsh + run: | + $ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop + $message = @' + ${{ inputs.similar_issues_text }} + '@ + + $maybe_message = @() + if (![string]::IsNullOrEmpty($message)) + { + $maybe_message = @("--default-message-stdin") + } + + $maybe_comment = @() + if (![string]::IsNullOrEmpty("${{ inputs.comment }}")) + { + $maybe_comment = @("--comment", "${{ inputs.comment }}") + } + + curl.exe -L https://github.com/OneBlue/wti/releases/download/v0.1.1/wti.exe -o triage/wti.exe + + cd triage && echo -n $message | .\wti.exe --issue ${{ inputs.issue }} --config config.yml --github-token "${{ inputs.token }}" --ignore-tags @maybe_message @maybe_comment \ No newline at end of file diff --git a/.github/workflows/new_issue.yml b/.github/workflows/new_issue.yml new file mode 100644 index 0000000..6192252 --- /dev/null +++ b/.github/workflows/new_issue.yml @@ -0,0 +1,38 @@ +name: Process new issue + +on: + issues: + types: [opened] + +jobs: + getSimilarIssues: + runs-on: ubuntu-latest + outputs: + message: ${{ steps.getBody.outputs.message }} + steps: + - uses: actions/checkout@v2 + - id: getBody + uses: craigloewen-msft/GitGudSimilarIssues@main + with: + issueTitle: ${{ github.event.issue.title }} + issueBody: ${{ github.event.issue.body }} + repository: ${{ github.repository }} + similarityTolerance: "0.7" + commentBody: | + # View similar issues + Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it! + wti: + name: Run wti + needs: getSimilarIssues + runs-on: windows-2022 + permissions: + issues: write + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - uses: ./.github/actions/triage + with: + similar_issues_text: "${{ needs.getSimilarIssues.outputs.message }}" + issue: "${{ github.event.issue.number }}" + token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/new_issue_comment.yml b/.github/workflows/new_issue_comment.yml new file mode 100644 index 0000000..b1e1feb --- /dev/null +++ b/.github/workflows/new_issue_comment.yml @@ -0,0 +1,22 @@ +name: Process new comment on issue + +on: + issue_comment: + types: [created] + +jobs: + wti: + name: Run wti + runs-on: windows-2022 + permissions: + issues: write + if: ${{ !github.event.issue.pull_request && github.event.issue.user.id == github.event.comment.user.id }} + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - uses: ./.github/actions/triage + with: + issue: '${{ github.event.issue.number }}' + comment: '${{ github.event.comment.id }}' + token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/similarissues.yml b/.github/workflows/similarissues.yml deleted file mode 100644 index 7c2373d..0000000 --- a/.github/workflows/similarissues.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: GitGudSimilarIssues comments - -on: - issues: - types: [opened] - -jobs: - getSimilarIssues: - runs-on: ubuntu-latest - outputs: - message: ${{ steps.getBody.outputs.message }} - steps: - - uses: actions/checkout@v2 - - id: getBody - uses: craigloewen-msft/GitGudSimilarIssues@main - with: - issueTitle: ${{ github.event.issue.title }} - issueBody: ${{ github.event.issue.body }} - repository: ${{ github.repository }} - similarityTolerance: "0.7" - add-comment: - needs: getSimilarIssues - runs-on: ubuntu-latest - permissions: - issues: write - if: needs.getSimilarIssues.outputs.message != '' - steps: - - name: Add comment - run: gh issue comment "$NUMBER" --repo "$REPO" --body "$BODY" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NUMBER: ${{ github.event.issue.number }} - REPO: ${{ github.repository }} - BODY: ${{ needs.getSimilarIssues.outputs.message }} diff --git a/triage/config.yml b/triage/config.yml new file mode 100644 index 0000000..89acafd --- /dev/null +++ b/triage/config.yml @@ -0,0 +1,193 @@ +wpa_profile: no-filter.wpaProfile + +logs_rules: + missing_logs_message: | + # Logs are required for review from WSL team + + If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. + **Otherwise please attach logs by following the instructions below**, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine. + +
+ + How to collect WSL logs + + Download and execute [collect-wsl-logs.ps1](https://github.com/Microsoft/WSL/blob/master/diagnostics/collect-wsl-logs.ps1) in an **administrative powershell prompt**: + + ``` + Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1 + Set-ExecutionPolicy Bypass -Scope Process -Force + .\collect-wsl-logs.ps1 + ``` + + The scipt will output the path of the log file once done. + + Once completed please upload the output files to this Github issue. + + [Click here for more info on logging](https://github.com/microsoft/WSL/blob/master/CONTRIBUTING.md#8-collect-wsl-logs-recommended-method) + If you choose to email these logs instead of attaching to the bug, please send them to wsl-gh-logs@microsoft.com with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'. +
+ + + missing_logs_add_tags: ['needs-author-feedback'] + skip_tags: ['feature', 'question', 'emailed-logs', 'network'] + +tags_rules: + - contains: '/question' + tag: 'question' + + - contains: '/feature' + tag: 'feature' + + - contains: '/emailed-logs' + tag: 'emailed-logs' + +rules: + - logline: + provider: Microsoft.Windows.Lxss.Manager + task: GuestLog + field1: + contains: 'brd: module loaded' + set: booting + + - logline: + provider: Microsoft.Windows.Lxss.Manager + task: GuestLog + field1: + contains: 'oom-kill' + set: + name: oom + capture: + field1: oom-error + + - logline: + provider: Microsoft.Windows.Lxss.Manager + task: GuestLog + field1: + contains: 'Kernel panic' + set: + name: kernel-panic + capture: + field1: kmsg + + - logline: + provider: Microsoft.Windows.Lxss.Manager + task: GuestLog + field1: + regex: 'WSL (.*) ERROR' + set: init-error + + - logline: + provider: Microsoft.Windows.Subsystem.Lxss + task: UserVisibleError + set: + name: user-visible-error + capture: + field3: error + + - logline: + provider: Microsoft-Windows-Hyper-V-Chipset + field1: + regex: '.*biosdevice.*80070057.*' # 80070057 = E_INVALIDARG + set: corrupted-initramfs + + - logline: + provider: Microsoft.Windows.Lxss.Manager + task: FailedToStartVm + set: + name: vm-failed-to-start + capture: + field4: error + + - logline: + provider: Microsoft.Windows.Lxss.Manager + set: service-running + oneshot: true + + - logline: + provider: Microsoft.Windows.Subsystem.Lxss + task: LxssException + field7: + regex: '.*0x80070422.*' + set: service-disabled-error + + - logline: + provider: Microsoft.Windows.Subsystem.Lxss + task: UserVisibleError + field3: {regex: '.*/ConfigureNetworking/HNS/.*'} + set: + name: hns-fatal-error + capture: + field3: error + + + - logline: + provider: Microsoft.Windows.Hyper.V.NetMgmt + task: NetMgmt::CreateVirtualSwitch + field4: '0x80041002' + set: + name: vmswitch-known-issue + capture: + field4: error + + - logline: + provider: Microsoft.Windows.Lxss.Manager + task: GuestLog + field1: + contains: 'EXT4-fs error' + set: + name: ext4-error + capture: + field1: error +actions: + - foreach: + var: user-visible-error + debug_message: 'Detected user visible error: $error' + + - when: + condition: 'kernel-panic' + debug_message: 'Found evidence of kernel panic: $kmsg' + + - when: + condition: + and: ['oom', 'booting'] + user_message: 'The logs show that WSL2 ran out of memory. Try increasing wsl2.memory in .wslconfig and see if that solves the issue.' + debug_message: 'Found evidence of OOM kill: $oom-error' + tag: needs-author-feedback + + - when: + condition: + and: ['vm-failed-to-start', 'hyperv-firmware-expired'] + user_message: 'The logs show that your Hyper-V firmware is expired. Please update your Windows build and see if that solves the issue' + tag: needs-author-feedback + + - when: + condition: + and: ['vm-failed-to-start', 'corrupted-initramfs'] + user_message: 'Your WSL installation seems corrupted. Please try to download and install the [latest WSL release](https://github.com/microsoft/WSL/releases/latest)' + tag: needs-author-feedback + + - when: + condition: + and: [{not: 'service-running'}, 'service-disabled-error'] + user_message: 'The logs show that wslservice is disabled. Try to run (elevated command prompt): `sc.exe config wslservice start= demand` and see if that solves the issue' + tag: needs-author-feedback + + - when: + condition: + and: ['vm-failed-to-start', 'hns-fatal-error'] + user_message: 'An HNS error seems to be causing WSL2 to fail to start. Adding network tag' + debug_message: 'Found HNS error: $error' + tag: 'network' + + - when: + condition: + and: ['vm-failed-to-start', 'vmswitch-known-issue'] + user_message: 'Known vmswitch issue found (error: $error). Adding network tag' + debug_message: 'Found evidence of vmswitch error: $error' + tag: 'network' + + - when: + condition: 'ext4-error' + user_message: 'The logs shows that a disk mount error occured. Try to [follow these repair instructions](https://learn.microsoft.com/en-us/windows/wsl/disk-space#how-to-repair-a-vhd-mounting-error) and see if that solves the issue.' + debug_message: 'Found evidence of ext4 error: $error' + tag: 'needs-author-feedback' \ No newline at end of file diff --git a/triage/no-filter.wpaProfile b/triage/no-filter.wpaProfile new file mode 100644 index 0000000..39a3135 --- /dev/null +++ b/triage/no-filter.wpaProfile @@ -0,0 +1,374 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/triage/wti.yml b/triage/wti.yml new file mode 100644 index 0000000..eb0aee3 --- /dev/null +++ b/triage/wti.yml @@ -0,0 +1,37 @@ +name: Sync GitHub with ADO + +on: + pull_request: + +jobs: + getSimilarIssues: + runs-on: ubuntu-latest + outputs: + message: ${{ steps.getBody.outputs.message }} + steps: + - uses: actions/checkout@v2 + - id: getBody + uses: craigloewen-msft/GitGudSimilarIssues@main + with: + issueTitle: "Cannot install WSL on latest Windows Insider dev build" # Hardcoded for testing + issueBody: "Cannot install WSL on latest Windows Insider dev build" # Hardcoded for testing + repository: ${{ github.repository }} + similarityTolerance: "0.1" # Lowered value for testing + commentBody: Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it! + + wti: + name: Run wti + needs: getSimilarIssues + runs-on: windows-2022 + permissions: + issues: write + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: 'Run WTI' + if: ${{ !contains(needs.getSimilarIssues.outputs.message, '''@') }} # Skip this step if the description contains a string that will break the here document + run: | + cd .github\workflows && echo @' + ${{ needs.getSimilarIssues.outputs.message }} + '@ | .\wti.exe --issue 11305 --config config.yml --github-token "${{ secrets.GITHUB_TOKEN }}" --ignore-tags --default-message-stdin \ No newline at end of file