Prep for the upcoming E2E Playwright CI workflow. The full seed (1200 users, 5000 tracks, 100k play events, 10k messages, etc.) takes ~60s and produces a lot of fixture data the suite never reads. A CI run just needs the 5 test accounts the auth fixture logs in as (admin/artist/user/mod/new) plus a small content set so player / playlist tests have something to render. New flag: go run ./cmd/tools/seed --ci CIConfig (cmd/tools/seed/config.go): - TotalUsers = 5 (== len(testAccounts), so SeedUsers' "remaining" branch is a no-op — only the 5 hardcoded accounts get inserted). - Tracks = 10, Playlists = 3 (covers player + playlist suites). - Albums = 0, all social/chat/live/marketplace/analytics/etc. = 0. main.go gates the heavy seeders (Social / Chat / Live / Marketplace / Analytics / Content / Moderation / Notifications / Misc) behind `if !cfg.CIMode`, prints a one-line "skipping ..." banner so the run log makes the choice obvious. The Users / Tracks / Playlists path is unchanged — same code, same validation pass at the end. Time: ~5s in CI mode (bcrypt cost 12 × 5 + a handful of bulk inserts) vs the ~60s minimal mode and ~5min full mode, measured locally against a tmpfs Postgres. Validate() and the SUMMARY printout work unchanged — empty tables just show "0 rows", and the orphan-FK checks remain useful (and pass trivially when the heavy seeders are skipped). modeName() returns "CI" so the boot banner reflects the choice. go build ./... clean. Help output: -ci Bare-minimum seed for E2E CI (...) -minimal Use reduced volumes (50 users, 200 tracks) for fast dev Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
214 lines
4.3 KiB
Go
214 lines
4.3 KiB
Go
package main
|
|
|
|
import "flag"
|
|
|
|
// Config holds all seed volume parameters.
|
|
type Config struct {
|
|
// CIMode: when true, main.go only runs SeedUsers / SeedTracks /
|
|
// SeedPlaylists and skips Chat/Live/Marketplace/Analytics/Content/
|
|
// Moderation/Notifications/Misc. Used by E2E CI to avoid the ~60s
|
|
// full seed when all the suite needs is the 5 test accounts and a
|
|
// handful of tracks/playlists.
|
|
CIMode bool
|
|
|
|
// Users
|
|
TotalUsers int
|
|
NormalUsers int
|
|
Artists int
|
|
Labels int
|
|
Moderators int
|
|
Admins int
|
|
|
|
// Content
|
|
Tracks int
|
|
Albums int
|
|
Playlists int
|
|
PlaylistMinTracks int
|
|
PlaylistMaxTracks int
|
|
|
|
// Social
|
|
Follows int
|
|
TrackLikes int
|
|
TrackReposts int
|
|
Comments int
|
|
CommentLikes int
|
|
|
|
// Chat
|
|
Conversations int
|
|
Messages int
|
|
|
|
// Live
|
|
PastLiveStreams int
|
|
LiveStreams int
|
|
|
|
// Marketplace
|
|
Products int
|
|
Orders int
|
|
ProductReviews int
|
|
|
|
// Analytics
|
|
PlayEvents int
|
|
ProfileViews int
|
|
AnalyticsMonths int
|
|
|
|
// Notifications
|
|
Notifications int
|
|
|
|
// Files
|
|
FileEntries int
|
|
|
|
// Misc
|
|
Groups int
|
|
SupportTickets int
|
|
APIKeys int
|
|
Announcements int
|
|
Reports int
|
|
DataExports int
|
|
GearItems int
|
|
Courses int
|
|
}
|
|
|
|
// FullConfig returns the full-scale configuration (~1200 users, ~5000 tracks).
|
|
func FullConfig() Config {
|
|
return Config{
|
|
TotalUsers: 1200,
|
|
NormalUsers: 1000,
|
|
Artists: 150,
|
|
Labels: 30,
|
|
Moderators: 15,
|
|
Admins: 5,
|
|
|
|
Tracks: 5000,
|
|
Albums: 300,
|
|
Playlists: 800,
|
|
PlaylistMinTracks: 5,
|
|
PlaylistMaxTracks: 50,
|
|
|
|
Follows: 15000,
|
|
TrackLikes: 30000,
|
|
TrackReposts: 5000,
|
|
Comments: 8000,
|
|
CommentLikes: 2000,
|
|
|
|
Conversations: 500,
|
|
Messages: 10000,
|
|
|
|
PastLiveStreams: 200,
|
|
LiveStreams: 5,
|
|
|
|
Products: 400,
|
|
Orders: 600,
|
|
ProductReviews: 300,
|
|
|
|
PlayEvents: 100000,
|
|
ProfileViews: 20000,
|
|
AnalyticsMonths: 6,
|
|
|
|
Notifications: 15000,
|
|
|
|
FileEntries: 6000,
|
|
|
|
Groups: 40,
|
|
SupportTickets: 80,
|
|
APIKeys: 30,
|
|
Announcements: 10,
|
|
Reports: 60,
|
|
DataExports: 15,
|
|
GearItems: 200,
|
|
Courses: 25,
|
|
}
|
|
}
|
|
|
|
// MinimalConfig returns a reduced configuration for fast dev iteration.
|
|
func MinimalConfig() Config {
|
|
return Config{
|
|
TotalUsers: 50,
|
|
NormalUsers: 30,
|
|
Artists: 12,
|
|
Labels: 3,
|
|
Moderators: 2,
|
|
Admins: 3,
|
|
|
|
Tracks: 200,
|
|
Albums: 25,
|
|
Playlists: 40,
|
|
PlaylistMinTracks: 3,
|
|
PlaylistMaxTracks: 15,
|
|
|
|
Follows: 200,
|
|
TrackLikes: 500,
|
|
TrackReposts: 100,
|
|
Comments: 150,
|
|
CommentLikes: 50,
|
|
|
|
Conversations: 20,
|
|
Messages: 200,
|
|
|
|
PastLiveStreams: 10,
|
|
LiveStreams: 2,
|
|
|
|
Products: 30,
|
|
Orders: 40,
|
|
ProductReviews: 20,
|
|
|
|
PlayEvents: 2000,
|
|
ProfileViews: 400,
|
|
AnalyticsMonths: 2,
|
|
|
|
Notifications: 300,
|
|
|
|
FileEntries: 250,
|
|
|
|
Groups: 5,
|
|
SupportTickets: 10,
|
|
APIKeys: 5,
|
|
Announcements: 3,
|
|
Reports: 8,
|
|
DataExports: 3,
|
|
GearItems: 20,
|
|
Courses: 5,
|
|
}
|
|
}
|
|
|
|
// CIConfig returns the bare-minimum configuration for E2E CI:
|
|
// just the 5 hardcoded test accounts (admin/artist/user/mod/new) plus
|
|
// a small fixture set of tracks and playlists. main.go skips the
|
|
// non-essential seeders when CIMode is true.
|
|
func CIConfig() Config {
|
|
return Config{
|
|
CIMode: true,
|
|
|
|
// 5 test accounts only — TotalUsers == len(testAccounts) so
|
|
// SeedUsers' "remaining" branch is a no-op.
|
|
TotalUsers: 5,
|
|
NormalUsers: 2,
|
|
Artists: 1,
|
|
Labels: 0,
|
|
Moderators: 1,
|
|
Admins: 1,
|
|
|
|
// Small fixture set so player / playlist tests have content.
|
|
Tracks: 10,
|
|
Albums: 0,
|
|
Playlists: 3,
|
|
PlaylistMinTracks: 1,
|
|
PlaylistMaxTracks: 3,
|
|
|
|
// Everything else stays at zero — corresponding seeders are
|
|
// either skipped via CIMode or run as no-ops on zero counts.
|
|
}
|
|
}
|
|
|
|
// ParseFlags parses CLI flags and returns the appropriate config.
|
|
func ParseFlags() Config {
|
|
minimal := flag.Bool("minimal", false, "Use reduced volumes (50 users, 200 tracks) for fast dev")
|
|
ci := flag.Bool("ci", false, "Bare-minimum seed for E2E CI (5 test accounts + 10 tracks + 3 playlists, skips chat/live/marketplace/analytics)")
|
|
flag.Parse()
|
|
if *ci {
|
|
return CIConfig()
|
|
}
|
|
if *minimal {
|
|
return MinimalConfig()
|
|
}
|
|
return FullConfig()
|
|
}
|