Skip to content

Commit 4c31bf1

Browse files
authored
chore(ci): add GitHub Actions workflow (#10)
* chore(ci): add GitHub Actions workflow to run Makefile rules Add CI workflow that runs key Makefile targets: - verify: deps, fmt, lint, test - build: build binary and upload artifact - test-e2e: run e2e tests with Maven and Gradle Workflow triggers on push to main and pull requests. Signed-off-by: spencercjh <spencercjh@gmail.com> * fix(provider): extract provider names as constants to fix lint errors - Add OpenAIProviderName constant for "openai" - Add OllamaProviderName constant for "ollama" - Update factory.go, ollama.go, and openai.go to use constants Fixes goconst lint errors in CI. Signed-off-by: spencercjh <spencercjh@gmail.com> * chore(ci): update Java version to 25 and improve concurrency settings Signed-off-by: spencercjh <spencercjh@gmail.com> * fix(e2e): update test to use new ProjectInfo structure ProjectInfo now uses FrameworkData to store framework-specific info. Update E2E test to access HasSpringdocDeps through spring.Info. Signed-off-by: spencercjh <spencercjh@gmail.com> * fix(ci): add diff checks for deps and fmt, remove redundant build - Add 'git diff --exit-code' after make deps to verify tidy modules - Add 'git diff --exit-code' after make fmt to verify formatting - Remove redundant build step from verify job (build job handles it) Signed-off-by: spencercjh <spencercjh@gmail.com> * chore(ci): simplify E2E test workflow by removing matrix strategy Signed-off-by: spencercjh <spencercjh@gmail.com> --------- Signed-off-by: spencercjh <spencercjh@gmail.com>
1 parent 14ba026 commit 4c31bf1

6 files changed

Lines changed: 118 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: ci-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
verify:
18+
name: Verify
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Go
25+
uses: actions/setup-go@v5
26+
with:
27+
go-version: stable
28+
cache: true
29+
30+
- name: Download dependencies
31+
run: make deps
32+
33+
- name: Verify dependencies are tidy
34+
run: git diff --exit-code -- go.mod go.sum
35+
36+
- name: Setup golangci-lint
37+
uses: golangci/golangci-lint-action@v7
38+
with:
39+
version: v2.10
40+
args: --help
41+
verify: false
42+
43+
- name: Format check
44+
run: make fmt
45+
46+
- name: Verify formatting
47+
run: git diff --exit-code
48+
49+
- name: Run linter
50+
run: make lint
51+
52+
- name: Run tests
53+
run: make test
54+
55+
build:
56+
name: Build
57+
runs-on: ubuntu-latest
58+
needs: verify
59+
steps:
60+
- name: Checkout code
61+
uses: actions/checkout@v4
62+
63+
- name: Set up Go
64+
uses: actions/setup-go@v5
65+
with:
66+
go-version: 1.26
67+
cache: true
68+
69+
- name: Build binary
70+
run: make build
71+
72+
- name: Upload build artifact
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: spec-forge-linux
76+
path: build/spec-forge
77+
retention-days: 7
78+
79+
test-e2e:
80+
name: E2E Tests
81+
runs-on: ubuntu-latest
82+
needs: build
83+
steps:
84+
- name: Checkout code
85+
uses: actions/checkout@v4
86+
87+
- name: Set up Go
88+
uses: actions/setup-go@v5
89+
with:
90+
go-version: stable
91+
cache: true
92+
93+
- name: Set up JDK 25
94+
uses: actions/setup-java@v4
95+
with:
96+
java-version: "25"
97+
distribution: "temurin"
98+
99+
- name: Run E2E tests (${{ matrix.test-type }})
100+
run: make test-e2e

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/spencercjh/spec-forge
22

3-
go 1.26.0
3+
go 1.26
44

55
require (
66
github.com/getkin/kin-openapi v0.133.0

integration-tests/e2e_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ func TestE2E_MavenSpringBoot_Generate(t *testing.T) {
5050
t.Errorf("Expected Maven build tool, got %s", info.BuildTool)
5151
}
5252

53-
if !info.HasSpringdocDeps {
53+
springInfo, ok := info.FrameworkData.(*spring.Info)
54+
if !ok {
55+
t.Fatal("Expected FrameworkData to be *spring.Info")
56+
}
57+
58+
if !springInfo.HasSpringdocDeps {
5459
t.Error("Expected springdoc dependencies to be present")
5560
}
5661

internal/enricher/provider/factory.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ func NewUnsupportedProviderError(provider string) *UnsupportedProviderError {
3838
// NewProvider creates a provider based on the provider type
3939
func NewProvider(cfg Config) (Provider, error) { //nolint:gocritic // copying config is acceptable
4040
switch cfg.Provider {
41-
case "openai":
41+
case OpenAIProviderName:
4242
return newOpenAIProvider(cfg.APIKey, cfg.Model)
4343
case "anthropic":
4444
return newAnthropicProvider(cfg.APIKey, cfg.Model)
45-
case "ollama":
45+
case OllamaProviderName:
4646
baseURL := cfg.BaseURL
4747
if baseURL == "" {
4848
baseURL = "http://localhost:11434"

internal/enricher/provider/ollama.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import (
88
"github.com/tmc/langchaingo/llms/ollama"
99
)
1010

11+
// OllamaProviderName is the name of the Ollama provider.
12+
const OllamaProviderName = "ollama"
13+
1114
// OllamaProvider implements Provider for Ollama local LLM using langchaingo
1215
type OllamaProvider struct {
1316
llm llms.Model
@@ -39,12 +42,12 @@ func newOllamaProvider(baseURL, model string) (*OllamaProvider, error) {
3942
func (p *OllamaProvider) Generate(ctx context.Context, prompt string) (string, error) {
4043
response, err := llms.GenerateFromSinglePrompt(ctx, p.llm, prompt)
4144
if err != nil {
42-
return "", fmt.Errorf("ollama generation failed: %w", err)
45+
return "", fmt.Errorf("%s generation failed: %w", OllamaProviderName, err)
4346
}
4447
return response, nil
4548
}
4649

4750
// Name returns the provider name
4851
func (p *OllamaProvider) Name() string {
49-
return "ollama"
52+
return OllamaProviderName
5053
}

internal/enricher/provider/openai.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import (
88
"github.com/tmc/langchaingo/llms/openai"
99
)
1010

11+
// OpenAIProviderName is the name of the OpenAI provider.
12+
const OpenAIProviderName = "openai"
13+
1114
// OpenAIProvider implements Provider for OpenAI using langchaingo
1215
type OpenAIProvider struct {
1316
llm llms.Model
@@ -41,5 +44,5 @@ func (p *OpenAIProvider) Generate(ctx context.Context, prompt string) (string, e
4144

4245
// Name returns the provider name
4346
func (p *OpenAIProvider) Name() string {
44-
return "openai"
47+
return OpenAIProviderName
4548
}

0 commit comments

Comments
 (0)