Skip to content
Closed
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
aad77ed
test report execution logic
Apr 7, 2025
802831e
fix(int): fix int types
Apr 7, 2025
e7a30eb
Merge branch 'fix_int_types' into feat_test_report_1
Apr 7, 2025
309d53a
changes
Apr 8, 2025
aeb5c30
chore(urfave cli): bump to v3
KellyMerrick Apr 8, 2025
e2749c2
converting some of the flags
KellyMerrick Apr 8, 2025
aa3edbf
Merge branch 'fix_int_types' of github.com:go-vela/worker into bump-u…
KellyMerrick Apr 8, 2025
86a2d9b
more v3
KellyMerrick Apr 8, 2025
f022c7a
more changes to v3
Apr 8, 2025
4a522db
Merge branch 'bump-urfave-v3' into feat_test_report_1
Apr 8, 2025
060aceb
chore(deps): update server to current main
KellyMerrick Apr 8, 2025
e2ec2b9
Merge branch 'bump-urfave-v3' into feat_test_report_1
Apr 9, 2025
a52952d
point to latest sdk-go
Apr 9, 2025
ec9dafa
add back missing code
Apr 9, 2025
6d37f5a
Merge branch 'main' into feat_test_report_1
timhuynh94 Apr 9, 2025
f42e676
add back missing code
Apr 9, 2025
76529b1
upload with build number
Apr 11, 2025
012d17e
fix(test reports): use build number instead of build id
KellyMerrick May 20, 2025
c26d850
feat(test reports): try testreport add db record
KellyMerrick Jun 17, 2025
7886bd1
Merge branch 'main' into feat_test_report_1
timhuynh94 Jun 24, 2025
e7fa8e6
Merge branch 'main' into feat_test_report_1
timhuynh94 Jul 3, 2025
9e63c7b
update docker package
Jul 3, 2025
b85a4c6
Merge branch 'main' into feat_test_report_1
timhuynh94 Jul 8, 2025
54eccc6
refactor code
Jul 14, 2025
02bc917
add testattachment
Jul 15, 2025
a3300f5
Merge branch 'main' into feat_test_report_1
timhuynh94 Aug 22, 2025
9c829e5
make clean
Aug 22, 2025
746ba27
point to sdk go branch
Aug 22, 2025
c0affe8
Merge branch 'main' into feat_test_report_1
timhuynh94 Aug 26, 2025
788af04
gomod tidy
Aug 26, 2025
085a207
fixing linters
Aug 27, 2025
e9a7ced
Potential fix for code scanning alert no. 5: Clear-text logging of se…
timhuynh94 Aug 27, 2025
fe11078
add and fix tests
Aug 28, 2025
14d8645
golanci run fix
Aug 28, 2025
ee65782
Merge branch 'main' into feat_test_report_1
timhuynh94 Sep 29, 2025
5e08770
point to server branch
Sep 29, 2025
319412f
non working code
Oct 14, 2025
2b63a1c
non working code
Oct 14, 2025
4bfe330
working but skip step
Oct 15, 2025
0fe9168
working with enabled
Oct 15, 2025
419a687
working with enabled
Oct 16, 2025
605d9a4
fix skip test
Oct 23, 2025
76efee5
point to server branch
Oct 23, 2025
3991c62
update for presigned url
Nov 12, 2025
6b3ef9a
fix conflicts
Dec 1, 2025
9a6b314
fix liniting
Dec 15, 2025
46db70b
enhance: use context for API calls and refresh install token
ecrupper Dec 30, 2025
bcdc2b4
restore some defaults
ecrupper Dec 30, 2025
8a358d7
linter
ecrupper Dec 30, 2025
8c8d2bc
feat(test attachments): merge in main
KellyMerrick Jan 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/vela-worker/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
// exec is a helper function to poll the queue
// and execute Vela pipelines for the Worker.
//
//nolint:nilerr,funlen // ignore returning nil - don't want to crash worker

Check failure on line 28 in cmd/vela-worker/exec.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] cmd/vela-worker/exec.go#L28

