Skip to content

Commit afdf236

Browse files
committed
fix: goreleaser templating and linting
- Fix broken goreleaser templating - Fix validation and improve linting - Correct pre-existing linting errors Signed-off-by: Nick Hale <[email protected]>
1 parent 1a60577 commit afdf236

File tree

7 files changed

+53
-6
lines changed

7 files changed

+53
-6
lines changed

.golangci.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
run:
2+
timeout: 5m
3+
4+
output:
5+
format: github-actions
6+
7+
linters:
8+
disable-all: true
9+
enable:
10+
- errcheck
11+
- gofmt
12+
- gosimple
13+
- govet
14+
- ineffassign
15+
- staticcheck
16+
- typecheck
17+
- thelper
18+
- unused
19+
- goimports
20+
- whitespace
21+
fast: false
22+
max-same-issues: 50

.goreleaser.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ archives:
3131
builds:
3232
- default
3333
- mac
34-
name_template: '{{.Project}}-v{{ .Version }}-{{ if eq .Os "darwin" }}macOS-universal{{ else }}{{ .Os }}-{{ .Arch }}{{ .Arm }}{{ end }}'
34+
name_template: 'gptscript-v{{ .Version }}-{{ if eq .Os "darwin" }}macOS-universal{{ else }}{{ .Os }}-{{ .Arch }}{{ .Arm }}{{ end }}'
3535
format_overrides:
3636
- goos: windows
3737
format: zip

Makefile

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
11
build:
22
CGO_ENABLED=0 go build -o bin/gptscript -tags "${GO_TAGS}" -ldflags "-s -w" .
33

4+
tidy:
5+
go mod tidy
6+
47
test:
58
go test -v ./...
69

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

19+
20+
validate: tidy lint
21+
if [ -n "$$(git status --porcelain)" ]; then \
22+
git status --porcelain; \
23+
echo "Encountered dirty repo!"; \
24+
git diff; \
25+
exit 1 \
26+
;fi
27+
1128
ci: build
1229
./bin/gptscript ./scripts/ci.gpt
30+

pkg/engine/cmd.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ func (e *Engine) newCommand(ctx context.Context, extraEnv []string, instructions
7777

7878
envMap := map[string]string{}
7979
for _, env := range env {
80-
key, value, ok := strings.Cut(env, "=")
81-
key, ok = strings.CutPrefix(key, "GPTSCRIPT_VAR_")
80+
key, value, _ := strings.Cut(env, "=")
81+
key, ok := strings.CutPrefix(key, "GPTSCRIPT_VAR_")
8282
if !ok {
8383
continue
8484
}

pkg/engine/daemon.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ func (e *Engine) startDaemon(ctx context.Context, tool types.Tool) (string, erro
8686
}()
8787

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

9294
for range 20 {

pkg/server/server.go

+4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ func New(opts ...Options) (*Server, error) {
5353
events: events,
5454
},
5555
})...)
56+
if err != nil {
57+
return nil, err
58+
}
59+
5660
noCacheRunner, err := runner.New(append(runnerOpts, runner.Options{
5761
CacheOptions: runner.CacheOptions{
5862
Cache: new(bool),

pkg/test/examples_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func TestEcho(t *testing.T) {
5555
}
5656

5757
func RequireOpenAPIKey(t *testing.T) {
58+
t.Helper()
5859
if os.Getenv("OPENAI_API_KEY") == "" {
5960
t.Skip()
6061
}

0 commit comments

Comments
 (0)