circleci

package
v0.4.13 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package circleci implements the CircleCI v2 API connector. It populates `builds` and `build_jobs` for repos configured in xray.toml.

Project mapping: the connector reads [connectors.circleci.projects] — a map of CircleCI project slug ("gh/<owner>/<name>") to GitHub repo slug, the same pattern as the sentry and bugsnag connectors. The map is required; omitting it is a validation error.

Simplifications versus the spec:

  • CircleCI does not classify pipeline triggers as cleanly as GitHub Actions does. Every emitted Build sets Event="push".
  • CircleCI's rerun model is more granular than the canonical (Attempt, RerunOfID) pair; the connector emits Attempt=1 and RerunOfID="" rather than synthesise misleading lineage.
  • PRNumber is left nil; recovering it requires correlating webhook payloads not exposed by the public v2 endpoints used here.
  • Job DurationSeconds is computed from started_at/stopped_at on the workflow job summary when both are present; otherwise nil. The connector deliberately does not fan out to per-job detail to avoid a request-per-job multiplier.

Index

Constants

View Source
const DefaultBaseURL = "https://circleci.com/api/v2"

DefaultBaseURL is the CircleCI v2 API base URL.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Token   string
	BaseURL string
}

Config is the connector's input. BaseURL is exposed only for tests.

type Connector

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

Connector implements connector.Connector against CircleCI v2.

func New

func New(cfg config.CircleCIConn, log *slog.Logger) (*Connector, error)

New builds a Connector wired to the rate-limit transport. It is an error to construct a Connector without a token; the token is the only authentication CircleCI v2 exposes for these endpoints.

func (*Connector) BudgetSnapshot added in v0.4.4

func (c *Connector) BudgetSnapshot() map[string]ratelimit.BudgetState

BudgetSnapshot returns the current rate-limit budget for this connector.

func (*Connector) Extract

Extract pulls workflows + jobs for the configured repo within window and emits canonical Build / BuildJob rows via the typed sink. A repo whose project_slug is inaccessible to the token is recorded in Provenance.Endpoints rather than producing a hard error — per spec, inaccessible-vs-absent is a meaningful distinction.

func (*Connector) Name

func (c *Connector) Name() string

Name returns the stable connector name used in `source` columns and the manifest's `extraction_provenance` entries.

func (*Connector) Ping

func (c *Connector) Ping(ctx context.Context) error

Ping verifies the configured token by calling GET /me. 401 is a fatal authentication failure; other non-2xx responses are surfaced verbatim so the caller can log the upstream status.

Jump to

Keyboard shortcuts

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