[Bug]: SOC predictor is not accurate. #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Check debug logs in bug reports | |
| on: | |
| issues: | |
| types: [opened, edited] | |
| jobs: | |
| check-logs: | |
| if: contains(github.event.issue.labels.*.name, 'bug') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| issues: write | |
| steps: | |
| - name: Check for valid debug logs | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const body = context.payload.issue.body || ''; | |
| // Extract debug logs section (between ### Debug logs and next ###) | |
| const match = body.match(/### Debug logs\s*\n([\s\S]*?)(?=\n### |$)/); | |
| const logsSection = match ? match[1].trim() : ''; | |
| // Patterns that indicate real debug logs | |
| const logPatterns = [ | |
| /\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}/, // timestamp | |
| /\b(DEBUG|INFO|WARNING|ERROR|CRITICAL)\b/, // log level | |
| /custom_components\.cardata/, // integration logger | |
| /\(MainThread\)/, // HA thread marker | |
| ]; | |
| const hasLabel = context.payload.issue.labels.some(l => l.name === 'needs-debug-logs'); | |
| const matchCount = logPatterns.filter(p => p.test(logsSection)).length; | |
| const isValid = logsSection.length > 100 && matchCount >= 2; | |
| if (!isValid) { | |
| // Add label if not present | |
| if (!hasLabel) { | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| labels: ['needs-debug-logs'] | |
| }); | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: [ | |
| '**The debug logs section does not appear to contain valid Home Assistant debug logs.**', | |
| '', | |
| 'Please enable debug logging and paste the actual log output:', | |
| '', | |
| '```yaml', | |
| 'logger:', | |
| ' default: info', | |
| ' logs:', | |
| ' custom_components.bmw_cardata: debug', | |
| '```', | |
| '', | |
| 'Then reproduce the issue and paste the logs in the **Debug logs** field.', | |
| 'Remove or redact personal data (VIN, location, tokens).', | |
| '', | |
| 'This issue will remain labeled `needs-debug-logs` until valid logs are provided.', | |
| ].join('\n') | |
| }); | |
| } | |
| } else if (hasLabel) { | |
| // Valid logs found and label exists — remove it | |
| try { | |
| await github.rest.issues.removeLabel({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| name: 'needs-debug-logs' | |
| }); | |
| } catch (e) { | |
| // Label might already be removed | |
| } | |
| } |