v0.2 P0 checklist #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: Issue Auto Labeler | |
| on: | |
| issues: | |
| types: [opened, edited, reopened] | |
| permissions: | |
| issues: write | |
| jobs: | |
| label: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Apply area labels | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const issue = context.payload.issue; | |
| const body = issue.body || ''; | |
| const lines = body.split(/\r?\n/); | |
| const areaLabels = new Set([ | |
| 'area: docs', | |
| 'area: spec', | |
| 'area: parser', | |
| 'area: interpreter', | |
| 'area: typechecker', | |
| 'area: compiler', | |
| 'area: cli', | |
| 'area: tests', | |
| ]); | |
| const explicitAreas = new Set(); | |
| for (const line of lines) { | |
| const match = line.match(/^\s*-\s*\[[xX]\]\s*area:\s*([a-z]+)\s*$/i); | |
| if (!match) { | |
| continue; | |
| } | |
| const label = `area: ${match[1].toLowerCase()}`; | |
| if (areaLabels.has(label)) { | |
| explicitAreas.add(label); | |
| } | |
| } | |
| const filteredLines = lines.filter((line) => { | |
| if (/^\s*-\s*\[[ xX]\]\s*area:\s*/i.test(line)) { | |
| return false; | |
| } | |
| if (/^##\s+Primary area/i.test(line)) { | |
| return false; | |
| } | |
| return true; | |
| }); | |
| const text = `${issue.title}\n${filteredLines.join('\n')}`.toLowerCase(); | |
| const rules = [ | |
| { label: 'area: docs', re: /(\bdoc\b|\bdocs\b|documentation|readme|guide|tutorial)/ }, | |
| { label: 'area: spec', re: /(\bspec\b|specification|grammar)/ }, | |
| { label: 'area: parser', re: /(parser|parse|parsing|syntax)/ }, | |
| { label: 'area: interpreter', re: /(interpreter|runtime|eval|evaluator)/ }, | |
| { label: 'area: typechecker', re: /(type checker|typechecking|type checking|typechecker|typing rules|type inference|type system)/ }, | |
| { label: 'area: cli', re: /(\bcli\b|command line|terminal|shell)/ }, | |
| { label: 'area: compiler', re: /(compiler|\bir\b|codegen|lowering)/ }, | |
| { label: 'area: tests', re: /(\btesting\b|\bci\b|continuous integration|coverage|test suite|golden outputs?|snapshot|regression test|unit test|integration test)/ }, | |
| ]; | |
| const labels = new Set(explicitAreas); | |
| if (labels.size === 0) { | |
| for (const rule of rules) { | |
| if (rule.re.test(text)) { | |
| labels.add(rule.label); | |
| } | |
| } | |
| } | |
| if (labels.size === 0) { | |
| return; | |
| } | |
| await github.rest.issues.addLabels({ | |
| ...context.repo, | |
| issue_number: issue.number, | |
| labels: Array.from(labels), | |
| }); |