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

DM-35816: Support for viewing GitHub PR previews in Squareone #42

Merged
merged 12 commits into from
Aug 18, 2022

Conversation

jonathansick
Copy link
Member

@jonathansick jonathansick commented Aug 3, 2022

This adds new endpoints to support the UI for previewing a repository based on a GitHub check run:

  • GET /times-square/api/v1/github-pr/:org/:repo/:sha provides metadata about the GitHub contents for that commit, along with check runs and related pull requests. This endpoint powers the side bar in Squareone's views.
  • GET /times-square/api/v1/github-pr/:org/:repo/:sha/:path provides metadata about a specific notebook. This endpoint essentially maps to the traditional page resource given its context in a GitHub repository and commit.

These endpoints are specializations of the equivalent APIs for GitHub-backed pages in /times-square/api/v1/github.

The fastapi.Path class lets us properly document the path parameters in
the Open API spec.
This provides access to the pages that are built automatically by the
GitHub Check run handlers for a GitHub pull request.

- New PageService.get_github_pr_page
- New /github-pr/ endpoints, similar to the existing /github/ endpoints,
  but have the PR's head commit SHA in the path to show pages for a
  specific PR check run
- Revised GitHubTree domain model.

The new domain model separates path segments (which are used to add
nodes relative to other nodes) from the Squareone URL path. This
dramatically simplifies the tree domain construction and makes it
possible to use the same domain object for PR preview trees as well.

The new GitHubNode is a dataclass; in the REST API we transform that
dataclass into a Pydantic model for the response.
Normally we create a GitHubRepoService in webhook handlers where the
installation ID is know. This new create_github_repo_service classmethod
lets us look-up the installation ID for a specific repository, and then
create the service using a GitHub client authenticated for that
installation.
Get the check run resources from the GitHub API for a specific commit.
This method, along with the required domain models, allow us to get the
PR resources related to GitHub check runs for a specific commit.
The contents for a GitHub pull request now include info about pull
requests and the status of check runs.
This sets the "details_url" field for check runs to the Squareone
landing page for the check run,
/times-square/github-pr/:owner/:repo/:commit
@jonathansick jonathansick merged commit 58d0b0f into main Aug 18, 2022
@jonathansick jonathansick deleted the tickets/DM-35816 branch August 18, 2022 23:45
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.

1 participant