Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,17 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
go-version: 1.26
cache: true
Comment thread
spencercjh marked this conversation as resolved.

- name: Set up goctl
run: go install github.com/zeromicro/go-zero/tools/goctl@latest
Comment thread
spencercjh marked this conversation as resolved.

Comment on lines +93 to +95
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installing goctl@latest makes CI non-reproducible (a new goctl release can break the pipeline without code changes). Consider pinning to a specific version (ideally matching the go-zero version used in integration-tests/gozero-demo/go.mod) or centralizing the version in a workflow/env var.

Copilot uses AI. Check for mistakes.
- name: Set up JDK 25
uses: actions/setup-java@v4
with:
java-version: "25"
distribution: "temurin"

- name: Run E2E tests (${{ matrix.test-type }})
- name: Run E2E tests
run: make test-e2e
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,6 @@ output/
# Claude Code
.claude/
.go-version
integration-tests/gozero-demo/openapi.yaml
integration-tests/gozero-demo/openapi.json

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ LLM_API_KEY="sk-xxx" spec-forge enrich ./openapi.json \
| Framework | Language | Status |
|----------------------------------------------------------------------------------------------------------------------------------------------|----------------|----------------|
| [Spring Boot](https://springdoc.org/#plugins) | Java | ✅ Supported |
| [go-zero](https://go-zero.dev/reference/cli-guide/swagger/) | Go | 🚧 Coming soon |
| [go-zero](https://go-zero.dev/reference/cli-guide/swagger/) | Go | ✅ Supported |
| [Hertz](https://github.com/hertz-contrib/swagger-generate/tree/main/protoc-gen-http-swagger) | Go | 🚧 Coming soon |
| [Kitex](https://github.com/hertz-contrib/swagger-generate/tree/main/protoc-gen-rpc-swagger) | Go | 🚧 Coming soon |
| [gRPC](https://github.com/grpc-ecosystem/grpc-gateway?tab=readme-ov-file#6-optional-generate-openapi-definitions-using-protoc-gen-openapiv2) | Multi-language | 🚧 Coming soon |
Expand Down
25 changes: 18 additions & 7 deletions integration-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This directory contains end-to-end tests for the spec-forge CLI tool.
| `gradle-springboot-openapi-demo` | Gradle | Single module Spring Boot project |
| `maven-multi-module-demo` | Maven | Multi-module Spring Boot project |
| `gradle-multi-module-demo` | Gradle | Multi-module Spring Boot project |
| `gozero-demo` | Go Modules | go-zero framework project |
Comment thread
spencercjh marked this conversation as resolved.

## Running Tests

Expand All @@ -21,7 +22,13 @@ go test ./...

### End-to-End Tests

E2E tests require the build tools (Maven/Gradle) to be installed.
E2E tests require the following tools to be installed:

- **Java 25** - Required for Spring Boot projects (Maven/Gradle wrappers are included in demo projects)
- **goctl** - Required for go-zero projects. Install with:
```bash
go install github.com/zeromicro/go-zero/tools/goctl@latest
```

Comment on lines +28 to 32
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs recommend go install .../goctl@latest, which is convenient but can lead to non-reproducible e2e runs when goctl behavior changes. Consider documenting a pinned goctl version (matching the demo project's go-zero dependency) or at least noting that @latest may cause test drift over time.

Suggested change
- **goctl** - Required for go-zero projects. Install with:
```bash
go install github.com/zeromicro/go-zero/tools/goctl@latest
```
- **goctl** - Required for go-zero projects. Install with a version pinned to the go-zero dependency used in the `gozero-demo` project, for example:
```bash
go install github.com/zeromicro/go-zero/tools/goctl@vX.Y.Z

Note: Using @latest can change goctl behavior over time and may cause end-to-end tests to drift.

Copilot uses AI. Check for mistakes.
```bash
# Run all e2e tests
Expand All @@ -48,9 +55,13 @@ go test -tags=e2e ./...

## Test Coverage

| Test | Description |
|------|-------------|
| `TestE2E_MavenSpringBoot_Generate` | Tests generate flow for Maven project |
| `TestE2E_MavenSpringBoot_GenerateEnrich` | Tests complete generate → enrich flow |
| `TestE2E_GradleSpringBoot_Generate` | Tests generate flow for Gradle project |
| `TestE2E_ErrorHandling_CommandNotFound` | Tests error handling for missing commands |
| Test File | Tests | Description |
|-----------|-------|-------------|
| `spring_maven_test.go` | `TestE2E_MavenSpringBoot_Generate` | Tests generate flow for Maven project |
| `spring_maven_test.go` | `TestE2E_MavenSpringBoot_GenerateEnrich` | Tests complete generate → enrich flow |
| `spring_gradle_test.go` | `TestE2E_GradleSpringBoot_Generate` | Tests generate flow for Gradle project |
| `gozero_test.go` | `TestE2E_GoZero_Generate` | Tests generate flow for go-zero project |
| `gozero_test.go` | `TestE2E_GoZero_Detect` | Tests detection of go-zero project info |
| `gozero_test.go` | `TestE2E_GoZero_NoGoctl` | Tests graceful handling when goctl missing |
| `error_test.go` | `TestE2E_ErrorHandling_CommandNotFound` | Tests error handling for missing commands |
| `mock_provider_test.go` | `countingMockProvider` | Shared mock provider for enrichment tests |
41 changes: 41 additions & 0 deletions integration-tests/error_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//go:build e2e

package e2e_test

import (
"context"
"errors"
"os"
"path/filepath"
"testing"

"github.com/spencercjh/spec-forge/internal/executor"
)

// TestE2E_ErrorHandling_CommandNotFound tests error handling when build tool is not found.
func TestE2E_ErrorHandling_CommandNotFound(t *testing.T) {
// Create a temp directory with pom.xml but no maven installed
tmpDir := t.TempDir()
pomPath := filepath.Join(tmpDir, "pom.xml")
if err := os.WriteFile(pomPath, []byte(`<project></project>`), 0o644); err != nil {
t.Fatal(err)
}

ctx := context.Background()
exec := executor.NewExecutor()

// Try to run a non-existent command
_, err := exec.Execute(ctx, &executor.ExecuteOptions{
Command: "nonexistent_command_12345",
Args: []string{},
})

if err == nil {
t.Fatal("Expected error for non-existent command")
}

// Verify it's a CommandNotFoundError
if _, ok := errors.AsType[*executor.CommandNotFoundError](err); !ok {
t.Fatalf("expected CommandNotFoundError, got %T: %v", err, err)
}
}
72 changes: 37 additions & 35 deletions integration-tests/gozero-demo/go.mod
Original file line number Diff line number Diff line change
@@ -1,48 +1,50 @@
module github.com/spencercjh/gozero-demo

go 1.23.0
go 1.26

require github.com/zeromicro/go-zero v1.6.0
require github.com/zeromicro/go-zero v1.10.0

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grafana/pyroscope-go v1.2.7 // indirect
github.com/grafana/pyroscope-go/godeltaprof v0.1.9 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/openzipkin/zipkin-go v0.4.2 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/prometheus/client_golang v1.17.0 // indirect
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/openzipkin/zipkin-go v0.4.3 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.66.1 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.19.0 // indirect
go.opentelemetry.io/otel/exporters/zipkin v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/sdk v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
go.uber.org/automaxprocs v1.5.3 // indirect
golang.org/x/net v0.38.0 // indirect
golang.org/x/sys v0.31.0 // indirect
golang.org/x/text v0.23.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/zipkin v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/sdk v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/automaxprocs v1.6.0 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The require entry on go.yaml.in/yaml/v2 introduces a likely typosquatted and potentially malicious replacement for the legitimate gopkg.in/yaml.v2 module, creating a supply-chain risk. Including this module in go.mod allows it to be fetched and built in developer or CI environments, where it could run arbitrary code with access to secrets. Remove this requirement and, if YAML parsing is needed, depend on the official gopkg.in/yaml.v2 module instead.

Copilot uses AI. Check for mistakes.
golang.org/x/net v0.43.0 // indirect
golang.org/x/sys v0.35.0 // indirect
golang.org/x/text v0.28.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.36.11 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
Loading