Skip to content

Commit c596301

Browse files
Update CI scripts
1 parent 5a7ebe0 commit c596301

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

pkg/builtin/builtin.go

+20
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ var Tools = map[string]types.Tool{
6767
),
6868
BuiltinFunc: SysExec,
6969
},
70+
"sys.getenv": {
71+
Description: "Gets the value of an OS environment variable",
72+
Arguments: types.ObjectSchema(
73+
"name", "The environment variable name to lookup"),
74+
BuiltinFunc: SysGetenv,
75+
},
7076
}
7177

7278
func ListTools() (result []types.Tool) {
@@ -147,6 +153,9 @@ func SysExec(ctx context.Context, env []string, input string) (string, error) {
147153
cmd.Env = env
148154
cmd.Dir = params.Directory
149155
out, err := cmd.CombinedOutput()
156+
if err != nil {
157+
_, _ = os.Stdout.Write(out)
158+
}
150159
return string(out), err
151160
}
152161

@@ -241,6 +250,17 @@ func SysHTTPPost(ctx context.Context, env []string, input string) (string, error
241250
return fmt.Sprintf("Wrote %d to %s", len([]byte(params.Content)), params.URL), nil
242251
}
243252

253+
func SysGetenv(ctx context.Context, env []string, input string) (string, error) {
254+
var params struct {
255+
Name string `json:"name,omitempty"`
256+
}
257+
if err := json.Unmarshal([]byte(input), &params); err != nil {
258+
return "", err
259+
}
260+
log.Debugf("looking up env var %s", params.Name)
261+
return os.Getenv(params.Name), nil
262+
}
263+
244264
func SysAbort(ctx context.Context, env []string, input string) (string, error) {
245265
var params struct {
246266
Message string `json:"message,omitempty"`

pkg/monitor/display.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ func complete(opts ...Options) (result Options) {
2929
}
3030

3131
type Console struct {
32-
dumpState string
33-
liveOutput bool
32+
dumpState string
3433
}
3534

3635
var runID int64

scripts/ci.gpt

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
tools: make, sys.abort
1+
tools: sys.exec, sys.abort, sys.getenv
22

33
Run each step sequentially, if either step fails abort
44

5-
1. Run "make" to compile
6-
2. Run "make test" to test
7-
3. Run "make validate" to test
5+
1. If DANGEROUS environment variable does not equal "true" then abort
6+
2. Run "make" to compile
7+
3. Run the standard set of go validation tools: test, vet, and fmt recursively
8+
4. Install golangci-lint and validate the code using it
9+
5. If the git workspace is dirty, then abort
810

911
Then print SUCCESS
10-
---
11-
tool: make
12-
description: Runs the "make"
13-
args: arg: the args to pass to make
14-
15-
#!make ${ARG}

0 commit comments

Comments
 (0)