Skip to content

Commit a06030a

Browse files
committed
chore: add GitHub CI workflow and update documentation
Add CI pipeline with tests, linting, fuzz tests, build verification, and Codecov integration. Update AGENTS.md with traits syntax docs and expand .gitignore with standard Go patterns.
1 parent 6ff05eb commit a06030a

File tree

3 files changed

+230
-0
lines changed

3 files changed

+230
-0
lines changed

.github/workflows/ci.yml

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
# Cancel in-progress runs when new commits are pushed
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
permissions:
15+
contents: read
16+
pull-requests: read
17+
18+
jobs:
19+
# Detect what files changed to skip tests on doc-only changes
20+
changes:
21+
name: Detect Changes
22+
runs-on: ubuntu-latest
23+
outputs:
24+
code: ${{ steps.filter.outputs.code }}
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: dorny/paths-filter@v3
28+
id: filter
29+
with:
30+
filters: |
31+
code:
32+
- '**/*.go'
33+
- 'go.mod'
34+
- 'go.sum'
35+
- '.github/workflows/**'
36+
- '.golangci.yml'
37+
- 'Taskfile.yml'
38+
39+
test:
40+
needs: changes
41+
if: needs.changes.outputs.code == 'true' || github.event_name != 'pull_request'
42+
timeout-minutes: 15
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
os: [ubuntu-latest, macos-latest, windows-latest]
47+
runs-on: ${{ matrix.os }}
48+
49+
steps:
50+
- uses: actions/checkout@v4
51+
52+
- name: Set up Go
53+
uses: actions/setup-go@v5
54+
with:
55+
go-version-file: go.mod
56+
cache: true
57+
58+
- name: Download dependencies
59+
run: go mod download
60+
61+
- name: Run tests
62+
run: go test -v -race -timeout=10m ./...
63+
64+
fuzz:
65+
needs: changes
66+
if: needs.changes.outputs.code == 'true' || github.event_name != 'pull_request'
67+
timeout-minutes: 10
68+
runs-on: ubuntu-latest
69+
steps:
70+
- uses: actions/checkout@v4
71+
72+
- name: Set up Go
73+
uses: actions/setup-go@v5
74+
with:
75+
go-version-file: go.mod
76+
cache: true
77+
78+
- name: Run fuzz tests (quick)
79+
run: |
80+
# Run each fuzz test for 10 seconds to catch obvious issues
81+
go test -fuzz=FuzzParseScript -fuzztime=10s .
82+
go test -fuzz=FuzzParseExpressions -fuzztime=10s .
83+
go test -fuzz=FuzzEvalExpressions -fuzztime=10s .
84+
85+
lint:
86+
needs: changes
87+
if: needs.changes.outputs.code == 'true' || github.event_name != 'pull_request'
88+
timeout-minutes: 10
89+
runs-on: ubuntu-latest
90+
steps:
91+
- uses: actions/checkout@v4
92+
93+
- name: Set up Go
94+
uses: actions/setup-go@v5
95+
with:
96+
go-version-file: go.mod
97+
cache: true
98+
99+
- name: Run golangci-lint
100+
uses: golangci/golangci-lint-action@v6
101+
with:
102+
version: latest
103+
args: --timeout 5m
104+
105+
- name: Install govulncheck
106+
run: go install golang.org/x/vuln/cmd/govulncheck@latest
107+
108+
- name: Run govulncheck
109+
run: govulncheck ./...
110+
111+
build:
112+
needs: changes
113+
if: needs.changes.outputs.code == 'true' || github.event_name != 'pull_request'
114+
timeout-minutes: 10
115+
runs-on: ubuntu-latest
116+
steps:
117+
- uses: actions/checkout@v4
118+
119+
- name: Set up Go
120+
uses: actions/setup-go@v5
121+
with:
122+
go-version-file: go.mod
123+
cache: true
124+
125+
- name: Build
126+
run: go build -v ./...
127+
128+
- name: Cross-compile check
129+
run: |
130+
echo "Cross-compiling for Linux (amd64)..."
131+
GOOS=linux GOARCH=amd64 go build -v ./...
132+
echo "Cross-compiling for Linux (arm64)..."
133+
GOOS=linux GOARCH=arm64 go build -v ./...
134+
echo "Cross-compiling for Windows (amd64)..."
135+
GOOS=windows GOARCH=amd64 go build -v ./...
136+
echo "Cross-compiling for macOS (amd64)..."
137+
GOOS=darwin GOARCH=amd64 go build -v ./...
138+
echo "Cross-compiling for macOS (arm64)..."
139+
GOOS=darwin GOARCH=arm64 go build -v ./...
140+
141+
coverage:
142+
needs: changes
143+
if: needs.changes.outputs.code == 'true' || github.event_name != 'pull_request'
144+
timeout-minutes: 15
145+
runs-on: ubuntu-latest
146+
steps:
147+
- uses: actions/checkout@v4
148+
149+
- name: Set up Go
150+
uses: actions/setup-go@v5
151+
with:
152+
go-version-file: go.mod
153+
cache: true
154+
155+
- name: Run tests with coverage
156+
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...
157+
158+
- name: Upload coverage to Codecov
159+
uses: codecov/codecov-action@v5
160+
with:
161+
token: ${{ secrets.CODECOV_TOKEN }}
162+
file: ./coverage.txt
163+
flags: unittests
164+
fail_ci_if_error: false

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
.claude/
22
CLAUDE.md
33