directive `//nolint:nilerr,funlen // ignore returning nil - don't want to crash worker` is unused for linter "nilerr" (nolintlint)
Raw output
cmd/vela-worker/exec.go:28:1: directive `//nolint:nilerr,funlen // ignore returning nil - don't want to crash worker` is unused for linter "nilerr" (nolintlint)
//nolint:nilerr,funlen // ignore returning nil - don't want to crash worker
^
func (w *Worker) exec(index int, config *api.Worker) error {

Check failure on line 29 in cmd/vela-worker/exec.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] cmd/vela-worker/exec.go#L29

cyclomatic complexity 31 of func `(*Worker).exec` is high (> 30) (gocyclo)
Raw output
cmd/vela-worker/exec.go:29:1: cyclomatic complexity 31 of func `(*Worker).exec` is high (> 30) (gocyclo)
func (w *Worker) exec(index int, config *api.Worker) error {
^
var err error

// setup the version
Expand Down Expand Up @@ -150,6 +150,9 @@
execOutputCtn := *w.Config.Executor.OutputCtn
execOutputCtn.ID = fmt.Sprintf("outputs_%s", p.ID)

// dereference configured storage config and set the storage config for the executor
execStorage := *w.Config.Executor.Storage

// create logger with extra metadata
//
// https://pkg.go.dev/github.com/sirupsen/logrus#WithFields
Expand Down Expand Up @@ -242,6 +245,7 @@
Pipeline: p.Sanitize(w.Config.Runtime.Driver),
Version: v.Semantic(),
OutputCtn: &execOutputCtn,
Storage: &execStorage,
})

// add the executor to the worker
Expand Down
4 changes: 4 additions & 0 deletions cmd/vela-worker/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import (
"context"
"fmt"
"github.com/go-vela/server/storage"

Check failure on line 8 in cmd/vela-worker/flags.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] cmd/vela-worker/flags.go#L8

File is not properly formatted (gci)
Raw output
cmd/vela-worker/flags.go:8:1: File is not properly formatted (gci)
	"github.com/go-vela/server/storage"
^

Check failure on line 8 in cmd/vela-worker/flags.go

View workflow job for this annotation

GitHub Actions / full-review

File is not properly formatted (gci)

Check failure on line 8 in cmd/vela-worker/flags.go

View workflow job for this annotation

GitHub Actions / diff-review

File is not properly formatted (gci)
"strings"
"time"

Expand Down Expand Up @@ -120,5 +121,8 @@

f = append(f, runtime.Flags...)

// Storage Flags
f = append(f, storage.Flags...)

return f
}
24 changes: 24 additions & 0 deletions cmd/vela-worker/operate.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
registryWorker.SetHostname(w.Config.API.Address.Hostname())
registryWorker.SetAddress(w.Config.API.Address.String())
registryWorker.SetActive(true)
registryWorker.SetBuildLimit(int32(w.Config.Build.Limit))

Check failure on line 34 in cmd/vela-worker/operate.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] cmd/vela-worker/operate.go#L34

G115: integer overflow conversion int -> int32 (gosec)
Raw output
cmd/vela-worker/operate.go:34:36: G115: integer overflow conversion int -> int32 (gosec)
	registryWorker.SetBuildLimit(int32(w.Config.Build.Limit))
	                                  ^

// set routes from config if set or defaulted to `vela`
if (len(w.Config.Queue.Routes) > 0) && (w.Config.Queue.Routes[0] != "NONE" && w.Config.Queue.Routes[0] != "") {
Expand Down Expand Up @@ -76,7 +76,31 @@
// set to error as queue setup fails
w.updateWorkerStatus(registryWorker, constants.WorkerStatusError)
}
// getting storage creds
logrus.Trace("getting storage s3 creds..")
// fetching queue credentials using registration token
stCreds, _, err := w.VelaClient.Storage.GetInfo()
if err != nil {
logrus.Trace("error getting storage creds")
return err
}

// if an address was given at start up, use that — else use what is returned from server
if len(w.Config.Executor.Storage.Endpoint) == 0 {
w.Config.Executor.Storage.Endpoint = stCreds.GetStorageAddress()
logrus.Trace("storage address: ", w.Config.Executor.Storage.Driver)
}

