replay

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultWebhookSecret = "ghsync-replay-secret"
View Source
const RecordingVersion = 2

Variables

This section is empty.

Functions

func EncodeSteps

func EncodeSteps(writer io.Writer, steps []Step) error

func Write

func Write(writer io.Writer, recording Recording) error

Types

type Branch

type Branch struct {
	Ref        string `json:"ref"`
	SHA        string `json:"sha"`
	Repository string `json:"repository,omitempty"`
}

type CheckRun

type CheckRun struct {
	ID          int64      `json:"id"`
	NodeID      string     `json:"node_id"`
	HeadSHA     string     `json:"head_sha"`
	Name        string     `json:"name"`
	Status      string     `json:"status"`
	Conclusion  string     `json:"conclusion,omitempty"`
	DetailsURL  string     `json:"details_url"`
	AppSlug     string     `json:"app_slug,omitempty"`
	StartedAt   *time.Time `json:"started_at,omitempty"`
	CompletedAt *time.Time `json:"completed_at,omitempty"`
}

type CheckSuite

type CheckSuite struct {
	ID         int64     `json:"id"`
	NodeID     string    `json:"node_id"`
	HeadSHA    string    `json:"head_sha"`
	Status     string    `json:"status"`
	Conclusion string    `json:"conclusion,omitempty"`
	AppSlug    string    `json:"app_slug,omitempty"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
}

type Commit

type Commit struct {
	SHA               string    `json:"sha"`
	ParentSHA         string    `json:"parent_sha,omitempty"`
	Ref               string    `json:"ref"`
	CommittedAt       time.Time `json:"committed_at"`
	PullRequestNumber int       `json:"pull_request_number,omitempty"`
	DefaultBranch     bool      `json:"default_branch,omitempty"`
}

type CompileOptions

type CompileOptions struct {
	Speed         float64
	Copies        int
	Loop          bool
	WebhookSecret []byte
}

type Delivery

type Delivery struct {
	GUID      string          `json:"guid"`
	Event     string          `json:"event"`
	Action    string          `json:"action,omitempty"`
	Payload   json.RawMessage `json:"payload"`
	Signature string          `json:"signature"`
}

type Event

type Event struct {
	Seq          int64          `json:"seq"`
	AtMS         int64          `json:"at_ms"`
	Kind         string         `json:"kind"`
	Action       string         `json:"action,omitempty"`
	Repository   *Repository    `json:"repository,omitempty"`
	PullRequest  *PullRequest   `json:"pull_request,omitempty"`
	Review       *Review        `json:"review,omitempty"`
	IssueComment *IssueComment  `json:"issue_comment,omitempty"`
	Thread       *ReviewThread  `json:"review_thread,omitempty"`
	Comment      *ReviewComment `json:"review_comment,omitempty"`
	CheckSuite   *CheckSuite    `json:"check_suite,omitempty"`
	CheckRun     *CheckRun      `json:"check_run,omitempty"`
	Commit       *Commit        `json:"commit,omitempty"`
	Push         *Push          `json:"push,omitempty"`
	Stack        *Stack         `json:"stack,omitempty"`
	PreviousBase *Branch        `json:"previous_base,omitempty"`
}

func NormalizeEvents

func NormalizeEvents(events []TimedEvent) ([]Event, time.Time)

type FixtureMutation

type FixtureMutation struct {
	Kind          string         `json:"kind"`
	Action        string         `json:"action,omitempty"`
	Repository    Repository     `json:"repository"`
	PullRequest   *PullRequest   `json:"pull_request,omitempty"`
	Review        *Review        `json:"review,omitempty"`
	IssueComment  *IssueComment  `json:"issue_comment,omitempty"`
	ReviewThread  *ReviewThread  `json:"review_thread,omitempty"`
	ReviewComment *ReviewComment `json:"review_comment,omitempty"`
	CheckSuite    *CheckSuite    `json:"check_suite,omitempty"`
	CheckRun      *CheckRun      `json:"check_run,omitempty"`
	Commit        *Commit        `json:"commit,omitempty"`
	Push          *Push          `json:"push,omitempty"`
	Stack         *Stack         `json:"stack,omitempty"`
}
type Header struct {
	Type             string     `json:"type"`
	Version          int        `json:"version"`
	Repository       Repository `json:"repository"`
	Since            time.Time  `json:"since"`
	Until            time.Time  `json:"until"`
	StartedAt        time.Time  `json:"started_at"`
	SynthesizeStacks float64    `json:"synthesize_stacks_percent"`
	Seed             int64      `json:"seed"`
}

type IssueComment added in v0.3.0

type IssueComment struct {
	ID           int64     `json:"id"`
	NodeID       string    `json:"node_id"`
	AuthorKind   string    `json:"author_kind"`
	AuthorNodeID string    `json:"author_node_id,omitempty"`
	AuthorLogin  string    `json:"author_login,omitempty"`
	Body         string    `json:"body,omitempty"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

type Program

type Program struct {
	// contains filtered or unexported fields
}

func Compile

func Compile(recording Recording, options CompileOptions) (*Program, error)

func (*Program) NextLap

func (p *Program) NextLap() ([]Step, error)

type PullRequest

type PullRequest struct {
	ID             int64      `json:"id"`
	NodeID         string     `json:"node_id"`
	Number         int        `json:"number"`
	Title          string     `json:"title"`
	State          string     `json:"state"`
	Draft          bool       `json:"draft"`
	Merged         bool       `json:"merged"`
	AuthorLogin    string     `json:"author_login"`
	ReviewDecision string     `json:"review_decision,omitempty"`
	MergeableState string     `json:"mergeable_state,omitempty"`
	Head           Branch     `json:"head"`
	Base           Branch     `json:"base"`
	CreatedAt      time.Time  `json:"created_at"`
	UpdatedAt      time.Time  `json:"updated_at"`
	ClosedAt       *time.Time `json:"closed_at,omitempty"`
	MergedAt       *time.Time `json:"merged_at,omitempty"`
}

func SynthesizeStackBases

func SynthesizeStackBases(
	repository Repository,
	pulls []PullRequest,
	percent float64,
	seed int64,
) ([]PullRequest, map[int]bool)

type Push

type Push struct {
	Ref           string    `json:"ref"`
	Before        string    `json:"before"`
	After         string    `json:"after"`
	Forced        bool      `json:"forced,omitempty"`
	DefaultBranch bool      `json:"default_branch,omitempty"`
	PushedAt      time.Time `json:"pushed_at"`
}

type Recording

type Recording struct {
	Header Header
	Events []Event
}

func Read

func Read(reader io.Reader) (Recording, error)

type Repository

type Repository struct {
	ID               int64     `json:"id"`
	NodeID           string    `json:"node_id"`
	Owner            string    `json:"owner"`
	Name             string    `json:"name"`
	DefaultBranch    string    `json:"default_branch"`
	DefaultBranchSHA string    `json:"default_branch_sha"`
	UpdatedAt        time.Time `json:"updated_at"`
}

func (Repository) FullName

func (r Repository) FullName() string

type Review

type Review struct {
	ID           int64     `json:"id"`
	NodeID       string    `json:"node_id"`
	State        string    `json:"state"`
	Body         string    `json:"body,omitempty"`
	AuthorLogin  string    `json:"author_login"`
	AuthorKind   string    `json:"author_kind,omitempty"`
	AuthorNodeID string    `json:"author_node_id,omitempty"`
	CommitSHA    string    `json:"commit_sha,omitempty"`
	SubmittedAt  time.Time `json:"submitted_at"`
	UpdatedAt    time.Time `json:"updated_at,omitzero"`
}

type ReviewComment

type ReviewComment struct {
	ID          int64     `json:"id"`
	NodeID      string    `json:"node_id"`
	ReviewID    int64     `json:"review_id,omitempty"`
	Body        string    `json:"body,omitempty"`
	Path        string    `json:"path"`
	Line        *int      `json:"line,omitempty"`
	AuthorLogin string    `json:"author_login"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

type ReviewThread

type ReviewThread struct {
	ID         string          `json:"id"`
	IsResolved bool            `json:"is_resolved"`
	IsOutdated bool            `json:"is_outdated"`
	Path       string          `json:"path"`
	Line       *int            `json:"line,omitempty"`
	Comments   []ReviewComment `json:"comments"`
}

type Stack

type Stack struct {
	ID                int64         `json:"id"`
	Number            int           `json:"number"`
	Base              Branch        `json:"base"`
	PullRequests      []int         `json:"pull_requests"`
	PullRequestStates []PullRequest `json:"pull_request_states"`
	Synthetic         bool          `json:"synthetic,omitempty"`
}

func DeriveStacks

func DeriveStacks(repository Repository, pulls []PullRequest) []Stack

type Step

type Step struct {
	Seq        uint64          `json:"seq"`
	SourceSeq  int64           `json:"source_seq"`
	AtMS       int64           `json:"at_ms"`
	Copy       int             `json:"copy"`
	Lap        uint64          `json:"lap"`
	Mutation   FixtureMutation `json:"mutation"`
	Deliveries []Delivery      `json:"deliveries"`
}

func FirstLap

func FirstLap(recording Recording, options CompileOptions) ([]Step, error)

type TimedEvent

type TimedEvent struct {
	At        time.Time
	StableKey string
	Event     Event
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL