teeth

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

README

Teeth Package

This package contains a job that reads leech and pull request event records from BigQuery and publishes available log invocations in a PR comment.

Purpose

To provide automated feedback on pull requests by posting links to logs or status information derived from event processing.

Subdirectories

  • sql: Contains the SQL templates used by this package.

Files

  • bigquery.go: Implements the BigQuery client for this package, embedding the SQL query from sql/publisher_source.sql and handling execution and data insertion.
  • bigquery_test.go: Unit tests for the BigQuery interaction logic.
  • publish_logs.go: Defines the core interfaces and high-level logic for retrieving records to process and saving the results.

Design Patterns

  • Embedded SQL: Uses Go's //go:embed directive to include SQL files at compile time, keeping complex queries out of Go source files while avoiding runtime file loading issues.
  • Template Queries: Uses text/template to dynamically inject table names into the embedded SQL query based on configuration.

Documentation

Overview

Package teeth contains a job that will read leech and pull request event records from BigQuery and publish any available log invocations in a PR comment.

Index

Constants

This section is empty.

Variables

View Source
var PublisherSourceQuery string

PublisherSourceQuery is the source query that teeth job pipeline will use to publish results.

Functions

func SaveInvocationCommentStatus added in v0.0.16

func SaveInvocationCommentStatus(ctx context.Context, bqClient BigQueryClient, statuses []*InvocationCommentStatusRecord) error

SaveInvocationCommentStatus inserts the statuses into the InvocationCommentStatus table.

Types

type BQConfig

type BQConfig struct {
	ProjectID string
	DatasetID string

	PullRequestEventsTable       string
	InvocationCommentStatusTable string
	EventsTable                  string
	LeechStatusTable             string
}

TODO: Add query limit param.

BQConfig defines configuration parameters for the BigQuery client and the tables used by the teeth job pipeline.

type BigQuery added in v0.0.16

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

BigQuery provides a client to BigQuery API.

func NewBigQuery added in v0.0.16

func NewBigQuery(ctx context.Context, config *BQConfig) (*BigQuery, error)

NewBigQuery creates a new instance of a BigQuery client with config.

func (*BigQuery) Close added in v0.0.16

func (bq *BigQuery) Close() error

Close closes the BigQuery client.

func (*BigQuery) Insert added in v0.0.16

func (bq *BigQuery) Insert(ctx context.Context, statuses []*InvocationCommentStatusRecord) error

Insert writes statuses to the InvocationCommentStatusTable.

func (*BigQuery) QueryLatest added in v0.0.16

func (bq *BigQuery) QueryLatest(ctx context.Context) ([]*PublisherSourceRecord, error)

QueryLatest executes the source query for the latest PublisherSourceRecords to process.

type BigQueryClient

type BigQueryClient interface {
	QueryLatest(context.Context) ([]*PublisherSourceRecord, error)
	Insert(context.Context, []*InvocationCommentStatusRecord) error
}

BigQueryClient defines the spec for calls to read from and write to BigQuery tables.

type InvocationCommentStatusRecord

type InvocationCommentStatusRecord struct {
	PullRequestID  int                `bigquery:"pull_request_id"`
	PullRequestURL string             `bigquery:"pull_request_html_url"`
	ProcessedAt    time.Time          `bigquery:"processed_at"`
	CommentID      bigquery.NullInt64 `bigquery:"comment_id"`
	Status         string             `bigquery:"status"`
	JobName        string             `bigquery:"job_name"`
}

InvocationCommentStatusRecord is the output data structure that maps to the teeth pipeline's output table schema for invocation comment statuses.

type PublisherSourceRecord

type PublisherSourceRecord struct {
	DeliveryID     string    `bigquery:"delivery_id"`
	PullRequestID  int       `bigquery:"pull_request_id"`
	PullRequestURL string    `bigquery:"pull_request_html_url"`
	Received       time.Time `bigquery:"received"`
	LogsURI        string    `bigquery:"logs_uri"`
	HeadSHA        string    `bigquery:"head_sha"`
}

PublisherSourceRecord maps the columns from the source query to a struct.

func GetLatestSourceRecords added in v0.0.16

func GetLatestSourceRecords(ctx context.Context, bqClient BigQueryClient) ([]*PublisherSourceRecord, error)

GetLatestSourceRecords gets the latest publisher source records.

Jump to

Keyboard shortcuts

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