Skip to content

Add Support for Github Issues with Repo Mapping to Project#8

Merged
seuros merged 14 commits intoseuros:masterfrom
aviflombaum:master
May 25, 2025
Merged

Add Support for Github Issues with Repo Mapping to Project#8
seuros merged 14 commits intoseuros:masterfrom
aviflombaum:master

Conversation

@aviflombaum
Copy link
Contributor

This PR adds a GitHub adapter to integrate GitHub Issues with ActiveProject. The implementation:

  • Treats GitHub repositories as projects in ActiveProject's data model
  • Provides full CRUD operations for GitHub Issues
  • Supports issue comments
  • Includes comprehensive webhook support for real-time events
  • Maps GitHub states (open/closed) to ActiveProject statuses
  • Implements proper error handling and validation
  • Includes thorough testing with VCR fixtures

The adapter uses GitHub's REST API v3 and follows ActiveProject's adapter pattern, providing a consistent interface
alongside existing Jira, Trello, and Basecamp adapters.

@seuros seuros requested a review from Copilot April 11, 2025 21:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 56 out of 59 changed files in this pull request and generated 1 comment.

Files not reviewed (3)
  • test/fixtures/github_webhook_comment_created.json: Language not supported
  • test/fixtures/github_webhook_issue_closed.json: Language not supported
  • test/fixtures/github_webhook_issue_opened.json: Language not supported
Comments suppressed due to low confidence (1)

lib/active_project/adapters/github/issues.rb:98

  • In 'update_issue', the code updates the issue based solely on the key :status, yet the README usage shows updating with key :state. Consider supporting both keys or standardizing on one attribute name for issue status updates.
def update_issue(id, attributes, context = {})


# Add a comment
puts "Adding comment to issue ##{updated_issue.key}..."
comment = github_adapter.add_comment(updated_issue.key, "This is a comment added via the ActiveProject gem.")
Copy link

Copilot AI Apr 11, 2025

Choose a reason for hiding this comment

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

The README example demonstrates adding a comment via the GitHub adapter, but no 'add_comment' method is implemented in the adapter. Please add an implementation for 'add_comment' or update the documentation to match supported functionality.

