Skip to content

Commit 5f384b3

Browse files
authored
Merge pull request #2 from thedadams/add-ci
chore: add CI for merges and PRs
2 parents b3d7cf7 + b1b978a commit 5f384b3

File tree

5 files changed

+105
-5
lines changed

5 files changed

+105
-5
lines changed

.github/workflows/test.yaml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: test
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths-ignore:
7+
- README.md
8+
pull_request:
9+
branches:
10+
- main
11+
paths-ignore:
12+
- README.md
13+
14+
jobs:
15+
test-linux:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 1
21+
- uses: actions/setup-go@v5
22+
with:
23+
cache: false
24+
go-version: "1.22"
25+
- name: Validate
26+
run: make validate
27+
- name: Install gptscript
28+
run: |
29+
curl https://get.gptscript.ai/releases/default_linux_amd64_v1/gptscript -o gptscript
30+
chmod +x gptscript
31+
- name: Run Tests
32+
env:
33+
GPTSCRIPT_BIN: ./gptscript
34+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
35+
run: make test
36+
37+
test-windows:
38+
runs-on: windows-latest
39+
steps:
40+
- uses: actions/checkout@v4
41+
with:
42+
fetch-depth: 1
43+
- uses: actions/setup-go@v5
44+
with:
45+
cache: false
46+
go-version: "1.22"
47+
- name: Install gptscript
48+
run: |
49+
curl https://get.gptscript.ai/releases/default_windows_amd64_v1/gptscript.exe -o gptscript.exe
50+
- name: Run Tests
51+
env:
52+
GPTSCRIPT_BIN: .\gptscript.exe
53+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
54+
run: make test

.golangci.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
- revive
22+
fast: false
23+
max-same-issues: 50

Makefile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.PHONY: tidy lint test validate setup-ci
2+
3+
tidy:
4+
go mod tidy
5+
6+
test:
7+
go test -v ./...
8+
9+
GOLANGCI_LINT_VERSION ?= v1.56.1
10+
lint:
11+
if ! command -v golangci-lint &> /dev/null; then \
12+
echo "Could not find golangci-lint, installing version $(GOLANGCI_LINT_VERSION)."; \
13+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin $(GOLANGCI_LINT_VERSION); \
14+
fi
15+
16+
golangci-lint run
17+
18+
validate: tidy lint
19+
if [ -n "$$(git status --porcelain)" ]; then \
20+
git status --porcelain; \
21+
echo "Encountered dirty repo!"; \
22+
git diff; \
23+
exit 1 \
24+
;fi

exec_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ func TestExecFileChdir(t *testing.T) {
6767

6868
func TestExecComplexTool(t *testing.T) {
6969
tool := &Tool{
70-
Tools: []string{"sys.write"},
71-
JsonResponse: true,
70+
JSONResponse: true,
7271
Instructions: `
7372
Create three short graphic artist descriptions and their muses.
7473
These should be descriptive and explain their point of view.

tool.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type Tool struct {
1717
Args map[string]string
1818
InternalPrompt bool
1919
Instructions string
20-
JsonResponse bool
20+
JSONResponse bool
2121
}
2222

2323
// NewTool is a constructor for Tool struct.
@@ -33,7 +33,7 @@ func NewTool(name, description string, tools []string, maxTokens *int, model str
3333
Args: args,
3434
InternalPrompt: internalPrompt,
3535
Instructions: instructions,
36-
JsonResponse: jsonResponse,
36+
JSONResponse: jsonResponse,
3737
}
3838
}
3939

@@ -62,7 +62,7 @@ func (t *Tool) String() string {
6262
if t.Temperature != nil {
6363
sb.WriteString(fmt.Sprintf("Temperature: %f\n", *t.Temperature))
6464
}
65-
if t.JsonResponse {
65+
if t.JSONResponse {
6666
sb.WriteString("JSON Response: true\n")
6767
}
6868
if len(t.Args) > 0 {

0 commit comments

Comments
 (0)