Documentation
¶
Overview ¶
Package githubactions provides a GitHub Actions API client implementing the external.TestRunner interface. It supports triggering workflow runs via repository_dispatch or workflow_dispatch events, polling run status, and retrieving workflow logs.
GitHub Actions API documentation: https://docs.github.com/en/rest/actions
Authentication uses a GitHub Personal Access Token (PAT) or GitHub App token. The token must have 'actions:read' and 'actions:write' permissions.
All API calls use exponential backoff retries for transient failures.
Index ¶
- type Client
- func (c *Client) Cancel(ctx context.Context, runID string) error
- func (c *Client) GetLogs(ctx context.Context, runID string) (string, error)
- func (c *Client) GetStatus(ctx context.Context, runID string) (external.TestStatus, error)
- func (c *Client) TriggerTest(ctx context.Context, config external.TestConfig) (*external.TestRun, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a GitHub Actions API client implementing external.TestRunner.
func NewClient ¶
func NewClient(config external.ProviderConfig) (*Client, error)
NewClient creates a new GitHub Actions client with the given configuration. The token should be a GitHub PAT or GitHub App token with actions permissions. Returns an error if the configuration is invalid.
func (*Client) Cancel ¶
Cancel attempts to cancel a running workflow run. The runID is expected in the format "owner:repo:runID" as returned by TriggerTest.
func (*Client) GetLogs ¶
GetLogs retrieves the logs for a workflow run. The runID is expected in the format "owner:repo:runID" as returned by TriggerTest. Note: GitHub Actions logs are returned as a zip archive. For simplicity, this implementation returns a URL to view logs in the web UI.
func (*Client) GetStatus ¶
GetStatus polls the status of a GitHub Actions workflow run. The runID is expected in the format "owner:repo:runID" as returned by TriggerTest. Returns the current workflow run status as a TestStatus.
func (*Client) TriggerTest ¶
func (c *Client) TriggerTest(ctx context.Context, config external.TestConfig) (*external.TestRun, error)
TriggerTest triggers a GitHub Actions workflow run via workflow_dispatch. The JobName should be either the workflow file name (e.g., "ci.yml") or workflow ID. Parameters are passed as workflow inputs. Must include "owner" and "repo" parameters. The Ref specifies which branch/tag/SHA to run the workflow against. Returns a TestRun with the workflow run ID and metadata. The runID is encoded as "owner:repo:runID" to include all necessary information.