4+
# Test and coverage
45
coverage.out
56
coverage.html
7+
*.test
8+
*.out
9+
10+
# Go build artifacts
11+
*.exe
12+
*.exe~
13+
*.dll
14+
*.so
15+
*.dylib
16+
17+
# Go workspace
18+
go.work
19+
go.work.sum
20+
21+
# Dependency directories
22+
vendor/
23+
24+
# IDE and editor
25+
.idea/
26+
.vscode/
27+
*.swp
28+
*.swo
29+
*~
30+
31+
# OS files
32+
.DS_Store
33+
Thumbs.db

AGENTS.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,17 @@ task lint
114114
```
115115
go-zapscript/
116116
├── parser.go # Main parsing engine with ScriptReader
117+
├── reader.go # ScriptReader input handling
118+
├── symbols.go # Parser symbols and character constants
119+
├── traits.go # Traits syntax parsing (#key=value)
117120
├── types.go # Type definitions, constants, and argument structures
118121
├── models.go # JSON-serializable data structures for scripts
119122
├── advargs.go # Type-safe advanced argument wrapper
120123
├── exprenv.go # Expression evaluation environment types
121124
├── parser_test.go # Core parsing tests
122125
├── parser_coverage_test.go # Extended coverage tests
123126
├── parser_media_title_test.go # Media title syntax tests
127+
├── parser_traits_test.go # Traits syntax tests
124128
├── parser_property_test.go # Property-based tests (rapid)
125129
├── parser_fuzz_test.go # Fuzz tests
126130
├── parser_internal_test.go # Internal implementation tests
@@ -175,6 +179,37 @@ Direct media launch by system and title.
175179
- `-tag` - NOT (must not have tag)
176180
- `~tag` - OR (any of these tags)
177181

182+
### Traits Syntax
183+
184+
Traits provide metadata key-value pairs using `#` prefix:
185+
186+
```
187+
#key=value #key2=value2
188+
```
189+
190+
- `#key=value` - Key-value pair
191+
- `#flag` - Boolean shorthand (sets value to `true`)
192+
- `#key="quoted value"` - Quoted string (preserves spaces)
193+
- `#key=[a,b,c]` - Array values
194+
195+
**Type Inference** (unquoted values):
196+
- `true`/`false` → boolean
197+
- `123` → integer
198+
- `3.14` → float
199+
- Everything else → string
200+
- Quoted values are always strings
201+
202+
**Examples**:
203+
```
204+
#favorite → {"favorite": true}
205+
#count=5 → {"count": 5}
206+
#name="My Game" → {"name": "My Game"}
207+
#tags=[action,rpg,indie] → {"tags": ["action", "rpg", "indie"]}
208+
#enabled=true #priority=1 → {"enabled": true, "priority": 1}
209+
```
210+
211+
**Fallback Behavior**: Invalid trait syntax (e.g., `#my-trait` with hyphen) falls back to auto-launch content.
212+
178213
## Key API Entry Points
179214

180215
```go
@@ -202,14 +237,17 @@ result, err := parser.EvalExpressions(envStruct)
202237
- **HTTP**: `http.get`, `http.post`
203238
- **Input**: `input.keyboard`, `input.gamepad`, `input.coinp1`, `input.coinp2`
204239
- **UI**: `ui.notice`, `ui.picker`
240+
- **Metadata**: `traits` (parsed from `#key=value` syntax)
205241

206242
## Good Examples to Follow
207243

208244
**Copy these patterns for new code:**
209245

210246
- **Parser Methods**: `parser.go` - ScriptReader parsing methods
247+
- **Traits Parsing**: `traits.go` - Type inference, arrays, quoted values
211248
- **Type Definitions**: `types.go` - Constant and type patterns
212249
- **Table-Driven Tests**: `parser_test.go` - Test organization pattern
250+
- **Traits Tests**: `parser_traits_test.go` - Comprehensive trait syntax tests
213251
- **Property Tests**: `parser_property_test.go` - Property-based testing with rapid
214252
- **Fuzz Tests**: `parser_fuzz_test.go` - Fuzz testing pattern
215253

0 commit comments

Comments
 (0)