fix: improve check-repro workflow to validate repro field specifically

This commit is contained in:
lodev09 2025-12-16 16:16:12 +08:00
parent b42f80f4c8
commit 86d21fe19e
No known key found for this signature in database
GPG Key ID: F098AE8F7143F3E0
2 changed files with 32 additions and 15 deletions

View File

@ -32,18 +32,15 @@ body:
validations:
required: true
- type: dropdown
- type: checkboxes
id: platforms
attributes:
label: Affected Platforms
description: Select all platforms where you experience this issue.
multiple: true
options:
- iOS
- Android
- Web
validations:
required: true
- label: iOS
- label: Android
- label: Web
- label: Other
- type: input
id: library-version
@ -79,11 +76,9 @@ body:
- type: input
id: reproducible-example
attributes:
label: Reproduction Repository
description: |
**A minimal reproduction is required.** Provide a link to a GitHub repository or Expo Snack.
Issues without reproductions may be closed and labeled as `needs-repro`.
placeholder: https://github.com/username/repo or https://snack.expo.dev/...
label: Repro
description: A link to a GitHub repository, Expo Snack, CodeSandbox, or StackBlitz.
placeholder: https://github.com/username/repo
validations:
required: true

View File

@ -27,6 +27,13 @@ jobs:
const user = comment ? comment.user.login : author;
const body = comment ? comment.body : issue.body || '';
// Extract the reproduction field from the issue body
const reproFieldMatch = body.match(/### Repro\s+([\s\S]*?)(?=###|$)/i);
const reproField = reproFieldMatch ? reproFieldMatch[1].trim() : '';
// Skip if repro field is empty, n/a, or similar
const invalidRepro = /^(n\/?a|none|no|nothing|-|\.+)?$/i.test(reproField);
// Only accept repos owned by the issue author or commenter
const reproPatterns = [
new RegExp(`https?://github\\.com/${user}/[^/\\s]+/?`, 'i'),
@ -35,7 +42,8 @@ jobs:
new RegExp(`https?://stackblitz\\.com/[^\\s]+`, 'i'),
];
const hasRepro = reproPatterns.some(pattern => pattern.test(body));
// Check repro field specifically, not the entire body
const hasRepro = !invalidRepro && reproPatterns.some(pattern => pattern.test(reproField));
const labels = issue.labels.map(l => l.name);
const hasNeedsReproLabel = labels.includes('needs repro');
const hasReproProvidedLabel = labels.includes('repro provided');
@ -71,7 +79,21 @@ jobs:
});
}
} else {
// No valid repro - only act on issue events, not comments
// No valid repro - remove repro provided label if present
if (hasReproProvidedLabel) {
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
name: 'repro provided'
});
} catch (e) {
if (!e.message.includes('Label does not exist')) throw e;
}
}
// Only post warning comment on issue events, not comments
if (context.eventName !== 'issues') {
return;
}