// set access key in storage config
w.Config.Executor.Storage.AccessKey = stCreds.GetAccessKey()
logrus.Trace("access key: ", w.Config.Executor.Storage.AccessKey)
// set secret key in storage config
w.Config.Executor.Storage.SecretKey = stCreds.GetSecretKey()
logrus.Trace("secret key: ", w.Config.Executor.Storage.SecretKey)

// set bucket name in storage config
w.Config.Executor.Storage.Bucket = stCreds.GetStorageBucket()
logrus.Trace("bucket name: ", w.Config.Executor.Storage.Bucket)
// spawn goroutine for phoning home
executors.Go(func() error {
// five second ticker for signal handling
Expand Down
15 changes: 15 additions & 0 deletions cmd/vela-worker/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import (
"context"
"fmt"
"github.com/go-vela/server/storage"

Check failure on line 8 in cmd/vela-worker/run.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] cmd/vela-worker/run.go#L8

File is not properly formatted (gci)
Raw output
cmd/vela-worker/run.go:8:1: File is not properly formatted (gci)
	"github.com/go-vela/server/storage"
^

Check failure on line 8 in cmd/vela-worker/run.go

View workflow job for this annotation

GitHub Actions / full-review

File is not properly formatted (gci)

Check failure on line 8 in cmd/vela-worker/run.go

View workflow job for this annotation

GitHub Actions / diff-review

File is not properly formatted (gci)
"net/url"

"github.com/gin-gonic/gin"
Expand Down Expand Up @@ -96,7 +97,7 @@
},
// build configuration
Build: &Build{
Limit: int(c.Int("build.limit")),

Check failure on line 100 in cmd/vela-worker/run.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] cmd/vela-worker/run.go#L100

unnecessary conversion (unconvert)
Raw output
cmd/vela-worker/run.go:100:17: unnecessary conversion (unconvert)
				Limit:   int(c.Int("build.limit")),
				            ^
Timeout: c.Duration("build.timeout"),
},
// build configuration
Expand All @@ -104,10 +105,17 @@
// executor configuration
Executor: &executor.Setup{
Driver: c.String("executor.driver"),
MaxLogSize: uint(c.Uint("executor.max_log_size")),

Check failure on line 108 in cmd/vela-worker/run.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] cmd/vela-worker/run.go#L108

unnecessary conversion (unconvert)
Raw output
cmd/vela-worker/run.go:108:30: unnecessary conversion (unconvert)
				MaxLogSize:          uint(c.Uint("executor.max_log_size")),
				                         ^
LogStreamingTimeout: c.Duration("executor.log_streaming_timeout"),
EnforceTrustedRepos: c.Bool("executor.enforce-trusted-repos"),
OutputCtn: outputsCtn,
Storage: &storage.Setup{
Driver: c.String("storage.driver"),
Endpoint: c.String("storage.endpoint.name"),
AccessKey: c.String("storage.access.key"),
SecretKey: c.String("storage.secret.key"),
Bucket: c.String("storage.bucket.name"),
},
},
// logger configuration
Logger: &Logger{
Expand Down Expand Up @@ -138,6 +146,13 @@
Address: c.String("server.addr"),
Secret: c.String("server.secret"),
},
Storage: &storage.Setup{
Driver: c.String("storage.driver"),
Endpoint: c.String("storage.endpoint.name"),
AccessKey: c.String("storage.access.key"),
SecretKey: c.String("storage.secret.key"),
Bucket: c.String("storage.bucket.name"),
},
// Certificate configuration
Certificate: &Certificate{
Cert: c.String("server.cert"),
Expand Down Expand Up @@ -172,5 +187,5 @@
}

// start the worker
return w.Start()

Check failure on line 190 in cmd/vela-worker/run.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] cmd/vela-worker/run.go#L190

Function `Start` should pass the context parameter (contextcheck)
Raw output
cmd/vela-worker/run.go:190:16: Function `Start` should pass the context parameter (contextcheck)
	return w.Start()
	              ^

Check failure on line 190 in cmd/vela-worker/run.go

View workflow job for this annotation

GitHub Actions / full-review

Function `Start` should pass the context parameter (contextcheck)

Check failure on line 190 in cmd/vela-worker/run.go

View workflow job for this annotation

GitHub Actions / diff-review

Function `Start` should pass the context parameter (contextcheck)
}
3 changes: 3 additions & 0 deletions cmd/vela-worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package main

