ci

package
Version: v0.0.0-...-c8a281e Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunTests

func RunTests(logger *zap.SugaredLogger, db database.Database, runner Runner, rData *RunData)

RunTests runs the assignment specified in the provided RunData structure.

Types

type AssignmentInfo

type AssignmentInfo struct {
	AssignmentName     string
	Script             string
	CreatorAccessToken string
	GetURL             string
	TestURL            string
	RandomSecret       string
}

AssignmentInfo holds metadata needed to fetch student code and the test repository for an assignment.

type Docker

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

Docker is an implementation of the CI interface using Docker.

func NewDockerCI

func NewDockerCI(logger *zap.Logger) (*Docker, error)

NewDockerCI returns a runner to run CI tests.

func (*Docker) Close

func (d *Docker) Close() error

Close ensures that the docker client is closed.

func (*Docker) Run

func (d *Docker) Run(ctx context.Context, job *Job) (string, error)

Run implements the CI interface. This method blocks until the job has been completed or an error occurs, e.g., the context times out.

type Job

type Job struct {
	// Name describes the running job; mainly used to name docker containers.
	Name string
	// Image names the image to use to run the job.
	Image string
	// Dockerfile contents
	Dockerfile string
	// Commands is a list of shell commands to run as part of the job.
	Commands []string
}

Job describes how to execute a CI job.

type Local

type Local struct{}

Local is an implementation of the CI interface executing code locally.

func (*Local) Run

func (l *Local) Run(ctx context.Context, job *Job) (string, error)

Run implements the CI interface. This method blocks until the job has been completed or an error occurs, e.g., the context times out.

type RunData

type RunData struct {
	Course     *pb.Course
	Assignment *pb.Assignment
	Repo       *pb.Repository
	CommitID   string
	JobOwner   string
	Rebuild    bool
}

RunData stores CI data

func (RunData) String

func (r RunData) String(secret string) string

String returns a string representation of the run data structure

type Runner

type Runner interface {
	// Run should synchronously execute the described job and return the output.
	Run(context.Context, *Job) (string, error)
}

Runner contains methods for running user provided code in isolation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL