Documentation
¶
Index ¶
- Variables
- func EnvVars(sessionSecret, home, repoName, currentAssignment string) []string
- func TestExecutionMetricsCollectors() []prometheus.Collector
- type Docker
- type Job
- type Local
- type RunData
- func (r *RunData) GetOwners(db database.Database) ([]uint64, error)
- func (r *RunData) RecordResults(logger *zap.SugaredLogger, db database.Database, results *score.Results) (*qf.Submission, error)
- func (r *RunData) RunTests(ctx context.Context, logger *zap.SugaredLogger, sc scm.SCM, runner Runner) (*score.Results, error)
- func (r RunData) String() string
- type Runner
Constants ¶
This section is empty.
Variables ¶
var ( DefaultContainerTimeout = time.Duration(10 * time.Minute) QuickFeedPath = "/quickfeed" GoModCache = "/quickfeed-go-mod-cache" )
var ErrConflict = fmt.Errorf("submission is already being built, please wait")
Functions ¶
func TestExecutionMetricsCollectors ¶
func TestExecutionMetricsCollectors() []prometheus.Collector
TestExecutionMetricsCollectors returns a list of Prometheus metrics collectors for test execution.
Types ¶
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.SugaredLogger) (*Docker, error)
NewDockerCI returns a runner to run CI tests.
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. // If empty, the image is assumed to exist. // If non-empty, the image is built from this Dockerfile. Dockerfile string // BindDir is the directory to bind to the container's /quickfeed directory. BindDir string // Env is a list of environment variables to set for the job. Env []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.
type RunData ¶
type RunData struct { Course *qf.Course Assignment *qf.Assignment Repo *qf.Repository EnvVarsFn func(secret, homeDir string) []string BranchName string CommitID string JobOwner string Rebuild bool }
RunData stores CI data
func (*RunData) GetOwners ¶
GetOwners returns the UserIDs of a user or group repository's owners. Returns an error if no owners could be found. This method should only be called for a user or group repository.
func (*RunData) RecordResults ¶
func (r *RunData) RecordResults(logger *zap.SugaredLogger, db database.Database, results *score.Results) (*qf.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, sc scm.SCM, runner Runner) (*score.Results, error)
RunTests runs the tests for the assignment specified in the provided RunData structure, and returns the score results or an error. The method is idempotent and can be called concurrently on multiple RunData objects. The method clones the student or group repository from GitHub as specified in RunData, and copies the course's tests and assignment repositories from the host machine's file system. runs the tests and returns the score results.
The os.MkdirTemp() function ensures that any concurrent calls to this method will always use distinct temp directories. Specifically, the method creates a temporary directory on the host machine running the quickfeed server that holds the cloned/copied repositories and will be mounted as '/quickfeed' inside the container. This allows the docker container to run the tests on the student code and manipulate the folders as needed for a particular lab assignment's test requirements. The temporary directory is deleted when the container exits at the end of this method.