ci: use libsqld server in CI instead of Turso CLI

This commit is contained in:
2024-06-13 05:33:10 -04:00
parent 0db6fa9f70
commit 8f861ceca0
4 changed files with 31 additions and 6 deletions

View File

@@ -13,10 +13,10 @@ jobs:
- uses: oven-sh/setup-bun@v1
- name: Install
run: bun install
- name: Install Turso CLI
run: curl -sSfL https://get.tur.so/install.sh | bash
- name: Install libsql server
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/tursodatabase/libsql/releases/download/libsql-server-v0.24.14/libsql-server-installer.sh | sh
- name: Test
run: bun run test
run: bun run test --dbCommand \"~/.cargo/bin/sqld --http-listen-addr=127.0.0.1:3000\"
# TODO: uncomment this when https://github.com/cloudflare/workers-sdk/issues/5082 is fixed
# - name: Verify env
# run: bun env:verify

BIN
bun.lockb

Binary file not shown.

View File

@@ -31,6 +31,7 @@
"@cloudflare/workers-types": "^4.20240403.0",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/bun": "^1.1.2",
"@types/yargs": "^17.0.32",
"drizzle-kit": "^0.22.6",
"msw": "^2.3.0",
"prettier": "^3.2.5",
@@ -38,6 +39,7 @@
"ts-morph": "^22.0.0",
"typescript": "^5.4.5",
"wrangler": "^3.47.0",
"yargs": "^17.7.2",
"zx": "^8.1.2"
}
}

View File

@@ -1,6 +1,29 @@
import yargs from "yargs";
import { $ } from "zx";
const tursoProcess = $`turso dev --port 3000`.nothrow();
const args = await yargs(process.argv).option("dbCommand", {
alias: "db",
type: "string",
description: "Command to spin up the database",
demandOption: true,
}).argv;
const filteredKeys = new Set(["_", "dbCommand", "db", "$0", "db-command"]);
const positionalArgs = Object.entries(args)
.filter(([key]) => !filteredKeys.has(key))
.map(([key, value]) => {
if (typeof value === "boolean") {
return `--${key}`;
}
return `--${key}=${value}`;
})
.concat(args._.slice(2).map((arg) => `${arg}`));
const dbProcess = $({
quote: (arg) => arg,
verbose: true,
})`${args.dbCommand}`.nothrow();
process.env.TURSO_URL = "http://127.0.0.1:3000";
process.env.TURSO_AUTH_TOKEN = "asd";
@@ -8,6 +31,6 @@ await $`bun db:migrate`.nothrow();
await $({
verbose: true,
quote: (arg) => arg,
})`FORCE_COLOR=1 bun test ${process.argv.slice(2).join(" ")}`.nothrow();
})`FORCE_COLOR=1 bun test ${positionalArgs.join(" ")}`.nothrow();
await tursoProcess.kill("SIGINT");
await dbProcess.kill("SIGINT");