watchdog

package module
v0.0.0-...-62a7986 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2020 License: MIT Imports: 14 Imported by: 0

README

Watchdog for self-hosted build VMs that serve GitHub Actions

This program starts any sleeping build agent VMs that are needed by the GitHub Actions scripts currently running in the given repo, and stops any running build agents that aren't needed.

Installation

Install this program as a Google Cloud Function.

Define the following environment variables:

  • GOOGLE_CLOUD_PROJECT - project ID for a Google Cloud Platform project that contains the build agent VMs
  • GCE_ZONE - zone where the build agent VMs reside
  • GITHUB_ORGANIZATION - GitHub organization containing the game project
  • GITHUB_REPOSITORY - GitHub project containing the game project
  • GITHUB_PAT - Personal Access Token that allows querying the GitHub Actions REST API for the game project, and downloading files from the game project repository

Local development

  • Set all the environment variables manually, plus PORT to something unique.
  • cd cmd && go build . && cmd
  • Use curl http://localhost:<PORT> in a different window to trigger a run of the program.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Process

func Process(ctx context.Context, computeService *compute.Service, httpClient *http.Client, gitHubClient *github.Client, project string, zone string, gitHubOrganization string, gitHubRepository string) ([]string, []OnDemandInstance, []OnDemandInstance, []OnDemandInstance, error)

func RunWatchdog

func RunWatchdog(w http.ResponseWriter, r *http.Request)

Types

type GitHubWorkflowYamlJob

type GitHubWorkflowYamlJob struct {
	Name   string `yaml:"name"`
	RunsOn RunsOn `yaml:"runs-on"`
}

type GitHubWorkflowYamlJobs

type GitHubWorkflowYamlJobs struct {
	Jobs map[string]GitHubWorkflowYamlJob `yaml:"jobs"`
}

type LogMessage

type LogMessage struct {
	Message  string `json:"message"`
	Severity string `json:"severity"`
}

type OnDemandInstance

type OnDemandInstance struct {
	InstanceName string `json:"instance_name"`
	RunnerName   string `json:"runner_name"`
	GitHubScope  string `json:"github_scope"`
	Status       string `json:"status"`
}

type Result

type Result struct {
	RunnersRequired   []string           `json:"runners_required"`
	OnDemandInstances []OnDemandInstance `json:"on_demand_instances"`
	StartedInstances  []OnDemandInstance `json:"started_instances"`
	StoppedInstances  []OnDemandInstance `json:"stopped_instances"`
}

type RunsOn

type RunsOn []string

func (*RunsOn) UnmarshalYAML

func (runsOn *RunsOn) UnmarshalYAML(unmarshal func(interface{}) error) error

Implements the Unmarshaler interface of the yaml pkg.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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