Skip to content

Commit

Permalink
Update CI scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Feb 5, 2024
1 parent 5a7ebe0 commit c596301
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
20 changes: 20 additions & 0 deletions pkg/builtin/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ var Tools = map[string]types.Tool{
),
BuiltinFunc: SysExec,
},
"sys.getenv": {
Description: "Gets the value of an OS environment variable",
Arguments: types.ObjectSchema(
"name", "The environment variable name to lookup"),
BuiltinFunc: SysGetenv,
},
}

func ListTools() (result []types.Tool) {
Expand Down Expand Up @@ -147,6 +153,9 @@ func SysExec(ctx context.Context, env []string, input string) (string, error) {
cmd.Env = env
cmd.Dir = params.Directory
out, err := cmd.CombinedOutput()
if err != nil {
_, _ = os.Stdout.Write(out)
}
return string(out), err
}

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

func SysGetenv(ctx context.Context, env []string, input string) (string, error) {
var params struct {
Name string `json:"name,omitempty"`
}
if err := json.Unmarshal([]byte(input), &params); err != nil {
return "", err
}
log.Debugf("looking up env var %s", params.Name)
return os.Getenv(params.Name), nil
}

func SysAbort(ctx context.Context, env []string, input string) (string, error) {
var params struct {
Message string `json:"message,omitempty"`
Expand Down
3 changes: 1 addition & 2 deletions pkg/monitor/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ func complete(opts ...Options) (result Options) {
}

type Console struct {
dumpState string
liveOutput bool
dumpState string
}

var runID int64
Expand Down
16 changes: 6 additions & 10 deletions scripts/ci.gpt
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
tools: make, sys.abort
tools: sys.exec, sys.abort, sys.getenv

Run each step sequentially, if either step fails abort

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

Then print SUCCESS
---
tool: make
description: Runs the "make"
args: arg: the args to pass to make

#!make ${ARG}

0 comments on commit c596301

Please sign in to comment.