Repository navigation
ci: pin the artifacts catalog on docker image bumps #6744
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
7 commits
Select commit
Hold shift + click to select a range
89dfbbe
ci(repo): accumulate slim-service pins in a single catalog PR
claude 14a0bff
ci(repo): drop the artifacts catalog PR from slim mirroring
avallete cde5400
ci(repo): pin the artifacts catalog on docker image bumps
avallete 0e235cd
ci(repo): skip OrioleDB when pinning the slim catalog
avallete fcfa528
Merge branch 'develop' into avallete/amazing-cannon-157f6c
avallete 9812ba0
ci(repo): pin only published Dockerfile tag changes
avallete 355699d
ci(repo): keep the mirror payload check private
avallete 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| import { describe, expect, test } from "bun:test"; | ||
|
|
||
| import { InvalidPayloadError } from "./slim-mirror-payload.ts"; | ||
| import { | ||
| CATALOG_PATH, | ||
| planArtifactCatalogUpdate, | ||
| type ReleasePublication, | ||
| } from "./sync-artifacts-catalog.ts"; | ||
|
|
||
| const DIGEST_B = `sha256:${"b".repeat(64)}`; | ||
| const POSTGRES_17 = `ghcr.io/supabase/cli/postgres:17.6.1.168@sha256:${"9".repeat(64)}`; | ||
| const POSTGRES_15 = `ghcr.io/supabase/cli/postgres:15.14.1.168@sha256:${"f".repeat(64)}`; | ||
|
|
||
| const fixture = `const workloadCatalog = { | ||
| database: definition( | ||
| "postgres", | ||
| "17.6.1.168", | ||
| "${POSTGRES_17}", | ||
| "bin/supabase-postgres-start", | ||
| ["bin/supabase-postgres-start"], | ||
| { "15.14.1.168": "${POSTGRES_15}" }, | ||
| ), | ||
| rest: definition("postgrest", "v16.2", "ghcr.io/supabase/cli/postgrest:v16.2", "bin/postgrest"), | ||
| analytics: definition( | ||
| "analytics", | ||
| "v1.50.9", | ||
| "ghcr.io/supabase/cli/analytics:v1.50.9@sha256:${"a".repeat(64)}", | ||
| "bin/logflare", | ||
| ), | ||
| }; | ||
| `; | ||
|
|
||
| const published = (digest?: string): ReleasePublication => ({ status: "published", digest }); | ||
|
|
||
| describe("planArtifactCatalogUpdate", () => { | ||
| test("pins Dockerfile tags that changed and leaves the other postgres line", async () => { | ||
| const plan = await planArtifactCatalogUpdate({ | ||
| baseDockerfile: `FROM supabase/postgres:17.6.1.168 AS pg | ||
| FROM postgrest/postgrest:v16.2 AS postgrest | ||
| FROM supabase/logflare:1.50.9 AS logflare | ||
| `, | ||
| dockerfile: `FROM supabase/postgres:17.6.1.171 AS pg | ||
| FROM library/kong:2.8.1 AS kong | ||
| FROM postgrest/postgrest:v16.3 AS postgrest | ||
| FROM supabase/logflare:1.50.9 AS logflare | ||
| `, | ||
| catalog: fixture, | ||
| publication: async (service) => published(service === "postgres" ? DIGEST_B : undefined), | ||
| }); | ||
|
|
||
| expect(plan.updates.map((update) => `${update.service} ${update.version}`)).toEqual([ | ||
| "postgres 17.6.1.171", | ||
| "postgrest v16.3", | ||
| ]); | ||
| expect(plan.source).toContain(`"ghcr.io/supabase/cli/postgres:17.6.1.171@${DIGEST_B}"`); | ||
| expect(plan.source).toContain(`"${POSTGRES_15}"`); | ||
| expect(plan.source).toContain(`"ghcr.io/supabase/cli/postgrest:v16.3"`); | ||
| expect(plan.source).toContain(`"v1.50.9"`); | ||
| expect(plan.skipped).toEqual([]); | ||
| }); | ||
|
|
||
| test("a missing release blocks the commit and OrioleDB does not", async () => { | ||
| const movesPostgres = await planArtifactCatalogUpdate({ | ||
| baseDockerfile: "FROM supabase/postgres:17.6.1.168 AS pg\n", | ||
| dockerfile: `FROM supabase/postgres:17.6.1.171 AS pg | ||
| FROM postgrest/postgrest:v16.3 AS postgrest | ||
| `, | ||
| catalog: fixture, | ||
| publication: async () => ({ status: "missing" }), | ||
| }); | ||
| expect(movesPostgres.updates).toEqual([]); | ||
| expect(movesPostgres.source).toBe(fixture); | ||
| expect(movesPostgres.skipped.every((skip) => skip.blocking)).toBe(true); | ||
|
|
||
| const oriole = await planArtifactCatalogUpdate({ | ||
| baseDockerfile: | ||
| "FROM supabase/postgres:17.6.1.168 AS pg\nFROM postgrest/postgrest:v16.2 AS postgrest\n", | ||
| dockerfile: `FROM supabase/postgres:16.0.0.1-orioledb AS pg | ||
| FROM postgrest/postgrest:v16.3 AS postgrest | ||
| `, | ||
| catalog: fixture, | ||
| publication: async () => published(), | ||
| }); | ||
| expect(oriole.updates.map((update) => update.service)).toEqual(["postgrest"]); | ||
| expect(oriole.skipped).toEqual([ | ||
| { | ||
| alias: "pg", | ||
| reason: "pg supabase/postgres:16.0.0.1-orioledb has no slim image.", | ||
| blocking: false, | ||
| }, | ||
| ]); | ||
| expect(oriole.source).toContain(`"${POSTGRES_17}"`); | ||
| }); | ||
|
|
||
| test("refuses a backward pin and a tag that would escape the catalog string", async () => { | ||
| const backward = await planArtifactCatalogUpdate({ | ||
| baseDockerfile: "FROM supabase/postgres:17.6.1.170 AS pg\n", | ||
| dockerfile: "FROM supabase/postgres:17.6.1.171 AS pg\n", | ||
| catalog: fixture.replaceAll("17.6.1.168", "17.6.1.173"), | ||
| publication: async () => { | ||
| throw new Error("publication lookup"); | ||
| }, | ||
| }); | ||
| expect(backward.updates).toEqual([]); | ||
| expect(backward.skipped.map((skip) => skip.blocking)).toEqual([true]); | ||
| expect(backward.source).toContain(`"17.6.1.173"`); | ||
|
|
||
| await expect( | ||
| planArtifactCatalogUpdate({ | ||
| dockerfile: 'FROM supabase/gotrue:v1" AS gotrue\n', | ||
| catalog: fixture, | ||
| publication: async () => published(), | ||
| }), | ||
| ).rejects.toThrow(InvalidPayloadError); | ||
| }); | ||
| }); | ||
|
|
||
| describe("against the real catalog", () => { | ||
| test("every slim Dockerfile alias is a catalog entry", async () => { | ||
| const dockerfile = await Bun.file("apps/cli/src/shared/services/Dockerfile").text(); | ||
| const catalog = await Bun.file(CATALOG_PATH).text(); | ||
| const plan = await planArtifactCatalogUpdate({ | ||
| dockerfile, | ||
| catalog, | ||
| publication: async () => published(`sha256:${"a".repeat(64)}`), | ||
| }); | ||
|
|
||
| expect( | ||
| plan.skipped.filter((skip) => skip.blocking && !skip.reason.includes("older than")), | ||
| ).toEqual([]); | ||
| }); | ||
| }); | ||
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.