Skip to content
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

Github Search Module For Github Issues #1465

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Conversation

alper98
Copy link

@alper98 alper98 commented Oct 2, 2024

Pull Request: Add GitHub Search Backend Module and Frontend Plugin

Summary

This pull request introduces a new GitHub search backend module to enhance the search capabilities within the Backstage instance. The additions include:

  1. GitHub Search Backend Module: Indexes GitHub issues and makes them searchable inside the Backstage instance.

Changes

Backend

  • Module: search-backend-module-github
    • Functionality: Indexes GitHub issues and integrates them into the Backstage search engine.
    • Configuration:
      • Environment Variables:
        • search.collators.github.org: Specifies the organization to search within.
        • search.collators.github.query: Defines the query string used to search GitHub issues.
      • GitHub Credentials:
        • Token: Managed through Backstage integrations configuration.
        • App Authentication: Supported via GitHub apps with the necessary configuration.
      • YAML Configuration Example:
        search:
          collators:
            github:
              org: backstage
              host: github.com
              query: is:issue is:open org:backstage

Frontend

The GithubSearchResultListItem component will appear as follows on the search page:

image

@alper98 alper98 requested review from backstage-service and a team as code owners October 2, 2024 14:02
@alper98 alper98 requested a review from vinzscam October 2, 2024 14:02
Signed-off-by: Alper Altay <[email protected]>
Signed-off-by: Alper Altay <[email protected]>
@backstage-goalie
Copy link
Contributor

backstage-goalie bot commented Oct 2, 2024

Missing Changesets

The following package(s) are changed by this PR but do not have a changeset:

  • @backstage-community/plugin-github-issues

See CONTRIBUTING.md for more information about how to add changesets.

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage-community/plugin-github-issues workspaces/github-issues/plugins/github-issues none v0.4.6
@backstage-community/plugin-search-backend-module-github-issues workspaces/github-issues/plugins/search-backend-module-github-issues minor v0.1.0

Signed-off-by: Alper Altay <[email protected]>
Signed-off-by: Alper Altay <[email protected]>
Signed-off-by: Alper Altay <[email protected]>
@alper98 alper98 marked this pull request as ready for review October 2, 2024 18:07
Copy link
Member

@vinzscam vinzscam left a comment

Choose a reason for hiding this comment

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

thanks, this is amazing! 😻

async *execute(): AsyncGenerator<GithubIssuesDocument> {
this.logger.info('Starting collation of GitHub issues.');

const documents = await this.fetchGithubIssuesDocuments();
Copy link
Member

Choose a reason for hiding this comment

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

if there are 1000 issues, this will cause 1000 issues to be loaded in memory.
We could lift some logic from the fetchGithubIssuesDocuments, making sure that fetchGithubIssuesDocuments returns just a batch of element. Something like:

  let nextPage = ...
  while(hasNext()) {
    const result = this.fetchGithubIssuesDocuments(nextPage);
    nextPage = result.nextPage;
    for (const document of result.documents) {
      yield { ...document, ...stuff };
    }
  }

so that the collator will be more memory efficient.

Copy link
Author

Choose a reason for hiding this comment

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

Good point! Will change

}

private async fetchGithubIssuesDocuments(): Promise<Issue[] | Discussion[]> {
const { client } = await this.createClient();
Copy link
Member

Choose a reason for hiding this comment

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

we could move createClient to the parent function, so that we instantiate the client only once

Copy link
Author

Choose a reason for hiding this comment

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

Makes sense 🫡

/**
* The target that this provider should consume.
*
* @example "https://github.com/backstage"
Copy link
Author

Choose a reason for hiding this comment

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

self review: example should be backstage

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