ci

package
v0.0.0-...-35a0bdf Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultContainerTimeout = time.Duration(10 * time.Minute)
)

Functions

This section is empty.

Types

type AssignmentInfo

type AssignmentInfo struct {
	AssignmentName     string
	BranchName         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
	BranchName string
	CommitID   string
	JobOwner   string
	Rebuild    bool
}

RunData stores CI data

func (RunData) RecordResults

func (r RunData) RecordResults(logger *zap.SugaredLogger, db database.Database, results *score.Results) (*pb.Submission, error)

RecordResults for the course and assignment given by the run data structure. If the results argument is nil, then the submission is considered to be a manual review.

func (RunData) RunTests

func (r RunData) RunTests(ctx context.Context, logger *zap.SugaredLogger, runner Runner) (*score.Results, error)

RunTests runs the assignment specified in the provided RunData structure.

func (RunData) String

func (r RunData) 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
y or Y : Canonical URL