Repository navigation
ci: gate integrity — stop hiding failing suites, gate the app too #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
aee4755
fix(examples): reference-app tsconfig for TypeScript 7
sebyx07 029c653
build(examples): put the reference app in the root build graph
sebyx07 3f4b75d
feat(testing): register the fixture bag so app tests can run
sebyx07 8b392a0
feat(core): announce listening sockets so a test can reach its own port
sebyx07 fbea966
refactor(cli): one verify implementation, one definition of shippable
sebyx07 e42805c
ci: stop excluding opt-in test suites, gate the reference app too
sebyx07 9c28ff9
fix(ci): one gate each for the framework and the reference app
sebyx07 7bf45ad
fix(ci): green the advisory app gate, harden checkout, count lines right
sebyx07 55484a7
docs: state what verify emits and what a test name is for
sebyx07 327b549
test: pin the skipped flag the --json step shape promises
sebyx07 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # Bun runtime + test config for Postly. https://bun.sh/docs/runtime/bunfig | ||
| # | ||
| # One preload, two jobs: `scripts/test-setup.ts` pulls in @ultimat3/testing's preload (frozen | ||
| # clock, seeded RNG, sealed network, matchers) and registers the fixtures the app owns. | ||
|
|
||
| [install] | ||
| exact = false | ||
| production = false | ||
|
|
||
| [test] | ||
| root = "." | ||
| preload = ["./scripts/test-setup.ts"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 81a4b14eea7ebdea |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| // Postly's test preload: the fixtures the APP owns. `clock`, `mail` and `runJobs` arrive with | ||
| // the framework's own preload, imported below — an app registers only what the framework cannot | ||
| // know, which here is the seed graph and how a member becomes an actor. | ||
| // | ||
| // [test] | ||
| // preload = ["./scripts/test-setup.ts"] | ||
| // | ||
| // The framework is imported by relative path rather than by `@ultimat3/*`: this directory is not | ||
| // a workspace member yet (issue #9), and a preload runs before anything else, so it must not | ||
| // depend on workspace symlinks. A generated app writes `@ultimat3/testing` here. For the same | ||
| // reason `scripts/` is not in tsconfig's `include` — a composite project cannot reach across | ||
| // into another one's sources. Both go away when the app joins the workspace. | ||
|
|
||
| import { assert, userActor } from '../../../packages/core/src/index'; | ||
| import type { Driver, EntityCore, Repo, Seed } from '../../../packages/entity/src/index'; | ||
| import { memoryDriver, seedId } from '../../../packages/entity/src/index'; | ||
| import { defineFixtures } from '../../../packages/testing/src/index'; | ||
| import '../../../packages/testing/src/preload'; | ||
|
|
||
| /** Every seeded row carries an id; the rest of the columns are the entity's business. */ | ||
| export interface SeedRow { | ||
| readonly id: string; | ||
| readonly [column: string]: unknown; | ||
| } | ||
|
|
||
| export interface SeedHandle { | ||
| /** `pick({ draft: 'post:draft-money' })` — seed labels in, rows out, aliased at the call site. */ | ||
| pick<M extends Readonly<Record<string, string>>>( | ||
| labels: M, | ||
| ): Promise<{ readonly [K in keyof M]: SeedRow }>; | ||
| } | ||
|
|
||
| const idOf = (row: unknown): string | undefined => { | ||
| const value = (row as { readonly id?: unknown }).id; | ||
| return typeof value === 'string' ? value : undefined; | ||
| }; | ||
|
|
||
| /** | ||
| * Rows are captured on the way in rather than read back out: a tenant-scoped entity refuses an | ||
| * unscoped read, so a fixture would have to name the org before it could fetch the org. Insert | ||
| * still runs `$parse` and the invariants, so seeding still tests the schema. | ||
| */ | ||
| const capturingDriver = (rows: Map<string, SeedRow>): Driver => { | ||
| const base = memoryDriver(); | ||
| return { | ||
| repo: <Row>(entity: EntityCore<Row>): Repo<Row> => { | ||
| const inner = base.repo(entity); | ||
| return { | ||
| ...inner, | ||
| insert: async (values, options) => { | ||
| const row = await inner.insert(values, options); | ||
| const id = idOf(row); | ||
| if (id !== undefined) rows.set(id, row as SeedRow); | ||
| return row; | ||
| }, | ||
| }; | ||
| }, | ||
| }; | ||
| }; | ||
|
|
||
| /** A fresh graph per call: two tests must never see each other's writes. */ | ||
| const handleFor = (seed: Seed): SeedHandle => { | ||
| const rows = new Map<string, SeedRow>(); | ||
| const ready = seed.run({ driver: capturingDriver(rows) }); | ||
|
|
||
| return { | ||
| pick: async <M extends Readonly<Record<string, string>>>(labels: M) => { | ||
| await ready; | ||
| const picked: Record<string, SeedRow> = {}; | ||
| for (const [alias, label] of Object.entries(labels)) { | ||
| const row = rows.get(seedId(label)); | ||
| assert( | ||
| row !== undefined, | ||
| `seed "${seed.name}" has no row labelled "${label}"`, | ||
| `add it to packages/db/seeds/${seed.name}.ts with id: id('${label}')`, | ||
| ); | ||
| picked[alias] = row; | ||
| } | ||
| return picked as { readonly [K in keyof M]: SeedRow }; | ||
| }, | ||
| }; | ||
| }; | ||
|
|
||
| /** Imported on demand, so a test that never seeds never loads the entity graph. */ | ||
| const createSeed = async (): Promise<(name: string) => SeedHandle> => { | ||
| const { dev } = await import('../packages/db/seeds/dev'); | ||
| const seeds: Readonly<Record<string, Seed>> = { dev }; | ||
| return (name) => { | ||
| const seed = seeds[name]; | ||
| assert( | ||
| seed !== undefined, | ||
| `no seed named "${name}" — known seeds: ${Object.keys(seeds).join(', ')}`, | ||
| 'x db seed --list, then use one of the names it prints', | ||
| ); | ||
| return handleFor(seed); | ||
| }; | ||
| }; | ||
|
|
||
| /** A member row is the actor: same org, and its membership role is the authz role. */ | ||
| const actorFor = (member: SeedRow) => | ||
| userActor({ | ||
| id: String(member['userId'] ?? member.id), | ||
| orgId: String(member['orgId']), | ||
| roles: [String(member['role'])], | ||
| }); | ||
|
|
||
| defineFixtures({ | ||
| seed: createSeed, | ||
| actorFor: () => actorFor, | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.