import (
"github.com/go-vela/server/storage"

Check failure on line 6 in cmd/vela-worker/worker.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] cmd/vela-worker/worker.go#L6

File is not properly formatted (gci)
Raw output
cmd/vela-worker/worker.go:6:1: File is not properly formatted (gci)
	"github.com/go-vela/server/storage"
^

Check failure on line 6 in cmd/vela-worker/worker.go

View workflow job for this annotation

GitHub Actions / full-review

File is not properly formatted (gci)

Check failure on line 6 in cmd/vela-worker/worker.go

View workflow job for this annotation

GitHub Actions / diff-review

File is not properly formatted (gci)
"net/url"
"sync"
"time"
Expand Down Expand Up @@ -57,6 +58,7 @@
Server *Server
Certificate *Certificate
TLSMinVersion string
Storage *storage.Setup
}

// Worker represents all configuration and
Expand All @@ -72,5 +74,6 @@
RunningBuilds []*api.Build
QueueCheckedIn bool
RunningBuildsMutex sync.Mutex
Storage storage.Storage
}
)
43 changes: 43 additions & 0 deletions executor/linux/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
//
// https://pkg.go.dev/github.com/go-vela/worker/internal/build#Snapshot
defer func() { build.Snapshot(c.build, c.Vela, c.err, c.Logger) }()
// Check if storage client is initialized
// and if storage is enable
if c.Storage == nil {
return fmt.Errorf("storage client is not initialized")
}

// update the build fields
c.build.SetStatus(constants.StatusRunning)
Expand Down Expand Up @@ -290,7 +295,7 @@
for _, s := range c.pipeline.Stages {
// TODO: remove hardcoded reference
//
//nolint:goconst // ignore making a constant for now

Check failure on line 298 in executor/linux/build.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] executor/linux/build.go#L298

directive `//nolint:goconst // ignore making a constant for now` is unused for linter "goconst" (nolintlint)
Raw output
executor/linux/build.go:298:3: directive `//nolint:goconst // ignore making a constant for now` is unused for linter "goconst" (nolintlint)
		//nolint:goconst // ignore making a constant for now
		^
if s.Name == "init" {
continue
}
Expand Down Expand Up @@ -445,6 +450,12 @@
// output maps for dynamic environment variables captured from volume
var opEnv, maskEnv map[string]string

// test report object for storing the test report information
var tr *api.TestReport

// Flag to track if we've already created the test report record
testReportCreated := false

// fire up output container to run with the build
c.Logger.Infof("creating outputs container %s", c.OutputCtn.ID)

Expand Down Expand Up @@ -543,6 +554,38 @@
_step.Secrets = append(_step.Secrets, sec)
}

// logic for polling files only if the test-report step is present
// iterate through the steps in the build

if !_step.TestReport.Empty() {
c.Logger.Debug("creating test report record in database")
// send API call to update the test report
//
// https://pkg.go.dev/github.com/go-vela/sdk-go/vela#TestReportService.Add
// TODO: .Add should be .Update
// TODO: handle somewhere if multiple test report keys exist in pipeline
if !testReportCreated {
tr, c.err = c.CreateTestReport()
if c.err != nil {
return fmt.Errorf("unable to create test report: %w", c.err)
}

testReportCreated = true
}
if len(_step.TestReport.Results) != 0 {

Check failure on line 575 in executor/linux/build.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] executor/linux/build.go#L575

if statements should only be cuddled with assignments (wsl)
Raw output
executor/linux/build.go:575:4: if statements should only be cuddled with assignments (wsl)
			if len(_step.TestReport.Results) != 0 {
			^
err := c.outputs.pollFiles(ctx, c.OutputCtn, _step.TestReport.Results, c.build, tr)
if err != nil {
c.Logger.Errorf("unable to poll files for results: %v", err)
}
}
if len(_step.TestReport.Attachments) != 0 {

Check failure on line 581 in executor/linux/build.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] executor/linux/build.go#L581

if statements should only be cuddled with assignments (wsl)
Raw output
executor/linux/build.go:581:4: if statements should only be cuddled with assignments (wsl)
			if len(_step.TestReport.Attachments) != 0 {
			^
err := c.outputs.pollFiles(ctx, c.OutputCtn, _step.TestReport.Attachments, c.build, tr)
if err != nil {
c.Logger.Errorf("unable to poll files for attachments: %v", err)
}
}
}

