Skip to content

feat(integration-github): add repository purpose filtering#373

Open
arthurbazzz wants to merge 3 commits into
4.xfrom
feat/github-repository-purpose
Open

feat(integration-github): add repository purpose filtering#373
arthurbazzz wants to merge 3 commits into
4.xfrom
feat/github-repository-purpose

Conversation

@arthurbazzz

Copy link
Copy Markdown

Contexto

  • Foi adicionado o campo purpose em github_repositories
  • contributions definido como valor padrão
  • Filtro colocado impedindo que repositórios com purpose = challenge gerem contribuições
  • Mantém o comportamento atual para repositórios com purpose = contributions
  • Adiciona testes para os dois cenários (contributions e challenge)

Closes #344

@arthurbazzz arthurbazzz requested a review from a team June 24, 2026 13:54
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro

Run ID: bf6e035c-7707-4fdd-bd1b-e7b15cd7fbd0

📥 Commits

Reviewing files that changed from the base of the PR and between 896834e and 80967c2.

📒 Files selected for processing (1)
  • app-modules/integration-github/src/Models/GithubRepository.php
✅ Files skipped from review due to trivial changes (1)
  • app-modules/integration-github/src/Models/GithubRepository.php

📝 Walkthrough

Walkthrough

A new purpose string column is added to github_repositories and backfilled to contributions. PurposeType is introduced as a backed enum, GithubRepository gains a purpose PHPDoc property, and the repository factory sets purpose to contributions. ProjectGithubEvent::tenantsTracking() now limits matching repositories to purpose = contributions. Feature tests cover both challenge and contributions repository behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: adding repository purpose-based filtering in integration-github.
Description check ✅ Passed The description is directly related to the implemented purpose field, filtering, and tests.
Linked Issues check ✅ Passed The PR satisfies #344: adds purpose with default contributions, filters challenge repos, keeps contributions unchanged, and covers both cases in tests.
Out of Scope Changes check ✅ Passed The enum, factory, model PHPDoc, and tests are all in scope for the purpose-filtering change.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
app-modules/integration-github/src/Webhook/ProjectGithubEvent.php (1)

59-59: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Magic string 'contributions' duplicated across migration, query, and tests.

Centralize in a constant or enum to prevent silent drift between the default value and this filter.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app-modules/integration-github/src/Webhook/ProjectGithubEvent.php` at line
59, The `ProjectGithubEvent` query is using the magic string `contributions`
directly, which is duplicated across the codebase and can drift from the default
value. Introduce a shared constant or enum for this purpose value in the
relevant model/event class and use it in `ProjectGithubEvent` instead of the
literal string. Update the migration/default handling and any tests to reference
the same symbol so the filter, default, and assertions stay aligned.
app-modules/integration-github/database/migrations/2026_06_24_125428_add_purpose_to_github_repositories_table.php (1)

9-17: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Missing down() makes rollback a silent no-op.

Without a down(), migrate:rollback won't drop the purpose column, leaving schema drift.

♻️ Add rollback
     public function up(): void
     {
         Schema::table('github_repositories', static function (Blueprint $table): void {
             $table->string('purpose')->default('contributions');
         });
     }
+
+    public function down(): void
+    {
+        Schema::table('github_repositories', static function (Blueprint $table): void {
+            $table->dropColumn('purpose');
+        });
+    }
 };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@app-modules/integration-github/database/migrations/2026_06_24_125428_add_purpose_to_github_repositories_table.php`
around lines 9 - 17, The migration adds the github_repositories purpose column
in the anonymous Migration class but lacks a rollback path, so implement a
down() method that reverses the change by dropping purpose from the table. Use
the existing up() method and Schema::table pattern in this migration to keep the
forward and rollback behavior aligned.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@app-modules/integration-github/database/migrations/2026_06_24_125428_add_purpose_to_github_repositories_table.php`:
- Around line 9-17: The migration adds the github_repositories purpose column in
the anonymous Migration class but lacks a rollback path, so implement a down()
method that reverses the change by dropping purpose from the table. Use the
existing up() method and Schema::table pattern in this migration to keep the
forward and rollback behavior aligned.

In `@app-modules/integration-github/src/Webhook/ProjectGithubEvent.php`:
- Line 59: The `ProjectGithubEvent` query is using the magic string
`contributions` directly, which is duplicated across the codebase and can drift
from the default value. Introduce a shared constant or enum for this purpose
value in the relevant model/event class and use it in `ProjectGithubEvent`
instead of the literal string. Update the migration/default handling and any
tests to reference the same symbol so the filter, default, and assertions stay
aligned.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro

Run ID: aa0e4d01-f06b-45a7-abb5-5bcb14037f64

📥 Commits

Reviewing files that changed from the base of the PR and between ade5d6c and 79d4c0c.

📒 Files selected for processing (4)
  • app-modules/integration-github/database/migrations/2026_06_24_125428_add_purpose_to_github_repositories_table.php
  • app-modules/integration-github/src/Models/GithubRepository.php
  • app-modules/integration-github/src/Webhook/ProjectGithubEvent.php
  • app-modules/integration-github/tests/Feature/GithubWebhookTest.php

@danielhe4rt

Copy link
Copy Markdown
Contributor

@Clintonrocha98 @gvieira18

* @property string $tenant_id
* @property string $full_name
* @property bool $enabled
* @property string $purpose

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't 'purpose' be an enum rather than a string here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about this but i dunno if the "purpose" will grow more or if will remain only this two (contributions | challenge)

So is it better to create a enum?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is it better to create a enum?

IMO yes, it will prevent the spread of a possible incorrect string in the system, and at the same time, we will keep it as a strong type, specifying that it will always be only one of these values.

Comment on lines +11 to +16
public function up(): void
{
Schema::table('github_repositories', static function (Blueprint $table): void {
$table->string('purpose')->default('contributions');
});
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the idea of implementing an enum for this value, I would use a nullable string rather than a default value. Then, I would add an extra step to fill it with the default values.

Note

Do not use enums in migrations.
This could be impacted by a change in the future.
It will not be implemented if migration has already occurred; it will only be implemented on new databases.

Suggested change
public function up(): void
{
Schema::table('github_repositories', static function (Blueprint $table): void {
$table->string('purpose')->default('contributions');
});
}
public function up(): void
{
Schema::table('github_repositories', static function (Blueprint $table): void {
$table->string('purpose')->nullable();
});
DB::table('github_repositories')
->update(['purpose' => 'contributions']);
}

Before applying/implementing this suggestion, I would like to hear from @danielhe4rt and @Clintonrocha98. Default values aren't a problem, but they could be in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(integration-github): GithubRepository.purpose + excluir challenge das contribuições

3 participants