Compare commits

..

4 Commits

Author SHA1 Message Date
restitux 3ae27bffc5 Cleanup logging 2023-02-24 23:00:31 -07:00
restitux 5373a37bee Change RUNID env var name 2023-02-24 23:00:26 -07:00
restitux 6fee5aa268 Record docker build output in database 2023-02-24 23:00:10 -07:00
restitux b475631df6 Remove outdated todo 2023-02-24 22:51:19 -07:00
3 changed files with 22 additions and 4 deletions
+1
View File
@@ -149,6 +149,7 @@ CREATE TABLE runs (
id UUID PRIMARY KEY,
pipeline UUID,
in_progress BOOLEAN DEFAULT NULL,
build_output TEXT DEFAULT NULL,
result BIGINT DEFAULT NULL,
stdout TEXT DEFAULT NULL,
stderr TEXT DEFAULT NULL,
+13 -1
View File
@@ -295,8 +295,20 @@ RETURNING id, pipeline, in_progress;`
return run, nil
}
func (db *Database) UpdateRunBuildOutput(runId uuid.UUID, buildResult string) error {
query := `
UPDATE runs
SET build_output=$1
WHERE id=$2;`
_, err := db.Conn.Exec(context.Background(),
query, buildResult, runId)
return err
}
func (db *Database) UpdateRunResult(r Run) error {
// TODO: the id fiend is the query is broken
query := `
UPDATE runs
SET in_progress=$1, result=$2, stdout=$3, stderr=$4
+8 -3
View File
@@ -146,7 +146,12 @@ func ExecutePipeline(pe PipelineExecution, db database.Database, pipelineConf co
log.Errorf("could no read build response: %w", err)
return
}
log.Debugf("build log: %v", string(response))
err = db.UpdateRunBuildOutput(pe.Run.Id, string(response))
if err != nil {
log.Errorf("could not update build output for run: %w", err)
return
}
err = buildResponse.Body.Close()
if err != nil {
@@ -154,7 +159,7 @@ func ExecutePipeline(pe PipelineExecution, db database.Database, pipelineConf co
return
}
log.Info("Image built sucessfully sucessfully")
log.Info("Image built sucessfully")
hostConfig := container.HostConfig{}
@@ -190,7 +195,7 @@ func ExecutePipeline(pe PipelineExecution, db database.Database, pipelineConf co
// set cursorius environment variables
env = append(env, []string{
fmt.Sprintf("RUNID=%v", pe.Run.Id),
fmt.Sprintf("CURSORIUS_RUN_ID=%v", pe.Run.Id),
"CURSORIUS_SRC_DIR=/cursorius/src",
fmt.Sprintf("CURSORIUS_SERVER_URL=%v", pipelineConf.AccessURL),
}...)