Skip to content

Commit f726bba

Browse files
authored
Merge pull request #1 from Paca-AI/feature/enhance-bdd-scenario-management
feat: update plugin-sdk-go dependency and enhance BDD scenario manage…
2 parents 6625464 + 5772a3b commit f726bba

11 files changed

Lines changed: 754 additions & 346 deletions

File tree

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: backend-pr-ci
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "backend/**"
7+
- ".github/workflows/backend-pr-ci.yml"
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: backend-pr-ci-${{ github.event.pull_request.number || github.ref }}
15+
cancel-in-progress: true
16+
17+
env:
18+
GO_VERSION: "1.24"
19+
20+
jobs:
21+
lint:
22+
name: Lint
23+
runs-on: ubuntu-latest
24+
timeout-minutes: 10
25+
26+
defaults:
27+
run:
28+
working-directory: backend
29+
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 1
35+
36+
- name: Setup Go
37+
uses: actions/setup-go@v5
38+
with:
39+
go-version: ${{ env.GO_VERSION }}
40+
cache-dependency-path: backend/go.sum
41+
42+
- name: Install golangci-lint
43+
run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
44+
45+
- name: Run golangci-lint
46+
run: golangci-lint run --timeout=5m
47+
48+
build:
49+
name: Build
50+
runs-on: ubuntu-latest
51+
timeout-minutes: 10
52+
53+
defaults:
54+
run:
55+
working-directory: backend
56+
57+
steps:
58+
- name: Checkout repository
59+
uses: actions/checkout@v4
60+
with:
61+
fetch-depth: 1
62+
63+
- name: Setup Go
64+
uses: actions/setup-go@v5
65+
with:
66+
go-version: ${{ env.GO_VERSION }}
67+
cache-dependency-path: backend/go.sum
68+
69+
- name: Build WASM
70+
run: GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared -o bdd.wasm .
71+
72+
test:
73+
name: Tests
74+
runs-on: ubuntu-latest
75+
timeout-minutes: 15
76+
77+
defaults:
78+
run:
79+
working-directory: backend
80+
81+
steps:
82+
- name: Checkout repository
83+
uses: actions/checkout@v4
84+
with:
85+
fetch-depth: 1
86+
87+
- name: Setup Go
88+
uses: actions/setup-go@v5
89+
with:
90+
go-version: ${{ env.GO_VERSION }}
91+
cache-dependency-path: backend/go.sum
92+
93+
- name: Run tests (race detector)
94+
run: go test -race -timeout 60s -coverprofile=coverage.out $(go list ./...)
95+
96+
- name: Upload coverage report
97+
uses: actions/upload-artifact@v4
98+
with:
99+
name: coverage-report
100+
path: backend/coverage.out
101+
retention-days: 7
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: frontend-pr-ci
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "frontend/**"
7+
- ".github/workflows/frontend-pr-ci.yml"
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: frontend-pr-ci-${{ github.event.pull_request.number || github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
web-quality:
19+
name: Typecheck and build frontend
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 20
22+
23+
defaults:
24+
run:
25+
working-directory: frontend
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 1
32+
33+
- name: Setup Bun
34+
uses: oven-sh/setup-bun@v2
35+
with:
36+
bun-version: "1.2.23"
37+
38+
- name: Cache Bun packages
39+
uses: actions/cache@v4
40+
with:
41+
path: ~/.bun/install/cache
42+
key: ${{ runner.os }}-bun-${{ hashFiles('frontend/bun.lock') }}
43+
restore-keys: |
44+
${{ runner.os }}-bun-
45+
46+
- name: Install dependencies
47+
run: bun install --frozen-lockfile
48+
49+
- name: Typecheck
50+
run: bun run typecheck
51+
52+
- name: Build production bundle
53+
run: bun run build

.github/workflows/mcp-pr-ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: mcp-pr-ci
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "mcp/**"
7+
- ".github/workflows/mcp-pr-ci.yml"
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: mcp-pr-ci-${{ github.event.pull_request.number || github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
mcp-quality:
19+
name: Typecheck and build MCP server
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 10
22+
23+
defaults:
24+
run:
25+
working-directory: mcp
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 1
32+
33+
- name: Setup Bun
34+
uses: oven-sh/setup-bun@v2
35+
with:
36+
bun-version: "1.2.23"
37+
38+
- name: Cache Bun packages
39+
uses: actions/cache@v4
40+
with:
41+
path: ~/.bun/install/cache
42+
key: ${{ runner.os }}-bun-mcp-${{ hashFiles('mcp/bun.lock') }}
43+
restore-keys: |
44+
${{ runner.os }}-bun-mcp-
45+
46+
- name: Install dependencies
47+
run: bun install --frozen-lockfile
48+
49+
- name: Typecheck
50+
run: bun run typecheck
51+
52+
- name: Build
53+
run: bun run build

backend/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ module github.com/Paca-AI/first-party/bdd
22

33
go 1.24
44

5-
require github.com/Paca-AI/plugin-sdk-go v0.2.0-rc.3
5+
require github.com/Paca-AI/plugin-sdk-go v0.2.0-rc.5
66

77
require github.com/google/uuid v1.6.0

backend/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
github.com/Paca-AI/plugin-sdk-go v0.2.0-rc.3 h1:2MFHmdVIKVo1/Cyo7GL3S/LsAFxpsqhJSAbTao+xNEw=
2-
github.com/Paca-AI/plugin-sdk-go v0.2.0-rc.3/go.mod h1:5WeC6cSEf2wM1ovICZbDaVky9oi5id/Qpdfc5LDAQnw=
1+
github.com/Paca-AI/plugin-sdk-go v0.2.0-rc.5 h1:xrEPnJLM2sdwtY/wRaGOdfeDPv5zPUpR8QZJ/w2nQVU=
2+
github.com/Paca-AI/plugin-sdk-go v0.2.0-rc.5/go.mod h1:5WeC6cSEf2wM1ovICZbDaVky9oi5id/Qpdfc5LDAQnw=
33
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
44
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=

backend/scenarios.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ func (p *bddPlugin) createScenario(req *plugin.Request, res *plugin.Response) {
110110
CreatedAt: now,
111111
UpdatedAt: now,
112112
}
113+
plugin.RecordActivity(taskID, projectID, req.Caller.UserID, "task.bdd_scenario.created",
114+
map[string]any{"title": b.Title})
113115
created(res, scenario)
114116
}
115117

@@ -225,6 +227,22 @@ func (p *bddPlugin) updateScenario(req *plugin.Request, res *plugin.Response) {
225227
res.Error(404, "bdd scenario not found")
226228
return
227229
}
230+
// Collect which fields changed for the activity record.
231+
var changedFields []string
232+
if b.Title != nil && *b.Title != sc.str("title") {
233+
changedFields = append(changedFields, "title")
234+
}
235+
if b.Given != nil && *b.Given != sc.str("given_text") {
236+
changedFields = append(changedFields, "given")
237+
}
238+
if b.When != nil && *b.When != sc.str("when_text") {
239+
changedFields = append(changedFields, "when")
240+
}
241+
if b.Then != nil && *b.Then != sc.str("then_text") {
242+
changedFields = append(changedFields, "then")
243+
}
244+
plugin.RecordActivity(taskID, projectID, req.Caller.UserID, "task.bdd_scenario.updated",
245+
map[string]any{"title": updTitle, "changes": changedFields})
228246
ok(res, bddScenario{
229247
ID: scenarioID,
230248
TaskID: taskID,
@@ -247,6 +265,23 @@ func (p *bddPlugin) deleteScenario(req *plugin.Request, res *plugin.Response) {
247265
return
248266
}
249267

268+
// Fetch title before deletion for the activity record.
269+
titleResult, err := p.db.Query(
270+
`SELECT title FROM bdd_scenarios WHERE id = $1 AND task_id = $2`,
271+
scenarioID, taskID,
272+
)
273+
if err != nil {
274+
p.log.Error("deleteScenario title fetch: " + err.Error())
275+
res.Error(500, "failed to delete bdd scenario")
276+
return
277+
}
278+
if len(titleResult.Rows) == 0 {
279+
res.Error(404, "bdd scenario not found")
280+
return
281+
}
282+
scenarioTitleSC := newRowScanner(titleResult.Columns, titleResult.Rows[0])
283+
scenarioTitle := scenarioTitleSC.str("title")
284+
250285
affected, err := p.db.Exec(
251286
`DELETE FROM bdd_scenarios WHERE id = $1 AND task_id = $2`,
252287
scenarioID, taskID,
@@ -260,6 +295,8 @@ func (p *bddPlugin) deleteScenario(req *plugin.Request, res *plugin.Response) {
260295
res.Error(404, "bdd scenario not found")
261296
return
262297
}
298+
plugin.RecordActivity(taskID, projectID, req.Caller.UserID, "task.bdd_scenario.deleted",
299+
map[string]any{"title": scenarioTitle})
263300
res.NoContent()
264301
}
265302

0 commit comments

Comments
 (0)