Documentation
¶
Overview ¶
Package forge applies what reaches a forge — comments, labels, issues, releases — on GitHub, GitLab, or a simulated forge for the tests. Every write is idempotent, so a run interrupted half-way can be resumed.
Index ¶
- Variables
- func Marker(key string) string
- type Fake
- func (f *Fake) Comment(t Target, body, marker string) error
- func (f *Fake) Issue(id int) (*Issue, error)
- func (f *Fake) KeepIssue(title, body string, create bool) (int, error)
- func (f *Fake) Label(t Target, add, remove []string) error
- func (f *Fake) MergeRequestBranch(id int) (string, bool, error)
- func (f *Fake) OpenIssue(title, body, marker string) (int, error)
- func (f *Fake) OpenMergeRequest(branch, base, title, body string) (int, error)
- func (f *Fake) OpenMergeRequests(prefix string) ([]string, error)
- func (f *Fake) Release(tag, notes string) error
- func (f *Fake) Sticky(t Target, body, marker string, create bool) error
- type FakeItem
- type FakeRel
- type FakeState
- type Forge
- type Issue
- type Target
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrUnreachable = errors.New("forge unreachable")
ErrUnreachable marks a forge that did not answer: the run is blocked by something outside the role.
Functions ¶
Types ¶
type Fake ¶
type Fake struct{ Path string }
Fake is a forge kept in a JSON file, shared between processes, for the conformance tests. It can be told to fail its N-th write, once.
func (*Fake) OpenMergeRequest ¶
type FakeItem ¶
type FakeItem struct {
ID int `json:"id"`
Branch string `json:"branch,omitempty"` // a merge request's source branch
Base string `json:"base,omitempty"`
Closed bool `json:"closed,omitempty"`
Fork bool `json:"fork,omitempty"` // a merge request from a fork
Title string `json:"title,omitempty"`
Body string `json:"body,omitempty"`
Labels []string `json:"labels"`
Comments []string `json:"comments"`
}
FakeItem is an issue or a merge request.
type FakeState ¶
type FakeState struct {
Issues []FakeItem `json:"issues"`
MergeRequests []FakeItem `json:"merge-requests"`
Releases []FakeRel `json:"releases"`
FailOnWrite int `json:"fail-on-write,omitempty"` // the write that fails, counting from 1
Writes int `json:"writes"`
}
FakeState is the file's content.
type Forge ¶
type Forge interface {
Issue(id int) (*Issue, error)
// Comment posts body on t unless a comment carrying marker is already there.
Comment(t Target, body, marker string) error
// Sticky keeps one comment carrying marker on t, edited to body on each
// run instead of a new one each time; with create false, it only edits
// one already there.
Sticky(t Target, body, marker string, create bool) error
// Label adds and removes labels; adding one already there changes nothing.
Label(t Target, add, remove []string) error
// OpenIssue creates an issue, or comments on an open one with the same title.
OpenIssue(title, body, marker string) (int, error)
// KeepIssue rewrites the body of the open issue with this title, or opens
// it when there is none and create is true: one issue, kept in place.
KeepIssue(title, body string, create bool) (int, error)
// Release publishes notes for an existing tag, unless already published.
Release(tag, notes string) error
// OpenMergeRequest opens a merge request from branch into base, or
// updates the title and body of the one already open from branch.
OpenMergeRequest(branch, base, title, body string) (int, error)
// OpenMergeRequests lists the branches of the open merge requests whose
// branch starts with prefix, sorted.
OpenMergeRequests(prefix string) ([]string, error)
// MergeRequestBranch is the branch a merge request comes from, and
// whether it lives in this repository (not in a fork).
MergeRequestBranch(id int) (branch string, here bool, err error)
}
Forge is what the engine needs from one.
Click to show internal directories.
Click to hide internal directories.