ciutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package ciutil provides core types, helper functions, etc. for running CI tasks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitSystem

func InitSystem() error

InitSystem runs setup & checks against the host itself, so that oscar can run.

func RunCommand

func RunCommand(cmdArgs []string) error

RunCommand takes a string slice containing an entire command & its args to run, and returns a consisten error message in case of failure.

func RunDurationString

func RunDurationString(t time.Time) string

RunDurationString returns a calculated duration used to indicate how long a particular task took to run.

Types

type HostInfo

type HostInfo struct {
	OS     string
	Arch   string
	Kernel string
}

HostInfo holds the final host information values to be used in e.g. release downloads of a tool.

func GetHostInfo

func GetHostInfo(i HostInfoInput) (HostInfo, error)

GetHostInfo returns a populated HostInfo, based on the provided HostInfoInput mappings.

type HostInfoInput

type HostInfoInput struct {
	// The name a tool uses for Linux OSes (e.g. "linux", "unknown", etc.)
	OSLinux string
	// The name a tool uses for the Linux kernel (e.g. "linux", "linux-gnu", etc.)
	KernelLinux string
	// The name a tool uses for macOS (e.g. "apple")
	OSMacOS string
	// The name a tool uses for the macOS kernel (e.g. "darwin")
	KernelMacOS string
	// The name a tool uses for AMD64 architectures (e.g. "x86_64", "amd64", etc.)
	ArchAMD64 string
	// The name a tool uses for ARM64 architectures (e.g. "aarch64", "arm64", etc.)
	ArchARM64 string
}

HostInfoInput allows different tools to specify the different possible values for their host-related information. This is primarily used when downloading a release artifact. This is necessary to provide because different tools use different values for their host info. For example:

  • Some tools use "x86_64" for CPU architecture, while some use "amd64", and others even use "x64"
  • In addition to a kernel ID, some tools additionally specify an OS value (e.g. both "darwin" and "macos")

type Repo

type Repo struct {
	HasGo       bool
	HasPython   bool
	HasShell    bool
	HasMarkdown bool
}

Repo stores information about the contents of the repository being ran against.

func GetRepoComposition

func GetRepoComposition() (Repo, error)

GetRepoComposition returns a populated Repo.

func (Repo) String

func (repo Repo) String() string

String implements the fmt.Stringer interface.

type Tasker

type Tasker interface {
	// InfoText should return a human-readable display string that describes the task, e.g. "Run
	// tests". If this is unset, then its banner will not show in the CI log output at all (which
	// may be desirable) in the case of implementers of [Tasker.Init])
	InfoText() string
	// Run should perform the actual task's actions.
	Run() error
	// Post should perform any post-run actions for the task, if necessary.
	Post() error
}

Tasker defines the method set for working with metadata for a given CI Task.

type Tool

type Tool struct {
	// The tool's name, used as an identifier. May also be the tool's invocable command, in which
	// case it can be interpolated as such.
	Name string
	// The installable path for the tool, like a URL. Can also be a format string, e.g. with
	// placeholders for platform-specific strings.
	RemotePath string
	// The version of the tool.
	Version string
	// The path to the tool's config file, if it has one to use.
	ConfigFilePath string
}

A Tool is a helper struct used to help other types implementing Tasker pass around their tool versioning/installation information.

Jump to

Keyboard shortcuts

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