-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Make verdaccio available for all tests in CI #10670
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,40 +5,16 @@ | |
import { rm, writeFile, mkdir, exists, cp } from "fs/promises"; | ||
import { readdirSorted } from "../dummy.registry"; | ||
import { tmpdir } from "os"; | ||
import { fork, ChildProcess } from "child_process"; | ||
import { beforeAll, afterAll, beforeEach, afterEach, test, expect, describe } from "bun:test"; | ||
|
||
expect.extend({ | ||
toBeValidBin, | ||
toHaveBins, | ||
}); | ||
|
||
var verdaccioServer: ChildProcess; | ||
var testCounter: number = 0; | ||
var port: number = 4873; | ||
var packageDir: string; | ||
|
||
beforeAll(async () => { | ||
verdaccioServer = fork( | ||
require.resolve("verdaccio/bin/verdaccio"), | ||
["-c", join(import.meta.dir, "verdaccio.yaml"), "-l", `${port}`], | ||
{ silent: true, execPath: "bun" }, | ||
); | ||
|
||
await new Promise<void>(done => { | ||
verdaccioServer.on("message", (msg: { verdaccio_started: boolean }) => { | ||
if (msg.verdaccio_started) { | ||
console.log("Verdaccio started"); | ||
done(); | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
afterAll(() => { | ||
verdaccioServer.kill(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
packageDir = mkdtempSync(join(realpathSync(tmpdir()), "bun-install-registry-" + testCounter++ + "-")); | ||
env.BUN_INSTALL_CACHE_DIR = join(packageDir, ".bun-cache"); | ||
|
@@ -48,7 +24,7 @@ | |
` | ||
[install] | ||
cache = false | ||
registry = "http://localhost:${port}/" | ||
registry = "http://localhost:${env.VERDACCIO_PORT}/" | ||
`, | ||
); | ||
}); | ||
|
@@ -85,7 +61,7 @@ | |
env, | ||
}); | ||
|
||
expect(await exited).toBe(0); | ||
Check failure on line 64 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-x64-baseline / Tests (20)error: expect(received).toBe(expected)
Check failure on line 64 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-x64 / Tests (20)error: expect(received).toBe(expected)
Check failure on line 64 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-aarch64 / Tests (20)error: expect(received).toBe(expected)
|
||
|
||
const initialHash = Bun.hash(await file(join(packageDir, "bun.lockb")).arrayBuffer()); | ||
|
||
|
@@ -182,7 +158,7 @@ | |
stderr: stdio, | ||
env, | ||
}); | ||
expect(await exited).toBe(0); | ||
Check failure on line 161 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-x64-baseline / Tests (20)error: expect(received).toBe(expected)
Check failure on line 161 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-x64 / Tests (20)error: expect(received).toBe(expected)
Check failure on line 161 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-aarch64 / Tests (20)error: expect(received).toBe(expected)
|
||
|
||
await Promise.all([ | ||
(async () => | ||
|
@@ -216,7 +192,7 @@ | |
env, | ||
}); | ||
|
||
expect(await exited).toBe(0); | ||
Check failure on line 195 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-x64-baseline / Tests (20)error: expect(received).toBe(expected)
Check failure on line 195 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-x64 / Tests (20)error: expect(received).toBe(expected)
Check failure on line 195 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-aarch64 / Tests (20)error: expect(received).toBe(expected)
|
||
expect(await file(join(packageDir, "node_modules", "bin-change-dir", "package.json")).json()).toMatchObject({ | ||
name: "bin-change-dir", | ||
version: prod ? "1.0.0" : "1.0.1", | ||
|
@@ -1270,7 +1246,7 @@ | |
|
||
var err = await new Response(stderr).text(); | ||
var out = await new Response(stdout).text(); | ||
expect(err).toContain("Saved lockfile"); | ||
Check failure on line 1249 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-x64-baseline / Tests (20)error: expect(received).toContain(expected)
Check failure on line 1249 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-x64-baseline / Tests (20)error: expect(received).toContain(expected)
Check failure on line 1249 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-x64-baseline / Tests (20)error: expect(received).toContain(expected)
Check failure on line 1249 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-x64-baseline / Tests (20)error: expect(received).toContain(expected)
Check failure on line 1249 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-x64-baseline / Tests (20)error: expect(received).toContain(expected)
Check failure on line 1249 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-x64-baseline / Tests (20)error: expect(received).toContain(expected)
Check failure on line 1249 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-x64 / Tests (20)error: expect(received).toContain(expected)
Check failure on line 1249 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-x64 / Tests (20)error: expect(received).toContain(expected)
Check failure on line 1249 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-x64 / Tests (20)error: expect(received).toContain(expected)
Check failure on line 1249 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-x64 / Tests (20)error: expect(received).toContain(expected)
Check failure on line 1249 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-x64 / Tests (20)error: expect(received).toContain(expected)
Check failure on line 1249 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-x64 / Tests (20)error: expect(received).toContain(expected)
Check failure on line 1249 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-aarch64 / Tests (20)error: expect(received).toContain(expected)
Check failure on line 1249 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-aarch64 / Tests (20)error: expect(received).toContain(expected)
Check failure on line 1249 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-aarch64 / Tests (20)error: expect(received).toContain(expected)
Check failure on line 1249 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-aarch64 / Tests (20)error: expect(received).toContain(expected)
Check failure on line 1249 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-aarch64 / Tests (20)error: expect(received).toContain(expected)
Check failure on line 1249 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-aarch64 / Tests (20)error: expect(received).toContain(expected)
|
||
expect(err).not.toContain("not found"); | ||
expect(err).not.toContain("error:"); | ||
expect(err).not.toContain("panic:"); | ||
|
@@ -1559,7 +1535,7 @@ | |
}); | ||
|
||
const err = await Bun.readableStreamToText(stderr); | ||
expect(err).toContain("Saved lockfile"); | ||
Check failure on line 1538 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-x64-baseline / Tests (20)error: expect(received).toContain(expected)
Check failure on line 1538 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-x64 / Tests (20)error: expect(received).toContain(expected)
Check failure on line 1538 in test/cli/install/registry/bun-install-registry.test.ts GitHub Actions / Test linux-aarch64 / Tests (20)error: expect(received).toContain(expected)
|
||
expect(err).not.toContain("not found"); | ||
expect(err).not.toContain("error:"); | ||
expect(err).not.toContain("panic:"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dylan-conway this won't quite work. We need to check if it's CI and then use the CI version, but in development we still want to do this. I suggest having an
isCI