Documentation ¶
Index ¶
- Variables
- type Chart
- type ChartService
- type Client
- type Commit
- type ContentService
- type CoverageReport
- type CoverageReportDiff
- type CoverageService
- type DatabaseService
- type File
- type FileChange
- type FileDiff
- type FileNameFilters
- type Git
- type GitCommit
- type GitRepoService
- type GitRepository
- type GitService
- type Hook
- type HookEvent
- type HookService
- type LoginMiddleware
- type OAuthService
- type OAuthStore
- type OAuthToken
- type PullRequest
- type PullRequestHook
- type PullRequestService
- type Repo
- type RepoService
- type RepoSetting
- type RepoStore
- type Report
- type ReportComment
- type ReportService
- type ReportStore
- type ReportType
- type ReportUpdateAction
- type SCMProvider
- type SCMService
- type Session
- type StatementHit
- type Token
- type User
- type UserService
- type UserStore
- type WebhookService
Constants ¶
This section is empty.
Variables ¶
var ErrNotImplemented = errors.New("not implement")
ErrNotImplemented function
Functions ¶
This section is empty.
Types ¶
type ChartService ¶
type ChartService interface { CoverageDiffTreeMap(old, new *Report) Chart RepoCard(repo *Repo, report *Report) Chart }
ChartService provides charts
type Client ¶
type Client interface { Repositories() GitRepoService Users() UserService Git() GitService Contents() ContentService PullRequests() PullRequestService Webhooks() WebhookService Token(user *User) Token }
Client connects to a SCM provider
type Commit ¶ added in v0.1.4
type Commit struct { Sha string `json:"sha"` Message string `json:"message"` Committer string `json:"committer"` CommitterAvater string `json:"committerAvatar"` }
Commit object
type ContentService ¶
type ContentService interface { ListAllFiles(ctx context.Context, user *User, repo, ref string) ([]string, error) Find(ctx context.Context, user *User, repo, path, ref string) ([]byte, error) }
ContentService provides information of source codes
type CoverageReport ¶
type CoverageReport struct { Files []*File `json:"files"` Type ReportType `json:"type"` StatementCoverage float64 `json:"statementCoverage"` }
CoverageReport defined the code coverage report
func (*CoverageReport) ComputeStatementCoverage ¶ added in v0.1.0
func (cov *CoverageReport) ComputeStatementCoverage() float64
ComputeStatementCoverage of the report
type CoverageReportDiff ¶
CoverageReportDiff defines the difference between coverage reports
type CoverageService ¶
type CoverageService interface { Report(ctx context.Context, t ReportType, r io.Reader) (*CoverageReport, error) // Find coverage report from the given path. Find(ctx context.Context, t ReportType, path string) (string, error) Open(ctx context.Context, t ReportType, path string) (io.Reader, error) // TrimFileNames in the coverage report TrimFileNames(ctx context.Context, report *CoverageReport, filters FileNameFilters) error TrimFileNamePrefix(ctx context.Context, report *CoverageReport, prefixes ...string) error }
CoverageService provides CoverReport
type DatabaseService ¶
DatabaseService provides database operations with GORM
type File ¶
type File struct { Name string StatementCoverage float64 StatementHits []*StatementHit }
File holds the coverage information of a single file
type FileChange ¶
FileChange defines file status
type FileNameFilters ¶
type FileNameFilters []string
FileNameFilters is a list of regular expression to trim file name
type Git ¶
type Git interface { Clone(ctx context.Context, URL, token string) (GitRepository, error) PlainOpen(ctx context.Context, path string) (GitRepository, error) }
Git interact with SCM with plain git commands
type GitRepoService ¶ added in v0.1.9
type GitRepoService interface { NewReportID(repo *Repo) string // List repositories from SCM context List(ctx context.Context, user *User) ([]*Repo, error) Find(ctx context.Context, user *User, name string) (*Repo, error) CloneURL(ctx context.Context, user *User, name string) (string, error) CreateHook(ctx context.Context, user *User, name string) (*Hook, error) RemoveHook(ctx context.Context, user *User, name string, hook *Hook) error IsAdmin(ctx context.Context, user *User, name string) bool }
GitRepoService provides operations with SCM
type GitRepository ¶
type GitRepository interface { ListAllFiles(commit string) ([]string, error) // Commit returns a GitCommit object of the SHA Commit(commit string) (GitCommit, error) HeadCommit() string Branch() string Root() string }
GitRepository which is cloned from SCM
type GitService ¶
type GitService interface { GitRepository(ctx context.Context, user *User, repo string) (GitRepository, error) FindCommit(ctx context.Context, user *User, repo *Repo) string // ListCommits in the repository default branch ListCommits(ctx context.Context, user *User, repo string) ([]*Commit, error) // ListCommitsByRef in the repository reference. The reference could be branch name. ListCommitsByRef(ctx context.Context, user *User, repo, ref string) ([]*Commit, error) ListBranches(ctx context.Context, user *User, repo string) ([]string, error) }
GitService provides Git operations
type HookService ¶
type HookService interface { Create(ctx context.Context, repo *Repo) error Delete(ctx context.Context, repo *Repo) error Resolve(ctx context.Context, repo *Repo, hook HookEvent) error }
HookService manages and resolves webhooks
type LoginMiddleware ¶
type LoginMiddleware interface {
Handler(scm SCMProvider) login.Middleware
}
LoginMiddleware for Gin
type OAuthService ¶ added in v0.1.8
type OAuthService interface { CreateToken(ctx context.Context, name string) (*OAuthToken, error) DeleteToken(ctx context.Context, token *OAuthToken) error ListTokens(ctx context.Context) ([]*OAuthToken, error) Validate(r *http.Request) (*User, error) WithUser(ctx context.Context, user *User) context.Context }
OAuthService provide OAuth2 protocol
type OAuthStore ¶ added in v0.1.8
type OAuthStore interface { Create(token *OAuthToken) error Find(token *OAuthToken) (*OAuthToken, error) List(user *User) ([]*OAuthToken, error) Delete(token *OAuthToken) error }
OAuthStore token information
type OAuthToken ¶ added in v0.1.8
type OAuthToken struct { ID uint Name string Code string Access string Refresh string Expires time.Time CreatedAt time.Time Owner *User Data []byte }
OAuthToken holds OAuth2 token information
type PullRequest ¶
PullRequest object
type PullRequestHook ¶
type PullRequestHook struct { Number int Merged bool // Commit SHA of source branch head Commit string Source string Target string }
PullRequestHook event
type PullRequestService ¶
type PullRequestService interface { Find(ctx context.Context, user *User, repo string, number int) (*PullRequest, error) CreateComment(ctx context.Context, user *User, repo string, number int, body string) (int, error) RemoveComment(ctx context.Context, user *User, repo string, number int, id int) error ListChanges(ctx context.Context, user *User, repo string, number int) ([]*FileChange, error) }
PullRequestService provides operation to repository issue, basically to pull request
type Repo ¶
type Repo struct { ID uint URL string ReportID string NameSpace string Name string Branch string Private bool SCM SCMProvider }
Repo defined a repository structure
type RepoService ¶
type RepoService interface { // Synchronize repositories data from remote and store to database Synchronize(ctx context.Context, user *User) error }
RepoService provides repository opperations
type RepoSetting ¶
type RepoSetting struct { Filters FileNameFilters `json:"filters"` MergePullRequest bool `json:"mergePR"` UpdateAction ReportUpdateAction `json:"updateAction"` // Protected project from unauthorized user upload report Protected bool `json:"protected"` }
RepoSetting to customize repository
type RepoStore ¶
type RepoStore interface { Create(repo *Repo) error Update(repo *Repo) error UpdateOrCreate(repo *Repo) error BatchUpdateOrCreate(repos []*Repo) error Find(repo *Repo) (*Repo, error) Finds(urls ...string) ([]*Repo, error) // Creator is the user activated the repository Creator(repo *Repo) (*User, error) UpdateCreator(repo *Repo, user *User) error Setting(repo *Repo) (*RepoSetting, error) UpdateSetting(repo *Repo, setting *RepoSetting) error FindHook(repo *Repo) (*Hook, error) UpdateHook(repo *Repo, hook *Hook) error }
RepoStore repository in storage
type Report ¶
type Report struct { Files []string `json:"files"` Coverages []*CoverageReport `json:"coverages"` ReportID string `json:"reportID"` Commit string `json:"commit"` Reference string `json:"reference"` CreatedAt time.Time `json:"createdAt"` }
Report defined the code report structure
func (*Report) Find ¶ added in v0.1.0
func (report *Report) Find(t ReportType) (*CoverageReport, bool)
Find coverage report of given type
func (*Report) StatementCoverage ¶ added in v0.1.0
StatementCoverage of the report
type ReportComment ¶
ReportComment in the pull request
type ReportService ¶
type ReportService interface { DiffReports(source, target *Report) (*CoverageReportDiff, error) MarkdownReport(source, target *Report) (io.Reader, error) MergeReport(from, to *Report, changes []*FileChange) (*Report, error) }
ReportService provides reports operations
type ReportStore ¶
type ReportStore interface { Upload(r *Report) error Find(r *Report) (*Report, error) Finds(r *Report) ([]*Report, error) // List reports with reference (commit, branch or tag) List(reportID, ref string) ([]*Report, error) CreateComment(r *Report, comment *ReportComment) error FindComment(r *Report, number int) (*ReportComment, error) }
ReportStore the report in storage
type ReportType ¶
type ReportType string
ReportType of the coverage. Normally using programing language as a type
const ( // ReportPerl language ReportPerl ReportType = "perl" // ReportGo language ReportGo ReportType = "go" // ReportPython language ReportPython ReportType = "python" // ReportRuby language ReportRuby ReportType = "ruby" // ReportLCOV of lcov report ReportLCOV ReportType = "lcov" // ReportClover of clover report ReportClover ReportType = "clover" )
type ReportUpdateAction ¶
type ReportUpdateAction string
ReportUpdateAction action type when new report update
const ( // ActionAutoMerge with previous report ActionAutoMerge ReportUpdateAction = "merge" // ActionAppend report to a new record ActionAppend ReportUpdateAction = "append" )
type SCMProvider ¶
type SCMProvider string
SCMProvider of Git service
const ( // Gitea SCM Gitea SCMProvider = "gitea" // Github SCM Github SCMProvider = "github" // GitLab SCM GitLab SCMProvider = "gitlab" )
type SCMService ¶
type SCMService interface {
Client(scm SCMProvider) (Client, error)
}
SCMService to interact with given SCM provider
type Session ¶
type Session interface { CreateUser(c *gin.Context, user *User) error GetUser(c *gin.Context) *User StartBindUser(c *gin.Context) error EndBindUser(c *gin.Context) error ShouldBindUser(c *gin.Context) bool Clear(c *gin.Context) error }
Session of user login for Gin
type StatementHit ¶
StatementHit records hit count for a single line
func (*StatementHit) Copy ¶
func (h *StatementHit) Copy() *StatementHit
Copy to a new StatementHit object
type User ¶
type User struct { Login string Email string Avatar string // Gitea GiteaLogin string GiteaEmail string GiteaToken string GiteaRefresh string GiteaExpire time.Time // GitLab GitLabLogin string GitLabEmail string GitLabToken string GitLabRefresh string GitLabExpire time.Time // Github GithubLogin string GithubEmail string GithubToken string GithubRefresh string GithubExpire time.Time }
User is a user of the service
type UserService ¶
type UserService interface { Find(ctx context.Context, token *Token) (*User, error) Create(ctx context.Context, token *Token) (*User, error) Update(ctx context.Context, token *Token) (*User, error) Bind(ctx context.Context, user *User, token *Token) (*User, error) }
UserService defines operations with SCM
type UserStore ¶
type UserStore interface { Create(scm SCMProvider, user *scm.User, token *Token) error Find(scm SCMProvider, user *scm.User) (*User, error) FindByLogin(login string) (*User, error) Update(scm SCMProvider, user *scm.User, token *Token) error // Bind a new user from another SCM to registered user Bind(scm SCMProvider, user *User, scmUser *scm.User, token *Token) (*User, error) ListRepositories(user *User) ([]*Repo, error) UpdateRepositories(user *User, repositories []*Repo) error }
UserStore the user data to storage