fireactions

package module
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

test

Banner

Fireactions is an orchestrator for GitHub runners. BYOM (Bring Your Own Metal) and run self-hosted GitHub runners in ephemeral, fast and secure Firecracker based virtual machines.

Architecture

Several key features:

  • Autoscaling

    Robust pool based scaling, cost-effective with fast GitHub runner startup time of 20s~.

  • Ephemeral

    Each virtual machine is created from scratch and destroyed after the job is finished, no state is preserved between jobs, just like with GitHub hosted runners.

  • Customizable

    Define job labels and customize virtual machine resources to fit Your needs. See Configuration for more information.

Quickstart

  1. Create and install a GitHub App (see Creating a GitHub App) with the following permissions:

    • Read access to metadata
    • Read and write access to actions and organization self hosted runners
  2. Note down the GitHub App ID and generate a private key, save it to a file on the host machine, e.g. /root/private-key.pem.

  3. Download and run the installation script:

    curl -sSL https://raw.githubusercontent.com/hostinger/fireactions/main/install.sh -o install.sh
    chmod +x install.sh
    ./install.sh \
      --github-app-id=<GITHUB_APP_ID> \
      --github-app-key-file="/root/private-key.pem" \
      --github-organization="<GITHUB_ORGANIZATION>"
      --containerd-snapshotter-device="<DEVICE>"
    

This creates a default configuration with a single pool named default with a single runner. See Configuration for more information.

  1. Test the installation by creating a new GitHub workflow in your repository:
# .github/workflows/test.yaml
name: test

on:
  workflow_dispatch:
  pull_request:
      branches:
      - '*'
  push:
      branches:
      - main

jobs:
  test:
    name: test
    runs-on: # The label(s) of the Fireactions pool
    - self-hosted
    - fireactions
    steps:
    - name: Example
      run: |
        echo "Hello, Fireactions!"

Contributing

See CONTRIBUTING.md for more information on how to contribute to Fireactions.

License

See LICENSE

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version is the version of the Fireactions.
	Version = "0.0.0"

	// Date is the date when the binary was built.
	Date = "1970-01-01T00:00:00Z"

	// Commit is the Git SHA of the commit that was built.
	Commit = ""
)
View Source
var (
	// ErrPoolNotFound is returned when a pool is not found
	ErrPoolNotFound = errors.New("pool not found")
)

Functions

func String

func String() string

String returns a string representation of the Fireactions version.

Types

type Client

type Client struct {

	// Endpoint is the Fireactions API endpoint.
	Endpoint string

	// UserAgent is the User-Agent header to send when communicating with the
	// Fireactions API.
	UserAgent string

	// Username is the username to use when authenticating with the Fireactions API
	Username string

	// Password is the password to use when authenticating with the Fireactions API
	Password string
	// contains filtered or unexported fields
}

Client is a client for the Fireactions API.

func NewClient

func NewClient(opts ...ClientOpt) *Client

NewClient returns a new Client

func (*Client) GetPool

func (c *Client) GetPool(ctx context.Context, id string) (*Pool, *Response, error)

GetPool returns a pool by ID.

func (*Client) ListPools

func (c *Client) ListPools(ctx context.Context, opts *ListOptions) (Pools, *Response, error)

ListPools returns a list of pools.

func (*Client) PausePool

func (c *Client) PausePool(ctx context.Context, id string) (*Response, error)

PausePool pauses a pool by ID.

func (*Client) Reload added in v0.2.4

func (c *Client) Reload(ctx context.Context) (*Response, error)

Reload reloads the Fireactions server.

func (*Client) ResumePool

func (c *Client) ResumePool(ctx context.Context, id string) (*Response, error)

ResumePool resumes a pool by ID.

func (*Client) ScalePool

func (c *Client) ScalePool(ctx context.Context, id string) (*Response, error)

ScalePool scales a pool by ID.

type ClientOpt

type ClientOpt func(*Client)

ClientOpt is an option for a new Fireactions client.

func WithEndpoint

func WithEndpoint(endpoint string) ClientOpt

WithEndpoint returns a ClientOpt that specifies the Fireactions API endpoint to use when making requests to the Fireactions API.

func WithHTTPClient

func WithHTTPClient(client *http.Client) ClientOpt

WithHTTPClient returns a ClientOpt that specifies the HTTP client to use when making requests to the Fireactions API.

func WithPassword

func WithPassword(password string) ClientOpt

WithPassword returns a ClientOpt that specifies the password to use when authenticating with the Fireactions API.

func WithUserAgent

func WithUserAgent(userAgent string) ClientOpt

WithUserAgent returns a ClientOpt that specifies the User-Agent header to use when making requests to the Fireactions API.

func WithUsername

func WithUsername(username string) ClientOpt

WithUsername returns a ClientOpt that specifies the username to use when authenticating with the Fireactions API.

type Error

type Error struct {
	Message string `json:"error"`
}

Error represents an error returned by the Fireactions API.

func (*Error) Error

func (e *Error) Error() string

Error returns the error message. Implements the error interface.

type ListOptions

type ListOptions struct {
	Page    int
	PerPage int
}

ListOptions specifies the optional parameters to various List methods that support pagination.

func (*ListOptions) Apply

func (o *ListOptions) Apply(req *http.Request)

Apply modifies the request to include the optional pagination parameters.

type Pool

type Pool struct {
	Name       string     `json:"name"`
	MaxRunners int        `json:"max_runners"`
	MinRunners int        `json:"min_runners"`
	CurRunners int        `json:"cur_runners"`
	Status     PoolStatus `json:"status"`
}

Pool represents a pool of GitHub runners

func (*Pool) Cols

func (p *Pool) Cols() []string

func (*Pool) ColsMap

func (p *Pool) ColsMap() map[string]string

func (*Pool) KV

func (p *Pool) KV() []map[string]interface{}

type PoolState

type PoolState string

PoolState represents the state of a pool

const (
	// PoolStateActive represents the active state, meaning the pool is running
	PoolStateActive PoolState = "Active"

	// PoolStatePaused represents the paused state, meaning the pool is stopped
	PoolStatePaused PoolState = "Paused"
)

func (PoolState) String

func (p PoolState) String() string

String returns the string representation of the pool state

type PoolStatus

type PoolStatus struct {
	State   PoolState `json:"state"`
	Message string    `json:"message"`
}

PoolStatus represents the status of a pool

type Pools

type Pools []*Pool

Pool represents a slice of Pool

func (Pools) Cols

func (p Pools) Cols() []string

func (Pools) ColsMap

func (p Pools) ColsMap() map[string]string

func (Pools) KV

func (p Pools) KV() []map[string]interface{}

type Response

type Response struct {
	*http.Response
}

Response wraps an HTTP response.

func (*Response) HasNextPage

func (r *Response) HasNextPage() bool

HasNextPage returns true if the response has a next page.

func (*Response) NextPage

func (r *Response) NextPage() (string, error)

NextPage returns the next page URL.

Directories

Path Synopsis
cmd
fireactions command
helper

Jump to

Keyboard shortcuts

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