// perform any substitution on dynamic variables
err = _step.Substitute()
if err != nil {
Expand Down Expand Up @@ -691,7 +734,7 @@
// into the container right before execution, rather than
// during build planning. It is only available for the Docker runtime.
//
//nolint:funlen // explanation takes up a lot of lines

Check failure on line 737 in executor/linux/build.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] executor/linux/build.go#L737

directive `//nolint:funlen // explanation takes up a lot of lines` is unused for linter "funlen" (nolintlint)
Raw output
executor/linux/build.go:737:1: directive `//nolint:funlen // explanation takes up a lot of lines` is unused for linter "funlen" (nolintlint)
//nolint:funlen // explanation takes up a lot of lines
^
func loadLazySecrets(c *client, _step *pipeline.Container) error {
_log := new(api.Log)

Expand Down
5 changes: 3 additions & 2 deletions executor/linux/linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import (
"sync"
"time"

"github.com/sirupsen/logrus"

"github.com/go-vela/sdk-go/vela"
api "github.com/go-vela/server/api/types"
"github.com/go-vela/server/compiler/types/pipeline"
"github.com/go-vela/server/storage"
"github.com/go-vela/worker/internal/message"
"github.com/go-vela/worker/runtime"
"github.com/sirupsen/logrus"
)

type (
Expand All @@ -29,6 +29,7 @@ type (
Hostname string
Version string
OutputCtn *pipeline.Container
Storage storage.Storage

// clients for build actions
secret *secretSvc
Expand Down
26 changes: 26 additions & 0 deletions executor/linux/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import (
"fmt"
"github.com/go-vela/server/storage"
"time"

"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -209,3 +210,28 @@
return nil
}
}

// WithStorage sets the storage in the executor client for Linux.
func WithStorage(s *storage.Setup) Opt {
return func(c *client) error {
c.Logger.Trace("configuring storage in linux executor client")

// check if the storage provided is empty
if &s == nil {

Check failure on line 220 in executor/linux/opts.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] executor/linux/opts.go#L220

SA4022: the address of a variable cannot be nil (staticcheck)
Raw output
executor/linux/opts.go:220:6: SA4022: the address of a variable cannot be nil (staticcheck)
		if &s == nil {
		   ^
return fmt.Errorf("empty storage setup provided")
}

// set the storage in the client
var err error
c.Storage, err = storage.New(s)

Check failure on line 226 in executor/linux/opts.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] executor/linux/opts.go#L226

SA5011: possible nil pointer dereference (staticcheck)
Raw output
executor/linux/opts.go:226:32: SA5011: possible nil pointer dereference (staticcheck)
		c.Storage, err = storage.New(s)
		                             ^
if err != nil {

Check failure on line 227 in executor/linux/opts.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] executor/linux/opts.go#L227

only one cuddle assignment allowed before if statement (wsl)
Raw output
executor/linux/opts.go:227:3: only one cuddle assignment allowed before if statement (wsl)
		if err != nil {
		^
return fmt.Errorf("unable to create storage: %v", err)

Check failure on line 228 in executor/linux/opts.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] executor/linux/opts.go#L228

non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
Raw output
executor/linux/opts.go:228:54: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
			return fmt.Errorf("unable to create storage: %v", err)
			                                                  ^

Check failure on line 228 in executor/linux/opts.go

View workflow job for this annotation

GitHub Actions / full-review

non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)

Check failure on line 228 in executor/linux/opts.go

View workflow job for this annotation

GitHub Actions / diff-review

non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)

}

Check failure on line 230 in executor/linux/opts.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] executor/linux/opts.go#L230

unnecessary trailing newline (whitespace)
Raw output
executor/linux/opts.go:230:3: unnecessary trailing newline (whitespace)
		}
		^
if c.Storage == nil {
return fmt.Errorf("empty storage setup: %v", err)

Check failure on line 232 in executor/linux/opts.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] executor/linux/opts.go#L232

non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
Raw output
executor/linux/opts.go:232:49: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
			return fmt.Errorf("empty storage setup: %v", err)
			                                             ^

