Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
126 changes: 34 additions & 92 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fuzz_eventstore: ${{ steps.filter.outputs.fuzz_eventstore }}
fuzz_registry: ${{ steps.filter.outputs.fuzz_registry }}
fuzz_carport: ${{ steps.filter.outputs.fuzz_carport }}
web: ${{ steps.filter.outputs.web }}
app: ${{ steps.filter.outputs.app }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
Expand All @@ -30,7 +30,7 @@ jobs:
- 'internal/**'
- 'proto/**'
- 'scripts/**'
- 'web/**'
- 'app/**'
- 'testdata/**'
- 'examples/**'
- 'go.mod'
Expand Down Expand Up @@ -68,9 +68,9 @@ jobs:
- 'go.work'
- 'go.work.sum'
- 'Taskfile.yml'
web:
app:
- '.github/workflows/ci.yml'
- 'web/**'
- 'app/**'
- 'cmd/switchyardd/**'
- 'internal/activity/**'
- 'internal/api/**'
Expand All @@ -83,109 +83,53 @@ jobs:
- 'go.work'
- 'go.work.sum'

web-lint:
app-typecheck:
needs: changes
if: github.event_name != 'pull_request' || needs.changes.outputs.web == 'true'
if: github.event_name != 'pull_request' || needs.changes.outputs.app == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: web/package-lock.json
- name: Install web dependencies
run: npm ci --prefix web
- name: Lint web
run: npm run lint --prefix web
cache-dependency-path: app/package-lock.json
- name: Install app dependencies
run: npm ci --prefix app
- name: Type-check app
run: npm run typecheck --prefix app

web-test:
app-test:
needs: changes
if: github.event_name != 'pull_request' || needs.changes.outputs.web == 'true'
if: github.event_name != 'pull_request' || needs.changes.outputs.app == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: web/package-lock.json
- name: Install web dependencies
run: npm ci --prefix web
- name: Test web
run: npm run test --prefix web
cache-dependency-path: app/package-lock.json
- name: Install app dependencies
run: npm ci --prefix app
- name: Test app
run: npm test --prefix app

web-build:
app-build:
needs: changes
if: github.event_name != 'pull_request' || needs.changes.outputs.web == 'true'
if: github.event_name != 'pull_request' || needs.changes.outputs.app == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: web/package-lock.json
- name: Install web dependencies
run: npm ci --prefix web
- name: Build web bundle
run: npm run build --prefix web

web-e2e:
needs: changes
if: github.event_name != 'pull_request' || needs.changes.outputs.web == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.25'
cache: true
cache-dependency-path: go.sum
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: web/package-lock.json
- name: Install Pkl
run: |
sudo curl -fsSL -o /usr/local/bin/pkl "https://github.com/apple/pkl/releases/download/0.31.1/pkl-linux-amd64"
sudo chmod +x /usr/local/bin/pkl
pkl --version
- name: Install web dependencies
run: npm ci --prefix web
- name: Install Playwright browsers
run: npx --prefix web playwright install --with-deps chromium
- name: Run Playwright e2e tests
run: npm run test:e2e --prefix web

web-playwright:
needs: changes
if: github.event_name != 'pull_request' || needs.changes.outputs.web == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.25'
cache: true
cache-dependency-path: go.sum
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: web/package-lock.json
- name: Install Pkl
run: |
sudo curl -fsSL -o /usr/local/bin/pkl "https://github.com/apple/pkl/releases/download/0.31.1/pkl-linux-amd64"
sudo chmod +x /usr/local/bin/pkl
pkl --version
- name: Install web dependencies
run: npm ci --prefix web
- name: Install Playwright browsers
run: npx --prefix web playwright install --with-deps chromium
- name: Run Playwright
run: npm run test:e2e --prefix web
cache-dependency-path: app/package-lock.json
- name: Install app dependencies
run: npm ci --prefix app
- name: Build app bundle
run: npm run build --prefix app

# ── switchyard ──────────────────────────────────────────────────────────────────

Expand All @@ -203,6 +147,11 @@ jobs:
go-version: '1.25'
cache: true
cache-dependency-path: go.sum
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: app/package-lock.json

- name: Install Task
uses: arduino/setup-task@v2
Expand All @@ -216,7 +165,7 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Install protoc-gen-go-grpc
run: go install google.golang.org/grpc/cmd/[email protected].1
run: go install google.golang.org/grpc/cmd/[email protected].2

- name: Install Pkl
run: |
Expand All @@ -229,13 +178,6 @@ jobs:
sudo chmod +x /usr/local/bin/pkl
pkl --version

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: web/package-lock.json

- name: Regenerate proto (verify committed in sync)
run: |
PATH="$PATH:$(go env GOPATH)/bin" buf generate
Expand Down Expand Up @@ -269,9 +211,9 @@ jobs:
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: web/package-lock.json
- name: Build web frontend (required for embed.go)
run: npm ci --prefix web && npm run build --prefix web
cache-dependency-path: app/package-lock.json
- name: Build app bundle (required for embed.go)
run: npm ci --prefix app && npm run build --prefix app
- uses: golangci/golangci-lint-action@v7
with:
version: v2.11.4
Expand Down
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ var/
/gohomed.lock
/gohomed.sock

# Embedded web assets
internal/web/dist/
# Embedded web asset build outputs; keep the placeholder committed.
!internal/web/dist/
internal/web/dist/*
!internal/web/dist/.gitkeep

# Docs build output
docs/site/
Expand Down
45 changes: 19 additions & 26 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,50 +17,43 @@ tasks:
cmds:
- PATH="$(go env GOPATH)/bin:$PATH" buf generate --path proto/switchyard/activity/v1/

web:install:
desc: Install web npm dependencies (idempotent)
dir: web
app:install:
desc: Install app npm dependencies (idempotent)
dir: app
cmds:
- npm install --no-audit --no-fund

web:build:
desc: Build the web bundle into internal/web/dist
dir: web
deps: [web:install]
app:build:
desc: Build the Vue app bundle into internal/web/dist
dir: app
deps: [app:install]
cmds:
- npm run build

web:lint:
desc: Lint web sources
dir: web
deps: [web:install]
app:typecheck:
desc: Type-check app sources
dir: app
deps: [app:install]
cmds:
- npm run lint
- npm run typecheck

web:test:
desc: Run web unit tests
dir: web
deps: [web:install]
app:test:
desc: Run app unit tests
dir: app
deps: [app:install]
cmds:
- npm test

web:e2e:
desc: Run Playwright end-to-end tests (requires a running switchyardd)
dir: web
deps: [web:install]
cmds:
- npm run test:e2e

ui:dev:
desc: Start Vite dev server (proxies to switchyardd)
dir: web
deps: [web:install]
dir: app
deps: [app:install]
cmds:
- npm run dev

build:
desc: Build both binaries
deps: [web:build]
deps: [app:build]
cmds:
- go build -o {{.BIN_DIR}}/switchyardd ./cmd/switchyardd
- go build -o {{.BIN_DIR}}/switchyard ./cmd/switchyard
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc -b && vite build",
"build": "node scripts/clean-web-dist.mjs && vue-tsc -b && vite build",
"preview": "vite preview",
"test": "vitest run",
"typecheck": "vue-tsc -p tsconfig.json --noEmit && tsc -p tsconfig.node.json --noEmit",
Expand Down
14 changes: 14 additions & 0 deletions app/scripts/clean-web-dist.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { rm, readdir, mkdir } from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";

const appRoot = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
const dist = path.resolve(appRoot, "../internal/web/dist");

await mkdir(dist, { recursive: true });
for (const entry of await readdir(dist)) {
if (entry === ".gitkeep") {
continue;
}
await rm(path.join(dist, entry), { force: true, recursive: true });
}
13 changes: 13 additions & 0 deletions app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ export default defineConfig({
"@": path.resolve(__dirname, "src"),
},
},
build: {
outDir: "../internal/web/dist",
emptyOutDir: false,
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes("node_modules/monaco-editor")) {
return "monaco";
}
},
},
},
},
server: {
port: 5174,
strictPort: true,
Expand Down
7 changes: 0 additions & 7 deletions internal/activity/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,13 +475,6 @@ func filterWindow(since, until *timestamppb.Timestamp) (time.Time, time.Time) {
return s, u
}

func kindFilter(kind string) []string {
if kind == "" {
return nil
}
return []string{kind}
}

func matchesStoriesFilter(story *activityv1.Story, filter *activityv1.StoriesFilter) bool {
if filter == nil {
return true
Expand Down
12 changes: 6 additions & 6 deletions internal/activity/stories/story.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ func (s Story) ToProto() *activityv1.Story {
}

story := &activityv1.Story{
Id: s.ID,
Title: s.Title,
InnerEventIds: s.InnerEventIDs,
Tags: tags,
Source: s.Source,
EntityIds: s.EntityIDs,
Id: s.ID,
Title: s.Title,
InnerEventIds: s.InnerEventIDs,
Tags: tags,
Source: s.Source,
EntityIds: s.EntityIDs,
}
if !s.OccurredAt.IsZero() {
story.OccurredAt = timestamppb.New(s.OccurredAt)
Expand Down
Loading
Loading