check

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package check provides utilities for creating and updating GitHub Check Runs.

Use NewBuilder to construct a check run result incrementally. Write formatted output with Builder.Writef, set the [Builder.Status] and [Builder.Conclusion] fields, then call Builder.CheckRunCreate or Builder.CheckRunUpdate to produce the GitHub API options struct.

Output is automatically truncated to GitHub's maximum check run output length of 65536 bytes.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	Summary    string
	Status     Status
	Conclusion Conclusion
	// contains filtered or unexported fields
}

func NewBuilder

func NewBuilder(name, headSHA string) *Builder
Example
package main

import (
	"fmt"

	"github.com/chainguard-dev/terraform-infra-common/modules/github-bots/sdk/check"
)

func main() {
	b := check.NewBuilder("my-check", "abc123")
	b.Status = check.StatusInProgress
	b.Writef("Running checks...")

	cr := b.CheckRunCreate()
	fmt.Println(cr.Name)
	fmt.Println(cr.GetStatus())
}
Output:
my-check
in_progress

func (*Builder) CheckRunCreate

func (b *Builder) CheckRunCreate() *github.CreateCheckRunOptions

CheckRun returns a GitHub CheckRun object with the current state of the Builder.

If the Summary field is empty, it will be set to the name field. If the Conclusion field is set, the CheckRun will be marked as completed.

Example
package main

import (
	"fmt"

	"github.com/chainguard-dev/terraform-infra-common/modules/github-bots/sdk/check"
)

func main() {
	b := check.NewBuilder("my-check", "abc123")
	b.Conclusion = check.ConclusionSuccess
	b.Summary = "All checks passed"

	cr := b.CheckRunCreate()
	fmt.Println(cr.GetStatus())
	fmt.Println(cr.GetConclusion())
}
Output:
completed
success

func (*Builder) CheckRunUpdate

func (b *Builder) CheckRunUpdate() *github.UpdateCheckRunOptions
Example
package main

import (
	"fmt"

	"github.com/chainguard-dev/terraform-infra-common/modules/github-bots/sdk/check"
)

func main() {
	b := check.NewBuilder("my-check", "abc123")
	b.Conclusion = check.ConclusionFailure

	u := b.CheckRunUpdate()
	fmt.Println(u.GetConclusion())
}
Output:
failure

func (*Builder) Writef

func (b *Builder) Writef(format string, args ...any)

Writef appends a formatted string to the CheckRun output.

If the output exceeds the maximum length, it will be truncated and a message will be appended.

Example
package main

import (
	"fmt"

	"github.com/chainguard-dev/terraform-infra-common/modules/github-bots/sdk/check"
)

func main() {
	b := check.NewBuilder("my-check", "abc123")
	b.Writef("step %d: %s", 1, "passed")
	b.Writef("step %d: %s", 2, "passed")

	cr := b.CheckRunCreate()
	fmt.Print(cr.GetOutput().GetText())
}
Output:
step 1: passed
step 2: passed

type Conclusion

type Conclusion string
const (
	ConclusionActionRequired Conclusion = "action_required"
	ConclusionCancelled      Conclusion = "cancelled"
	ConclusionFailure        Conclusion = "failure"
	// ConclusionNeutral is the default, and is sufficient to pass a required check.
	ConclusionNeutral  Conclusion = "neutral"
	ConclusionSuccess  Conclusion = "success"
	ConclusionTimedOut Conclusion = "timed_out"
	// ConclusionSkipped is not sufficient to pass a required check.
	ConclusionSkipped Conclusion = "skipped"
)

type Status

type Status string
const (
	StatusQueued     Status = "queued"
	StatusInProgress Status = "in_progress"
	StatusCompleted  Status = "completed"
	StatusWaiting    Status = "waiting"
	StatusRequested  Status = "requested"
	StatusPending    Status = "pending"
)

Jump to

Keyboard shortcuts

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