Compare commits
20
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60b2e5d642 | ||
|
|
599098d726 | ||
|
|
648e77952f | ||
|
|
3c6490f25c | ||
|
|
bf8f89ff08 | ||
|
|
02fb586ae2 | ||
|
|
ce3396adcc | ||
|
|
6b72532331 | ||
|
|
a3e11a6ad1 | ||
|
|
6313817cd4 | ||
|
|
f9fba50093 | ||
|
|
c50b53cea0 | ||
|
|
7ee6b4969e | ||
|
|
1ef65523d3 | ||
|
|
738b727242 | ||
|
|
068ac93e40 | ||
|
|
53d642bbb7 | ||
|
|
f0ecd16cb0 | ||
|
|
2a4dd82643 | ||
|
|
d33cfd6ccc |
@@ -0,0 +1,14 @@
|
|||||||
|
# TODO: delete this file if unused
|
||||||
|
# This is on the only .env file commited to git.
|
||||||
|
# It's purpose is to provide an environment from which it can operate the app and do full development.
|
||||||
|
|
||||||
|
DATABASE_URL=postgres://app_client:app_password@postgres:5432/inventory_2?sslmode=disable
|
||||||
|
TEST_DATABASE_URL=postgres://app_client:app_password@postgres:5432/inventory_2_test?sslmode=disable
|
||||||
|
|
||||||
|
# AUTH0_DOMAIN / AUTH0_CLIENT_ID / AUTH0_CLIENT_SECRET / AUTH0_CALLBACK_URL
|
||||||
|
# are intentionally omitted: with DEV_AUTH_ENABLED=true below, real Auth0
|
||||||
|
# login never runs, so config.Load() doesn't require them.
|
||||||
|
|
||||||
|
DEV_AUTH_ENABLED=true
|
||||||
|
|
||||||
|
PORT=8090
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
name: Claude Assistant for Gitea
|
name: Claude Assistant for Gitea
|
||||||
|
|
||||||
|
env:
|
||||||
|
DATABASE_URL: postgres://postgres:postgres@postgres:5432/inventory_2?sslmode=disable
|
||||||
|
TEST_DATABASE_URL: postgres://postgres:postgres@postgres:5432/inventory_2_test?sslmode=disable
|
||||||
|
PGUSER: postgres
|
||||||
|
PGPASSWORD: postgres
|
||||||
|
|
||||||
on:
|
on:
|
||||||
# Trigger on issue comments (works on both issues and pull requests in Gitea)
|
# Trigger on issue comments (works on both issues and pull requests in Gitea)
|
||||||
issue_comment:
|
issue_comment:
|
||||||
@@ -22,6 +28,18 @@ jobs:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
issues: write
|
issues: write
|
||||||
# Note: Gitea Actions may not require id-token: write for basic functionality
|
# Note: Gitea Actions may not require id-token: write for basic functionality
|
||||||
|
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres
|
||||||
|
env:
|
||||||
|
POSTGRES_PASSWORD: "$PGPASSWORD"
|
||||||
|
options: >-
|
||||||
|
--health-cmd pg_isready
|
||||||
|
--health-interval 10s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 5
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -37,6 +55,20 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
|
- name: Install psql and initialize the db
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y postgresql-client
|
||||||
|
PGPASSWORD=postgres psql postgres -h postgres -c 'CREATE DATABASE inventory_2'
|
||||||
|
|
||||||
|
- name: Install golang-migrate
|
||||||
|
run: |
|
||||||
|
go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
|
||||||
|
|
||||||
|
- name: Migrate schema up
|
||||||
|
run: |
|
||||||
|
migrate -path database_migrations -database "$DATABASE_URL" up
|
||||||
|
|
||||||
- name: Run Claude Assistant
|
- name: Run Claude Assistant
|
||||||
uses: markwylde/claude-code-gitea-action@gitea
|
uses: markwylde/claude-code-gitea-action@gitea
|
||||||
with:
|
with:
|
||||||
@@ -49,6 +81,12 @@ jobs:
|
|||||||
penpot_self_hosted__high_level_overview
|
penpot_self_hosted__high_level_overview
|
||||||
penpot_self_hosted__penpot_api_info
|
penpot_self_hosted__penpot_api_info
|
||||||
penpot_self_hosted__export_shape
|
penpot_self_hosted__export_shape
|
||||||
|
Bash(go:*)
|
||||||
|
Bash(gofmt:*)
|
||||||
|
Bash(./tailwind.sh)
|
||||||
|
Bash(node -v)
|
||||||
|
Bash(npm install)
|
||||||
|
Bash(psql:*)
|
||||||
gitea_api_url: "https://gitea.inventory-plus-plus.com/api/v1"
|
gitea_api_url: "https://gitea.inventory-plus-plus.com/api/v1"
|
||||||
gitea_token: ${{ secrets.GITEA_TOKEN }} # Use standard workflow token
|
gitea_token: ${{ secrets.GITEA_TOKEN }} # Use standard workflow token
|
||||||
# anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
# anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||||
@@ -67,3 +105,6 @@ jobs:
|
|||||||
- Use standard git operations when possible
|
- Use standard git operations when possible
|
||||||
env:
|
env:
|
||||||
GITEA_SERVER_URL: "https://gitea.inventory-plus-plus.com"
|
GITEA_SERVER_URL: "https://gitea.inventory-plus-plus.com"
|
||||||
|
NODE_VERSION: 24.x
|
||||||
|
POSTGRES_HOST: postgres
|
||||||
|
POSTGRES_PORT: 5432
|
||||||
|
|||||||
+1
-1
@@ -5,4 +5,4 @@ node_modules
|
|||||||
|
|
||||||
.env
|
.env
|
||||||
.env.*
|
.env.*
|
||||||
.env.example
|
!.env.gitea-claude-bot-dev
|
||||||
|
|||||||
@@ -1,128 +0,0 @@
|
|||||||
package ui_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"flag"
|
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
|
|
||||||
"ruben/inventory2/domains/accounts"
|
|
||||||
"ruben/inventory2/domains/authentication"
|
|
||||||
etsy_platform "ruben/inventory2/domains/platforms/etsy"
|
|
||||||
"ruben/inventory2/domains/raw_events"
|
|
||||||
"ruben/inventory2/domains/reports"
|
|
||||||
"ruben/inventory2/internal/testdb"
|
|
||||||
"ruben/inventory2/server/auth"
|
|
||||||
"ruben/inventory2/server/response"
|
|
||||||
"ruben/inventory2/server/ui"
|
|
||||||
)
|
|
||||||
|
|
||||||
// update regenerates the golden files under testdata/golden from the
|
|
||||||
// current rendered output, instead of comparing against them. Review the
|
|
||||||
// diff like any other golden file before committing it, e.g.:
|
|
||||||
//
|
|
||||||
// TEST_DATABASE_URL=... go test ./server/ui/... -run TestServeTemplate_Golden -update
|
|
||||||
var update = flag.Bool("update", false, "update golden files in testdata/golden instead of comparing against them")
|
|
||||||
|
|
||||||
// TestServeTemplate_Golden is a raw-HTML snapshot/regression test: it
|
|
||||||
// exercises server/ui's real routing + templating path end-to-end (real
|
|
||||||
// templates, real Store types backed by a real Postgres connection, the
|
|
||||||
// same response.HandleResponses/HandleErrors middleware production uses -
|
|
||||||
// nothing about the render path is mocked) and diffs the rendered HTML
|
|
||||||
// against a committed golden file, so an unintentional template/markup
|
|
||||||
// change shows up as a reviewable diff instead of shipping silently.
|
|
||||||
//
|
|
||||||
// This is the "raw HTML snapshot" layer described in issue #33's UI-testing
|
|
||||||
// proposal. A browser-screenshot layer (e.g. chromedp, for catching CSS/
|
|
||||||
// layout regressions raw HTML can't) and Penpot-design-fidelity comparisons
|
|
||||||
// are separate, not-yet-implemented layers of that same proposal.
|
|
||||||
//
|
|
||||||
// Only covers logged-out pages for now (no seeded oauth session/cookie);
|
|
||||||
// extend the tests table below using testdb.SeedOAuthSession plus an
|
|
||||||
// "access_token" cookie on the request to cover authenticated pages.
|
|
||||||
//
|
|
||||||
// Like other integration tests in this repo, it's skipped (not failed) if
|
|
||||||
// TEST_DATABASE_URL is unset. If a golden file hasn't been generated yet,
|
|
||||||
// the individual case is also skipped (not failed) rather than breaking
|
|
||||||
// the suite - run with -update once, review the generated file, and commit
|
|
||||||
// it to turn that case into a real regression check.
|
|
||||||
func TestServeTemplate_Golden(t *testing.T) {
|
|
||||||
pool := testdb.Pool(t)
|
|
||||||
logger := testdb.Logger()
|
|
||||||
|
|
||||||
accts := accounts.NewStore(logger, pool)
|
|
||||||
rawEvents := raw_events.NewStore(logger, pool)
|
|
||||||
reps := reports.NewStore(logger, pool, accts)
|
|
||||||
etsy := etsy_platform.NewPlatform(
|
|
||||||
logger,
|
|
||||||
func(acctID int64) string { return "" },
|
|
||||||
"", "",
|
|
||||||
pool,
|
|
||||||
)
|
|
||||||
|
|
||||||
authr := authentication.NewDev(pool, logger)
|
|
||||||
authM := auth.NewService(logger, authr, accts)
|
|
||||||
|
|
||||||
gin.SetMode(gin.TestMode)
|
|
||||||
router := gin.New()
|
|
||||||
router.Use(
|
|
||||||
authM.Identify,
|
|
||||||
response.HandleResponses,
|
|
||||||
response.HandleErrors,
|
|
||||||
)
|
|
||||||
|
|
||||||
ui.Routes(
|
|
||||||
logger,
|
|
||||||
router.Group("/ui"),
|
|
||||||
"/ui",
|
|
||||||
rawEvents,
|
|
||||||
accts,
|
|
||||||
reps,
|
|
||||||
etsy,
|
|
||||||
authM.Authenticate(),
|
|
||||||
true,
|
|
||||||
)
|
|
||||||
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
path string
|
|
||||||
wantStatus int
|
|
||||||
}{
|
|
||||||
{name: "home-logged-out", path: "/ui", wantStatus: http.StatusOK},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
req := httptest.NewRequest(http.MethodGet, tt.path, nil)
|
|
||||||
rec := httptest.NewRecorder()
|
|
||||||
router.ServeHTTP(rec, req)
|
|
||||||
|
|
||||||
require.Equal(t, tt.wantStatus, rec.Code, "unexpected status for %s", tt.path)
|
|
||||||
|
|
||||||
got := rec.Body.Bytes()
|
|
||||||
golden := filepath.Join("testdata", "golden", tt.name+".html")
|
|
||||||
|
|
||||||
if *update {
|
|
||||||
require.NoError(t, os.MkdirAll(filepath.Dir(golden), 0o755))
|
|
||||||
require.NoError(t, os.WriteFile(golden, got, 0o644))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
want, err := os.ReadFile(golden)
|
|
||||||
if os.IsNotExist(err) {
|
|
||||||
t.Skipf(
|
|
||||||
"golden file %s does not exist yet; generate it once via `go test ./server/ui/... -run TestServeTemplate_Golden -update` (requires TEST_DATABASE_URL), then review and commit it",
|
|
||||||
golden,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
require.NoError(t, err, "reading golden file %s", golden)
|
|
||||||
|
|
||||||
require.Equal(t, string(want), string(got), "rendered output for %s no longer matches %s; if this change is intentional, regenerate with -update", tt.path, golden)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user