Copilot uses AI. Check for mistakes.
def initialize(options = {})
super
@status_mappings = options.delete(:status_mappings) || {
"open" => :open,
Copy link
Owner

Choose a reason for hiding this comment

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

since it the same, Github don't need mapping. You can omit it like jira and basecamp.

@@ -4,17 +4,28 @@ module ActiveProject
# Represents a standardized event parsed from a webhook payload.
# Using Struct for simplicity for now. Could be a full class inheriting BaseResource if needed.
WebhookEvent = Struct.new(
Copy link
Owner

Choose a reason for hiding this comment

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

We will rebuild the webhook in a future version, i tested it only in basecamp and jira.

You can remove the Webhook in GH to have the test pass.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I got the webhooks working I'm pretty sure, I'll double check.

@seuros
Copy link
Owner

seuros commented Apr 11, 2025

Wow, i started analyzing it few hours ago, but i'm happy to have you implement it.

GitHub offers two types of Projects:

  1. Repository-level Projects (via /repos/:owner/:repo/projects)
  2. Organization-level Projects (via /orgs/:org/projects)

Let's investigate if we can create a single adapter that handles both types through polymorphism. The adapter could detect the project type and use the appropriate endpoint.

If the differences become too complex for a single class, we could implement an inheritance structure with:

  • GithubBaseAdapter (shared functionality)
    • GithubRepoAdapter (repo-specific implementation)
    • GithubOrgAdapter (org-specific implementation)

This approach would maintain a clean interface while handling the endpoint differences under the hood.

@aviflombaum
Copy link
Contributor Author

I figured I'd map the concept of a project to a repo with issues on it as I think that's a more common pattern for the idea of projects and tickets/issues in the GitHub world.

GitHub projects via the REST API refer to a soon to be deprecated project resource. The new project resource on GitHub is only accessible via the graphql api, which we could implement. But those project objects don't really have issues, they have tasks, which can map to issues. But also those project objects can map to multiple repositories.

I thought this implementation mirrors the majority of actual issues and ticket management I've experienced on GitHub. We mostly think in terms of the repo being the project and its issues being tickets.

Thoughts?

I'll look over the other comments too if they need fixing happy to do it.

Also, to be honest, this was 98% vibe coded 😃 hope that's ok!

@seuros
Copy link
Owner

seuros commented Apr 11, 2025

Vibe coding’s totally fine as long as there’s some underlying research and understanding of the flow.

But let’s be honest here, vibe coding has a bad habit of inventing patterns that don’t actually exist and leaving behind more artifact/comments than a hoarder-themed episode of reality TV. It makes future maintenance a bit like an archaeological expedition.

The gem’s broader goal is to offer a normalized interface across tools. In reality, 99% of what people actually do in project management tools is create issues/tasks, move them around a board, and leave passive-aggressive comments.

The “transformational features” that we see in keynote slides, are mostly used by 12 power users who spend their days on LinkedIn telling everyone how a pastel-colored dashboard increased their team’s productivity by 1000% and to comment "Design" to get a free PDF with the method.

For the GitHub adapter: we should probably check when the REST endpoint is actually getting removed before committing to anything. If it’s soon, maybe not worth the effort or the vibes.

As for GraphQL, I was planning to explore a base engine so we can layer the other implementation on top of it cleanly.

The long-term vision here is to have all these adapters eventually maintained by their respective vendors, once we’ve established a sane standard, for us Rubyists and for our lovely LLM assistants who deserve better than this mess.

@aviflombaum
Copy link
Contributor Author

It looks like the REST API for Projects was due to be sunset already: https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/#rest-api-timeline So it sounds like a bad idea to use that.

I think it would be ideal to actually support both model mappings, where a "Project" could be a repo or it could be a Github project using the GraphQL API and maps to the project and tasks objects of that API and not the repo / issues objects.

We could Scope that somehow with two differetn Adadapters, Maybe GithubProjects for the GraphQL and Github Issues for the repo/issues mapping.

Anyway, let me know how you want to proceed, I think there's a lot of utility in the repo/issues mapping over the Projects one.

@seuros
Copy link
Owner

seuros commented Apr 16, 2025

let name this adapter to github_rest and merge it.

Can you fix the Webhook error in tests ? We could create a new Struct for Github Wehbhook.

@aviflombaum
Copy link
Contributor Author

Yep, I'll fix. I'd even consider renaming this adapter GithubRepo and then the GraphQL one for a github project can be GithubProject - that to me feels like a clear seperation for users of which to use - want to use this gem to manage issues on a repo? GithubRepo - want to use this to manage tasks on a github project - GithubProject.

@seuros
Copy link
Owner

seuros commented Apr 16, 2025

I like this thinking.

@seuros
Copy link
Owner

seuros commented Apr 23, 2025

@aviflombaum any update on this ?

seuros and others added 8 commits April 23, 2025 07:58
Centralized HTTP request handling into a reusable HttpClient module, simplifying and standardizing logic across adapters. Updated adapters (Trello, Basecamp, and Jira) to use the new module, reducing duplication and improving maintainability.
refactor: HTTP logic to use centralized HttpClient module
• add async, async-http & async-http-faraday to gemspec
• HttpClient now selects adapter via AP_DEFAULT_ADAPTER (defaults to :net_http)
• Pagination mix-in with each_page / each_page_async helpers
• ActiveProject::Async.run wrapper for easy task spawning
• Trello::Connection: map 400 "invalid id" → NotFoundError (kept in same file)
• CI matrix entry with AP_DEFAULT_ADAPTER=async_http
• lib/active_project/railtie.rb sets Fiber scheduler before Zeitwerk
• config flag   config.active_project.use_async_scheduler  (default true)
• env-var opt-out AP_NO_ASYNC_SCHEDULER=1
• main file requires railtie only when Rails::Railtie is defined
• adds AS::Notifications event "active_project.async_scheduler_set"
feat(core): introduce Async I/O pathway
…ster--components--active_project

chore(master): release active_project 0.3.0
seuros and others added 3 commits May 25, 2025 18:50
* feat: Github project adapter.

* feat(github): implement webhook processing for GitHub Projects V2

* Update lib/active_project/adapters/base.rb

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Renamed github adapter to github_repo in configuration
- Merged GitHub adapter functionality with existing github_project
- Resolved conflicts in README, configuration, and test files
- Combined VCR configuration approaches
- Updated test fixtures to use correct adapter names

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@seuros seuros merged commit e79bc39 into seuros:master May 25, 2025
0 of 2 checks passed
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.

2 participants