Check failure on line 232 in executor/linux/opts.go

View workflow job for this annotation

GitHub Actions / full-review

non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)

Check failure on line 232 in executor/linux/opts.go

View workflow job for this annotation

GitHub Actions / diff-review

non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
}

return nil
}
}
69 changes: 67 additions & 2 deletions executor/linux/outputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
"encoding/base64"
"fmt"
"maps"
"path/filepath"
"strconv"

api "github.com/go-vela/server/api/types"
"github.com/go-vela/server/compiler/types/pipeline"
envparse "github.com/hashicorp/go-envparse"
"github.com/sirupsen/logrus"

"github.com/go-vela/server/compiler/types/pipeline"
)

// outputSvc handles communication with the outputs container during the build.
Expand Down Expand Up @@ -204,3 +206,66 @@

return outputMap, maskMap, nil
}

// pollFiles polls the output for files from the sidecar container.
func (o *outputSvc) pollFiles(ctx context.Context, ctn *pipeline.Container, fileList []string, b *api.Build, tr *api.TestReport) error {
// exit if outputs container has not been configured
if len(ctn.Image) == 0 {
return fmt.Errorf("no outputs container configured")
}

// update engine logger with outputs metadata
//
// https://pkg.go.dev/github.com/sirupsen/logrus#Entry.WithField
logger := o.client.Logger.WithField("test-outputs", ctn.Name)

// grab file paths from the container
filesPath, err := o.client.Runtime.PollFileNames(ctx, ctn, fileList)
if err != nil {
return fmt.Errorf("unable to poll file names: %w", err)
}

if len(filesPath) == 0 {
return fmt.Errorf("no files found for file list: %v", fileList)
}

// process each file found
for _, filePath := range filesPath {
fileName := filepath.Base(filePath)
logger.Debugf("processing file: %s (path: %s)", fileName, filePath)

// get file content from container
reader, size, err := o.client.Runtime.PollFileContent(ctx, ctn, filePath)
if err != nil {
return fmt.Errorf("unable to poll file content for %s: %w", filePath, err)
}

// create storage object path
objectName := fmt.Sprintf("%s/%s/%s/%s",
b.GetRepo().GetOrg(),
b.GetRepo().GetName(),
strconv.FormatInt(b.GetNumber(), 10),
fileName)

// upload file to storage
err = o.client.Storage.UploadObject(ctx, &api.Object{
ObjectName: objectName,
Bucket: api.Bucket{BucketName: o.client.Storage.GetBucket(ctx)},
FilePath: filePath,
}, reader, size)
if err != nil {
return fmt.Errorf("unable to upload object %s: %w", fileName, err)
}

logger.Debugf("successfully uploaded file %s (%d bytes)", fileName, size)

// create test attachment record in database after successful upload
err = o.client.CreateTestAttachment(fileName, filePath, size, tr)
if err != nil {
logger.Errorf("unable to create test attachment record for %s: %v", fileName, err)
// don't return error here to avoid blocking the upload process
}

Check failure on line 267 in executor/linux/outputs.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] executor/linux/outputs.go#L267

block should not end with a whitespace (or comment) (wsl)
Raw output
executor/linux/outputs.go:267:3: block should not end with a whitespace (or comment) (wsl)
		}
		^
}

return nil
}
31 changes: 31 additions & 0 deletions executor/linux/report.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: Apache-2.0

package linux

import (
"fmt"

api "github.com/go-vela/server/api/types"
)

// CreateTestReport creates a test report record in the database for the current build.
func (c *client) CreateTestReport() (*api.TestReport, error) {
// create empty test report for the build
testReport := &api.TestReport{}

// update test report in database
tr, resp, err := c.Vela.TestReport.Update(
c.build.GetRepo().GetOrg(),
c.build.GetRepo().GetName(),
c.build.GetNumber(),
testReport,
)
if err != nil {
return nil, fmt.Errorf("failed to create test report record: build=%d, status=%d, error=%w",
c.build.GetNumber(), resp.StatusCode, err)
}

c.Logger.Debugf("created test report record: id=%d, build=%d", tr.GetID(), c.build.GetNumber())

return tr, nil
}
Loading
Loading