Skip to content

Preview: Replace instance exports with synthetic fixtures - #68

Merged
whereareiam merged 1 commit into
devfrom
refactor/synthetic-fixtures
Oct 3, 2026
Merged

whereareiam merged 1 commit into
devfrom
refactor/synthetic-fixtures

Conversation

@whereareiam

Copy link
Copy Markdown
Owner

The local preview's fixtures were exports from a real Forgejo instance mixed with hand-made additions. This replaces them with invented data declared in one consistent format.

Why

  • The fixtures contained real repository content, an instance hostname and a personal commit email. The new ones use alex, sam and acme and contain nothing from a real instance. Earlier commits are left as they are; history is not rewritten.
  • The exported repositories did not load in a fresh clone. Git does not keep their empty refs/ directories, so they were not valid repositories and git push --mirror fell back to pushing this repository's own history into both fixture repositories.
  • The importer deleted SQLite's write-ahead log before copying the database, which could drop Forgejo's most recent writes.
  • Several states could not be previewed at all: packages, issues, pull requests, draft and prerelease releases, and workflow logs with real lines.

What the preview has now

acme/webapp alex/notes
History 13 commits on 5 branches, 4 tags 2 commits
Issues 6 (open and closed, labels, milestones, comments) none
Pull requests 4: open, draft, merged, closed none
Releases 5: three stable (one with assets), a prerelease, a draft none
Packages 2 versions 1
Workflow runs 3: passed, failed, tag release; with step logs and commit statuses none

alex/notes stays small on purpose so empty states can be checked. sam is a second user and a member of an acme team.

How it works

  • dev/fixtures/owner.json declares users, the organization and teams. Each folder under dev/fixtures/repository/ holds one repository: repository.json, history.json, the files of each commit, and workflow runs with their logs.
  • The seeder replays each history into real commits and creates everything else through Forgejo's API, acting as the declared author.
  • What the API cannot create is written to the database from the same declarations: past timestamps, the activity feed, finished workflow runs and their commit statuses. Every row is checked against the live schema, so a Forgejo upgrade that renames or adds a required column stops seeding with the table and column named.
  • All times are daysAgo, resolved at seeding, so the feed and contribution heatmap always look recent.
  • A repository that already exists is not seeded again. bun dev:forgejo:reset empties the volume for a fresh seed.

dev/fixtures/README.md documents the format. The preview's default login changes from whereareiam to alex.

Checks

  • bun commit passes (402 tests). New tests cover the fixture clock, the log parser and line-offset encoding, and the consistency of the checked-in fixtures (every commit has files, every referenced user, label, milestone, branch and commit exists).
  • Seeded an empty volume three times end to end on Forgejo 16.0.3. Verified through the API that every declared object exists with the declared state, author and date, and that a second seed leaves existing repositories untouched.
  • 31 pages across the dashboard, profiles, organization, repository, issues, pull requests, releases, tags, Actions and packages return 200 without template errors. Checked visually: repository home, releases, profile, dashboard feed and heatmap, the pull request with its failing check, the Actions list, and a failed job's step log.
  • No row in the preview's issues, comments or activity is stamped with the seed time afterwards.

Known limits: the merge commit of the merged pull request is created at seed time, and the Actions sidebar marks both workflows with Forgejo's "no matching runner" warning because the preview has no runner.

🤖 Generated with Claude Code

The preview's fixtures were exports from a real Forgejo instance mixed
with hand-made additions. The exported repositories were also unusable
in a fresh clone: Git does not keep their empty refs directories, so
the seeder silently pushed this repository's own history instead.

Fixtures are now invented and declared under dev/fixtures: owner.json
for users and the organization, and one folder per repository holding
its description, history, commit files and workflow runs. The seeder
builds each history as real commits and creates issues, pull requests,
releases and packages through the API. What the API cannot create is
written to the database from the same declarations: past timestamps,
the activity feed, finished workflow runs with logs, and their commit
statuses. Those rows are checked against the live schema, so a Forgejo
upgrade that changes a column fails by naming it.

Times are relative to the day of seeding. The preview user is now alex,
and dev:forgejo:reset empties the volume for a fresh seed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@whereareiam whereareiam added the skip-changelog Internal change excluded from release notes label Oct 3, 2026
@whereareiam
whereareiam merged commit be3197b into dev Oct 3, 2026
8 of 9 checks passed
@whereareiam
whereareiam deleted the refactor/synthetic-fixtures branch October 3, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Internal change excluded from release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant