-
Notifications
You must be signed in to change notification settings - Fork 0
feat: implement repository hygiene and automation infrastructure #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
88a1597
e09e046
8f11ae8
685a74e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| version: 2 | ||
| updates: | ||
| # GitHub Actions dependencies | ||
| - package-ecosystem: "github-actions" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
| day: "monday" | ||
| time: "09:00" | ||
| open-pull-requests-limit: 5 | ||
| labels: | ||
| - "dependencies" | ||
| - "github-actions" | ||
| commit-message: | ||
| prefix: "chore" | ||
| prefix-development: "chore" | ||
| include: "scope" | ||
|
|
||
| # npm/JavaScript dependencies (if package.json exists) | ||
| - package-ecosystem: "npm" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
| day: "monday" | ||
| time: "09:00" | ||
| open-pull-requests-limit: 10 | ||
| versioning-strategy: increase | ||
| labels: | ||
| - "dependencies" | ||
| - "javascript" | ||
| commit-message: | ||
| prefix: "chore" | ||
| prefix-development: "chore" | ||
| include: "scope" | ||
| ignore: | ||
| # Ignore major version updates for now | ||
| - dependency-name: "*" | ||
| update-types: ["version-update:semver-major"] | ||
|
|
||
| # Python dependencies (if requirements.txt, setup.py, or pyproject.toml exists) | ||
| - package-ecosystem: "pip" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
| day: "monday" | ||
| time: "09:00" | ||
| open-pull-requests-limit: 10 | ||
| labels: | ||
| - "dependencies" | ||
| - "python" | ||
| commit-message: | ||
| prefix: "chore" | ||
| prefix-development: "chore" | ||
| include: "scope" | ||
| ignore: | ||
| # Ignore major version updates for now | ||
| - dependency-name: "*" | ||
| update-types: ["version-update:semver-major"] | ||
|
|
||
| # Docker dependencies (if Dockerfile exists) | ||
| - package-ecosystem: "docker" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
| day: "monday" | ||
| time: "09:00" | ||
| open-pull-requests-limit: 5 | ||
| labels: | ||
| - "dependencies" | ||
| - "docker" | ||
| commit-message: | ||
| prefix: "chore" | ||
| include: "scope" | ||
|
|
||
| # Go dependencies (if go.mod exists) | ||
| - package-ecosystem: "gomod" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
| day: "monday" | ||
| time: "09:00" | ||
| open-pull-requests-limit: 10 | ||
| labels: | ||
| - "dependencies" | ||
| - "golang" | ||
| commit-message: | ||
| prefix: "chore" | ||
| include: "scope" | ||
|
Comment on lines
+86
to
+88
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "ignorePatterns": [ | ||
| { | ||
| "pattern": "^http://localhost" | ||
| } | ||
| ], | ||
| "timeout": "20s", | ||
| "retryOn429": true, | ||
| "retryCount": 3, | ||
| "fallbackRetryDelay": "30s", | ||
| "aliveStatusCodes": [200, 206, 301, 302, 307, 308, 403, 429] | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,71 @@ | ||||||
| ## 📋 Descrição | ||||||
|
|
||||||
| <!-- Descreva as mudanças feitas neste PR. Seja claro e objetivo. --> | ||||||
|
|
||||||
| ### O que mudou? | ||||||
|
|
||||||
| <!-- Liste as principais alterações --> | ||||||
|
|
||||||
| ### Por quê? | ||||||
|
|
||||||
| <!-- Explique a motivação para essas mudanças --> | ||||||
|
|
||||||
| ## ✅ Checklist | ||||||
|
|
||||||
| <!-- Marque os itens aplicáveis com [x] --> | ||||||
|
|
||||||
| - [ ] O código segue os padrões do projeto | ||||||
| - [ ] Testes foram executados e estão passando | ||||||
| - [ ] Documentação foi atualizada (se aplicável) | ||||||
| - [ ] Commits seguem o padrão [Conventional Commits](https://www.conventionalcommits.org/pt-br/) | ||||||
| - [ ] Não há conflitos com a branch base | ||||||
| - [ ] Revisão própria do código foi realizada | ||||||
| - [ ] Comentários foram adicionados em áreas complexas (se necessário) | ||||||
|
|
||||||
| ## 🔗 Issue Relacionada | ||||||
|
|
||||||
| <!-- Link para a issue relacionada. Se não houver, remova esta seção. --> | ||||||
|
|
||||||
| Closes # | ||||||
| Relates to # | ||||||
|
|
||||||
| ## 🎯 Impacto Esperado | ||||||
|
|
||||||
| <!-- Descreva quais áreas do projeto são afetadas por essas mudanças --> | ||||||
|
|
||||||
| ### Áreas Afetadas | ||||||
|
|
||||||
| - [ ] Documentação | ||||||
| - [ ] Automação/Scripts | ||||||
| - [ ] Templates | ||||||
| - [ ] CI/CD | ||||||
| - [ ] Configuração do Projeto | ||||||
| - [ ] Outro: ___________ | ||||||
|
|
||||||
| ### Impacto de Risco | ||||||
|
|
||||||
| - [ ] **Baixo** - Mudanças isoladas, sem impacto em funcionalidades existentes | ||||||
| - [ ] **Médio** - Alterações que podem afetar funcionalidades existentes | ||||||
| - [ ] **Alto** - Mudanças significativas que requerem atenção especial | ||||||
|
|
||||||
| ## 📸 Capturas de Tela (se aplicável) | ||||||
|
|
||||||
| <!-- Adicione capturas de tela ou GIFs para demonstrar mudanças visuais --> | ||||||
|
|
||||||
| ## 🧪 Como Testar | ||||||
|
|
||||||
| <!-- Descreva os passos para testar as mudanças --> | ||||||
|
|
||||||
| 1. | ||||||
|
Check failure on line 59 in .github/pull_request_template.md
|
||||||
| 2. | ||||||
|
Check failure on line 60 in .github/pull_request_template.md
|
||||||
| 3. | ||||||
|
Check failure on line 61 in .github/pull_request_template.md
|
||||||
|
|
||||||
| ## 📝 Notas Adicionais | ||||||
|
|
||||||
| <!-- Qualquer informação adicional que os revisores devem saber --> | ||||||
|
|
||||||
| ## 🔍 Revisores Sugeridos | ||||||
|
|
||||||
| <!-- @mencione revisores específicos, se houver --> | ||||||
|
|
||||||
| @ | ||||||
|
||||||
| @ | |
| @reviewer-username |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| name: Auto Label PRs | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, edited, reopened] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| issues: write | ||
|
|
||
| jobs: | ||
| auto-label: | ||
| name: Automatically Label Pull Requests | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Auto-label based on PR content | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const prTitle = context.payload.pull_request.title.toLowerCase(); | ||
| const prBody = (context.payload.pull_request.body || '').toLowerCase(); | ||
| const prContent = `${prTitle} ${prBody}`; | ||
|
|
||
| // Define label mapping with keywords | ||
| const labelMappings = { | ||
| 'enhancement': ['feat', 'feature', 'add', 'implement', 'enhance', 'new'], | ||
| 'bugfix': ['fix', 'bug', 'resolve', 'correct', 'patch', 'repair'], | ||
| 'documentation': ['docs', 'documentation', 'readme', 'guide', 'comment'], | ||
| 'refactor': ['refactor', 'cleanup', 'restructure', 'optimize', 'improve'] | ||
| }; | ||
|
|
||
| // Additional labels for special cases | ||
| const specialLabels = { | ||
| 'dependencies': ['dependency', 'dependencies', 'dependabot', 'upgrade', 'update package'], | ||
| 'ci': ['ci', 'workflow', 'github actions', 'pipeline', 'automation'], | ||
| 'security': ['security', 'vulnerability', 'cve', 'exploit'], | ||
| 'breaking-change': ['breaking change', 'breaking', 'major version'] | ||
| }; | ||
|
|
||
| // Combine all label mappings | ||
| const allMappings = { ...labelMappings, ...specialLabels }; | ||
|
|
||
| const labelsToAdd = new Set(); | ||
|
|
||
| // Check for matching keywords | ||
| for (const [label, keywords] of Object.entries(allMappings)) { | ||
| for (const keyword of keywords) { | ||
| if (prContent.includes(keyword)) { | ||
| labelsToAdd.add(label); | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Convert Set to Array | ||
| const labels = Array.from(labelsToAdd); | ||
|
|
||
| // If no labels matched, add 'needs-triage' | ||
| if (labels.length === 0) { | ||
| labels.push('needs-triage'); | ||
| } | ||
|
|
||
| // Get current labels | ||
| const currentLabels = context.payload.pull_request.labels.map(l => l.name); | ||
|
|
||
| // Only add labels that don't already exist | ||
| const newLabels = labels.filter(l => !currentLabels.includes(l)); | ||
|
|
||
| if (newLabels.length > 0) { | ||
| console.log(`Adding labels: ${newLabels.join(', ')}`); | ||
|
|
||
| await github.rest.issues.addLabels({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.payload.pull_request.number, | ||
| labels: newLabels | ||
| }); | ||
| } else { | ||
| console.log('No new labels to add'); | ||
| } | ||
|
|
||
| - name: Add size label | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| // Get PR diff stats | ||
| const pr = await github.rest.pulls.get({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| pull_number: context.payload.pull_request.number | ||
| }); | ||
|
|
||
| const additions = pr.data.additions; | ||
| const deletions = pr.data.deletions; | ||
| const totalChanges = additions + deletions; | ||
|
|
||
| let sizeLabel = ''; | ||
|
|
||
| if (totalChanges < 10) { | ||
| sizeLabel = 'size/XS'; | ||
| } else if (totalChanges < 50) { | ||
| sizeLabel = 'size/S'; | ||
| } else if (totalChanges < 200) { | ||
| sizeLabel = 'size/M'; | ||
| } else if (totalChanges < 500) { | ||
| sizeLabel = 'size/L'; | ||
| } else { | ||
| sizeLabel = 'size/XL'; | ||
| } | ||
|
|
||
| // Remove existing size labels | ||
| const currentLabels = context.payload.pull_request.labels; | ||
| const sizeLabelsToRemove = currentLabels | ||
| .filter(l => l.name.startsWith('size/')) | ||
| .map(l => l.name); | ||
|
|
||
| for (const label of sizeLabelsToRemove) { | ||
| await github.rest.issues.removeLabel({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.payload.pull_request.number, | ||
| name: label | ||
| }).catch(() => { | ||
| // Ignore errors if label doesn't exist | ||
| }); | ||
| } | ||
|
|
||
| // Add new size label | ||
| console.log(`Adding size label: ${sizeLabel} (${totalChanges} changes)`); | ||
|
|
||
| await github.rest.issues.addLabels({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.payload.pull_request.number, | ||
| labels: [sizeLabel] | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit message configuration for the Docker ecosystem is missing the "prefix-development" field, which is present in the GitHub Actions, npm, and pip configurations. This inconsistency could lead to different commit message formats for Docker dependency updates. For consistency, consider adding "prefix-development: 'chore'" to match the other ecosystem configurations.