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

Provide an API to set generic Pull-Request sidebar content #23783

Open
silverwind opened this issue Mar 29, 2023 · 8 comments
Open

Provide an API to set generic Pull-Request sidebar content #23783

silverwind opened this issue Mar 29, 2023 · 8 comments
Labels
modifies/api This PR adds API routes or modifies them topic/api Concerns mainly the API type/feature Completely new functionality. Can only be merged if feature freeze is not active. type/proposal The new feature has not been accepted yet but needs to be discussed first.

Comments

@silverwind
Copy link
Member

silverwind commented Mar 29, 2023

Feature Description

It'd be nice if we could offer a API where third-party integrations like code coverage could create sidebar content into a PR, like for example coverage.

I could see it accepting something like

{
  "title": "CodeCov Coverage",
  "value": "55.32% (+0.15%)"
  "link": "https://codecov.example.com/pr-1234",
  "details": "more verbose markdown content..."
}

details and maybe value could accept Markdown. details content could be used to display a popup on mouseover that shows detailed content.

Related:

https://app.codecov.io/gh/feedback/p/support-gitea-scm
#23746 (comment)

@silverwind silverwind added type/proposal The new feature has not been accepted yet but needs to be discussed first. type/feature Completely new functionality. Can only be merged if feature freeze is not active. labels Mar 29, 2023
@a1012112796
Copy link
Member

a1012112796 commented Mar 29, 2023

@silverwind silverwind added the modifies/api This PR adds API routes or modifies them label Mar 29, 2023
@jpraet
Copy link
Member

jpraet commented Mar 29, 2023

For this example use case about reporting test coverage of a PR, isn't commit status suited for that?

https://try.gitea.io/api/swagger#/repository/repoCreateStatus

@silverwind
Copy link
Member Author

For this example use case about reporting test coverage of a PR, isn't commit status suited for that?

I think it's insufficient. It can only show success/error/warning etc, which is fine for cases where you want strict coverage, e.g. only success a PR if coverage increases. But for detailed reporting like CodeCov does as comments currently on GitHub, it's not enough.

@lunny
Copy link
Member

lunny commented Mar 30, 2023

We need an standard API to store the coverage stats results. We can have a summary in the sidebar of pull request. And even more, we can display every file's coverage in pull request file view or commit file view.

@silverwind
Copy link
Member Author

silverwind commented Mar 30, 2023

It could be generalized as "PR Metadata" and "PR file metadata" on the API. Thought I guess if we want to integrate deeply and show progress bars and such, there is no way around specifically supporting the coverage use case with specific APIs tailored to it.

@lunny
Copy link
Member

lunny commented Mar 30, 2023

It could be generalized as "PR Metadata" and "PR file metadata" on the API. Thought I guess if we want to integrate deeply and show progress bars and such, there is no way around specifically supporting the coverage use case with specific APIs tailored to it.

Just like commit status API, it will stick owner_name/repo_name and commit SHA, but not associated with a special PR. Because you don't know which model users will use with Gitea.

@a1012112796
Copy link
Member

look the action also need it, ref: #23722 #23721

@a1012112796
Copy link
Member

a1012112796 commented Mar 31, 2023

I think the checks run feature in github is a good solution for this issue, looks it's Upgraded commit status. the difference betwen check run and commit status :
image
in my view, looks check run = commit status + code review

some tips about do it:

image


屏幕截图 2023-03-31 163821

  • To show it on ui, maybe we can reuse commit status and code comment ui
  • checkRun db struct in my view:
type ChekRun struct {
	ID         int64                  `xorm:"pk autoincr"`
	RepoID     int64                  `xorm:"INDEX UNIQUE(repo_sha_index)"`
	Repo       *repo_model.Repository `xorm:"-"`
	State      int64                  // difference with `CommitStatus`
	Conclusion int64                  // difference with `CommitStatus`

	SHA       string           `xorm:"VARCHAR(64) NOT NULL INDEX UNIQUE(repo_sha_index)"`
	TargetURL string           `xorm:"TEXT"`
	NameHash  string           `xorm:"char(40) index"`
	Name      string           `xorm:"TEXT"`
	Creator   *user_model.User `xorm:"-"`
	CreatorID int64

	StartAt     timeutil.TimeStamp // difference with `CommitStatus`
	CompletedAt timeutil.TimeStamp // difference with `CommitStatus`

	OutPut  *ChekRunOutPut  `xorm:"-"` // difference with `CommitStatus`
	Actions []ChekRunAction `xorm:"-"` // difference with `CommitStatus`

	CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
	UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
}

type ChekRunAnnotation struct {
	Path            string
	StartLine       int64
	EndLine         int64
	StartColumn     int64
	EndColumn       int64
	AnnotationLevel string
	Message         string
	Title           string
	RawDetails      string
}

type ChekRunOutPut struct {
	ID          int64 `xorm:"pk autoincr"`
	ChekcRunID  int64 `xorm:"INDEX"`
	Title       string
	Summary     string
	Text        string
	Annotations []ChekRunAnnotation `xorm:"JSON"`
}

type ChekRunAction struct {
	ID          int64 `xorm:"pk autoincr"`
	ChekcRunID  int64 `xorm:"INDEX"`
	Label       string
	Description string
	Identifier  string
	Url         string
}

@silverwind silverwind added the topic/api Concerns mainly the API label Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
modifies/api This PR adds API routes or modifies them topic/api Concerns mainly the API type/feature Completely new functionality. Can only be merged if feature freeze is not active. type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

No branches or pull requests

4 participants