Compare commits
4 Commits
4c490fc450
...
a79ea1905a
Author | SHA1 | Date | |
---|---|---|---|
a79ea1905a | |||
331876127a | |||
ee1262e983 | |||
e51a528838 |
2
.github/workflows/macos.yml
vendored
2
.github/workflows/macos.yml
vendored
@ -18,7 +18,7 @@ concurrency:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build
|
name: Build
|
||||||
runs-on: macOS-latest
|
runs-on: macOS-12
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
|
|
||||||
|
@ -56,6 +56,8 @@ type Job struct {
|
|||||||
RepoName string
|
RepoName string
|
||||||
Commit string
|
Commit string
|
||||||
|
|
||||||
|
Description string
|
||||||
|
|
||||||
Artifact artifact.Artifact
|
Artifact artifact.Artifact
|
||||||
Target distro.KernelInfo
|
Target distro.KernelInfo
|
||||||
|
|
||||||
|
@ -132,11 +132,15 @@ type Patch struct {
|
|||||||
|
|
||||||
// Artifact is for .out-of-tree.toml
|
// Artifact is for .out-of-tree.toml
|
||||||
type Artifact struct {
|
type Artifact struct {
|
||||||
Name string
|
Name string
|
||||||
Type ArtifactType
|
Type ArtifactType
|
||||||
TestFiles []FileTransfer
|
|
||||||
SourcePath string
|
SourcePath string
|
||||||
Targets []Target
|
SourceFiles []string
|
||||||
|
|
||||||
|
TestFiles []FileTransfer
|
||||||
|
|
||||||
|
Targets []Target
|
||||||
|
|
||||||
Script string
|
Script string
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -112,7 +113,11 @@ func Build(flog zerolog.Logger, tmp string, ka Artifact,
|
|||||||
|
|
||||||
outdir = tmp + "/source"
|
outdir = tmp + "/source"
|
||||||
|
|
||||||
err = copy.Copy(ka.SourcePath, outdir)
|
if len(ka.SourceFiles) == 0 {
|
||||||
|
err = copy.Copy(ka.SourcePath, outdir)
|
||||||
|
} else {
|
||||||
|
err = CopyFiles(ka.SourcePath, ka.SourceFiles, outdir)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -226,6 +231,35 @@ type Result struct {
|
|||||||
InternalErrorString string
|
InternalErrorString string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CopyFiles(path string, files []string, dest string) (err error) {
|
||||||
|
err = os.MkdirAll(dest, os.ModePerm)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, sf := range files {
|
||||||
|
if sf[0] == '/' {
|
||||||
|
err = CopyFile(sf, filepath.Join(dest, filepath.Base(sf)))
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
err = os.MkdirAll(filepath.Join(dest, filepath.Dir(sf)), os.ModePerm)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = CopyFile(filepath.Join(path, sf), filepath.Join(dest, sf))
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func CopyFile(sourcePath, destinationPath string) (err error) {
|
func CopyFile(sourcePath, destinationPath string) (err error) {
|
||||||
sourceFile, err := os.Open(sourcePath)
|
sourceFile, err := os.Open(sourcePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -92,6 +92,15 @@ func Load(localpath string, name string) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd = exec.Command(Runtime, "tag", "localhost/"+name, name)
|
||||||
|
log.Debug().Msgf("%v", cmd)
|
||||||
|
|
||||||
|
raw, err = cmd.CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
log.Debug().Err(err).Msg(string(raw))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ func createJobTable(db *sql.DB) (err error) {
|
|||||||
group_uuid TEXT,
|
group_uuid TEXT,
|
||||||
repo TEXT,
|
repo TEXT,
|
||||||
"commit" TEXT,
|
"commit" TEXT,
|
||||||
|
description TEXT,
|
||||||
config TEXT,
|
config TEXT,
|
||||||
target TEXT,
|
target TEXT,
|
||||||
created INT,
|
created INT,
|
||||||
@ -30,8 +31,8 @@ func createJobTable(db *sql.DB) (err error) {
|
|||||||
|
|
||||||
func AddJob(db *sql.DB, job *api.Job) (err error) {
|
func AddJob(db *sql.DB, job *api.Job) (err error) {
|
||||||
stmt, err := db.Prepare(`INSERT INTO job (updated, uuid, group_uuid, repo, "commit", ` +
|
stmt, err := db.Prepare(`INSERT INTO job (updated, uuid, group_uuid, repo, "commit", ` +
|
||||||
`config, target, created, started, finished) ` +
|
`description, config, target, created, started, finished) ` +
|
||||||
`VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);`)
|
`VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11);`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -53,7 +54,7 @@ func AddJob(db *sql.DB, job *api.Job) (err error) {
|
|||||||
target := tbuf.Bytes()
|
target := tbuf.Bytes()
|
||||||
|
|
||||||
res, err := stmt.Exec(time.Now().Unix(), job.UUID, job.Group,
|
res, err := stmt.Exec(time.Now().Unix(), job.UUID, job.Group,
|
||||||
job.RepoName, job.Commit, config, target,
|
job.RepoName, job.Commit, job.Description, config, target,
|
||||||
job.Created.Unix(), job.Started.Unix(),
|
job.Created.Unix(), job.Started.Unix(),
|
||||||
job.Finished.Unix(),
|
job.Finished.Unix(),
|
||||||
)
|
)
|
||||||
@ -68,10 +69,10 @@ func AddJob(db *sql.DB, job *api.Job) (err error) {
|
|||||||
func UpdateJob(db *sql.DB, job *api.Job) (err error) {
|
func UpdateJob(db *sql.DB, job *api.Job) (err error) {
|
||||||
stmt, err := db.Prepare(`UPDATE job ` +
|
stmt, err := db.Prepare(`UPDATE job ` +
|
||||||
`SET updated=$1, uuid=$2, group_uuid=$3, repo=$4, ` +
|
`SET updated=$1, uuid=$2, group_uuid=$3, repo=$4, ` +
|
||||||
`"commit"=$5, config=$6, target=$7, ` +
|
`"commit"=$5, description=$6, config=$7, target=$8, ` +
|
||||||
`created=$8, started=$9, finished=$10, ` +
|
`created=$9, started=$10, finished=$11, ` +
|
||||||
`status=$11 ` +
|
`status=$12 ` +
|
||||||
`WHERE id=$12`)
|
`WHERE id=$13`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -92,7 +93,7 @@ func UpdateJob(db *sql.DB, job *api.Job) (err error) {
|
|||||||
target := tbuf.Bytes()
|
target := tbuf.Bytes()
|
||||||
|
|
||||||
_, err = stmt.Exec(time.Now().Unix(), job.UUID, job.Group,
|
_, err = stmt.Exec(time.Now().Unix(), job.UUID, job.Group,
|
||||||
job.RepoName, job.Commit,
|
job.RepoName, job.Commit, job.Description,
|
||||||
config, target,
|
config, target,
|
||||||
job.Created.Unix(), job.Started.Unix(),
|
job.Created.Unix(), job.Started.Unix(),
|
||||||
job.Finished.Unix(), job.Status, job.ID)
|
job.Finished.Unix(), job.Status, job.ID)
|
||||||
@ -103,7 +104,8 @@ func scanJob(scan func(dest ...any) error) (job api.Job, err error) {
|
|||||||
var config, target []byte
|
var config, target []byte
|
||||||
var updated, created, started, finished int64
|
var updated, created, started, finished int64
|
||||||
err = scan(&job.ID, &updated, &job.UUID, &job.Group,
|
err = scan(&job.ID, &updated, &job.UUID, &job.Group,
|
||||||
&job.RepoName, &job.Commit, &config, &target,
|
&job.RepoName, &job.Commit, &job.Description,
|
||||||
|
&config, &target,
|
||||||
&created, &started, &finished, &job.Status)
|
&created, &started, &finished, &job.Status)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -130,7 +132,7 @@ func scanJob(scan func(dest ...any) error) (job api.Job, err error) {
|
|||||||
|
|
||||||
func Jobs(db *sql.DB, where string, args ...any) (jobs []api.Job, err error) {
|
func Jobs(db *sql.DB, where string, args ...any) (jobs []api.Job, err error) {
|
||||||
q := `SELECT id, updated, uuid, group_uuid, ` +
|
q := `SELECT id, updated, uuid, group_uuid, ` +
|
||||||
`repo, "commit", config, target, created, ` +
|
`repo, "commit", description, config, target, created, ` +
|
||||||
`started, finished, status FROM job`
|
`started, finished, status FROM job`
|
||||||
if len(where) != 0 {
|
if len(where) != 0 {
|
||||||
q += ` WHERE ` + where
|
q += ` WHERE ` + where
|
||||||
@ -163,7 +165,7 @@ func Jobs(db *sql.DB, where string, args ...any) (jobs []api.Job, err error) {
|
|||||||
func Job(db *sql.DB, uuid string) (job api.Job, err error) {
|
func Job(db *sql.DB, uuid string) (job api.Job, err error) {
|
||||||
stmt, err := db.Prepare(`SELECT id, updated, uuid, ` +
|
stmt, err := db.Prepare(`SELECT id, updated, uuid, ` +
|
||||||
`group_uuid, ` +
|
`group_uuid, ` +
|
||||||
`repo, "commit", config, target, ` +
|
`repo, "commit", description, config, target, ` +
|
||||||
`created, started, finished, status ` +
|
`created, started, finished, status ` +
|
||||||
`FROM job WHERE uuid=$1`)
|
`FROM job WHERE uuid=$1`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user