Skip to content

Commit

Permalink
Merge pull request #16 from njhale/fix-gr-templating
Browse files Browse the repository at this point in the history
fix: goreleaser templating, linting, and action runners
  • Loading branch information
njhale authored Feb 9, 2024
2 parents 1a60577 + afdf236 commit d8e2a1f
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 6 deletions.
22 changes: 22 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
run:
timeout: 5m

output:
format: github-actions

linters:
disable-all: true
enable:
- errcheck
- gofmt
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- thelper
- unused
- goimports
- whitespace
fast: false
max-same-issues: 50
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ archives:
builds:
- default
- mac
name_template: '{{.Project}}-v{{ .Version }}-{{ if eq .Os "darwin" }}macOS-universal{{ else }}{{ .Os }}-{{ .Arch }}{{ .Arm }}{{ end }}'
name_template: 'gptscript-v{{ .Version }}-{{ if eq .Os "darwin" }}macOS-universal{{ else }}{{ .Os }}-{{ .Arch }}{{ .Arm }}{{ end }}'
format_overrides:
- goos: windows
format: zip
Expand Down
22 changes: 20 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
build:
CGO_ENABLED=0 go build -o bin/gptscript -tags "${GO_TAGS}" -ldflags "-s -w" .

tidy:
go mod tidy

test:
go test -v ./...

validate:
go vet ./...
GOLANGCI_LINT_VERSION ?= v1.56.1
lint:
if ! command -v golangci-lint &> /dev/null; then \
echo "Could not find golangci-lint, installing version $(GOLANGCI_LINT_VERSION)."; \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin $(GOLANGCI_LINT_VERSION); \
fi

golangci-lint run


validate: tidy lint
if [ -n "$$(git status --porcelain)" ]; then \
git status --porcelain; \
echo "Encountered dirty repo!"; \
git diff; \
exit 1 \
;fi

ci: build
./bin/gptscript ./scripts/ci.gpt

4 changes: 2 additions & 2 deletions pkg/engine/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ func (e *Engine) newCommand(ctx context.Context, extraEnv []string, instructions

envMap := map[string]string{}
for _, env := range env {
key, value, ok := strings.Cut(env, "=")
key, ok = strings.CutPrefix(key, "GPTSCRIPT_VAR_")
key, value, _ := strings.Cut(env, "=")
key, ok := strings.CutPrefix(key, "GPTSCRIPT_VAR_")
if !ok {
continue
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/engine/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ func (e *Engine) startDaemon(ctx context.Context, tool types.Tool) (string, erro
}()

context.AfterFunc(ctx, func() {
cmd.Process.Kill()
if err := cmd.Process.Kill(); err != nil {
log.Errorf("daemon failed to kill tool [%s] process: %v", tool.Name, err)
}
})

for range 20 {
Expand Down
4 changes: 4 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ func New(opts ...Options) (*Server, error) {
events: events,
},
})...)
if err != nil {
return nil, err
}

noCacheRunner, err := runner.New(append(runnerOpts, runner.Options{
CacheOptions: runner.CacheOptions{
Cache: new(bool),
Expand Down
1 change: 1 addition & 0 deletions pkg/test/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func TestEcho(t *testing.T) {
}

func RequireOpenAPIKey(t *testing.T) {
t.Helper()
if os.Getenv("OPENAI_API_KEY") == "" {
t.Skip()
}
Expand Down

0 comments on commit d8e2a1f

Please sign in to comment.