8000 feat(cli): rename compile back to analyze, as a function and a command by colinhacks · Pull Request #195 · colinhacks/reylo · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
8000 Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/scripts/install-check.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Installs reylo as a project does, from the packages a run built, on the platform it runs on, and
// checks that the engine installed for that platform types and runs a query: the nine packages
// published to a registry of the check's own (Verdaccio, holding nothing else), `npm install reylo`
// in a fresh project, which must bring this platform's engine package alone, `reylo compile` on a
// in a fresh project, which must bring this platform's engine package alone, `reylo analyze` on a
// SQLite query through the `reylo` command npm installed, a program run under the reylo/register
// preload, and Postgres statements nested to the engine's bound, compiled by the installed binary
// preload, and Postgres statements nested to the engine's bound, analyzed by the installed binary
// as tests/depth.test.ts analyzes them.
//
// node .github/scripts/install-check.ts <packs> <platform>
Expand Down Expand Up @@ -98,7 +98,7 @@ try {
if (printed !== `reylo ${version}`) throw new Error(`the installed binary prints "${printed}", where reylo is ${version}`);
console.log(printed);

step("reylo compile through the installed command, and the preload, on a SQLite database");
step("reylo analyze through the installed command, and the preload, on a SQLite database");
const db = new DatabaseSync(join(project, "app.db"));
db.exec("create table users (id integer primary key, name text not null); insert into users values (1, 'ada')");
db.close();
Expand All @@ -107,10 +107,10 @@ try {
const env = { ...process.env, DATABASE_URL: "file:./app.db" };
// npm's own shim for reylo's bin, which starts the launcher (src/cli.ts), which runs the binary.
const command = join(project, "node_modules", ".bin", windows ? "reylo.cmd" : "reylo");
const compiled = run(command, ["compile", "user.sql"], { cwd: project, env }).trim();
console.log(compiled);
const descriptor = JSON.parse(compiled) as { file?: string; columns?: { name: string }[]; cardinality?: string };
if (descriptor.file !== "user.sql" || descriptor.columns?.map((c) => c.name).join() !== "id,name" || descriptor.cardinality !== "at_most_one") throw new Error("reylo compile did not type user.sql");
const analyzed = run(command, ["analyze", "user.sql"], { cwd: project, env }).trim();
console.log(analyzed);
const descriptor = JSON.parse(analyzed) as { file?: string; columns?: { name: string }[]; cardinality?: string };
if (descriptor.file !== "user.sql" || descriptor.columns?.map((c) => c.name).join() !== "id,name" || descriptor.cardinality !== "at_most_one") throw new Error("reylo analyze did not type user.sql");
// The playground's server, which the launcher runs in JavaScript.
if (!run(command, ["play", "--help"], { cwd: project }).startsWith("Usage: reylo play")) throw new Error("reylo play --help printed no usage");
const ran = run(process.execPath, ["--import", "reylo/register", "main.ts"], { cwd: project, env }).trim();
Expand Down
10 changes: 5 additions & 5 deletions .github/scripts/windows-check.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// The type check on Windows (windows.yml), through the packages `nub run build` writes: one project
// links dist/reylo, which finds the engine where an install puts it (dist/reylo/node_modules, a
// junction to dist/engine-win32-x64), and for each way a URL can name its database the loader
// analyzes its query as the type check does, `reylo compile` through the package's command does
// analyzes its query as the type check does, `reylo analyze` through the package's command does
// too, and `tsc` types it. The engine opens the files a URL names itself, so each case names its
// database differently: relative, absolute, as a file URL, on another drive, on a `subst` drive,
// through a share, through a short (8.3) name, beside a writer holding a WAL open; a
Expand Down Expand Up @@ -91,7 +91,7 @@ const loaderAnalysis = [
const sessionModule = pathToFileURL(join(project, "node_modules", "reylo", "src", "analyze.js")).href;

/**
* One way to name the database: the loader must type the query, and so must `reylo compile`, the
* One way to name the database: the loader must type the query, and so must `reylo analyze`, the
* native binary's own reading of the project, which the package's command runs (a DuckDB database
* runs inside the app, and the binary refuses it); for SQLite `tsc` must too.
*/
Expand All @@ -106,9 +106,9 @@ function check(name: string, url: string, { env = {}, tsc = true, analyze = !url
}
if (loader.status !== 0) failures.push(`${name}: the loader's analysis exited ${loader.status}`);
if (analyze) {
const compiled = run(process.execPath, [join(project, "node_modules", "reylo", "src", "cli.js"), "compile", "queries/get_user.sql"], project, false, env);
console.log(`reylo compile: ${compiled.status}\n${compiled.out.trim()}`);
if (compiled.status !== 0 || !compiled.out.includes(`"file":"queries/get_user.sql"`)) failures.push(`${name}: reylo compile exited ${compiled.status}`);
const analyzed = run(process.execPath, [join(project, "node_modules", "reylo", "src", "cli.js"), "analyze", "queries/get_user.sql"], project, false, env);
console.log(`reylo analyze: ${analyzed.status}\n${analyzed.out.trim()}`);
if (analyzed.status !== 0 || !analyzed.out.includes(`"file":"queries/get_user.sql"`)) failures.push(`${name}: reylo analyze exited ${analyzed.status}`);
}
if (!tsc) return;
rmSync(join(project, ".reylo"), { recursive: true, force: true });
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ jobs:
if-no-files-found: error
retention-days: 7

# Each platform's package installed as a project installs it, and run there: npm brings that platform's engine alone, which types a query with reylo compile through the installed command, runs it under the reylo/register preload, and reads Postgres statements nested to its bound (.github/scripts/install-check.ts). Each runs on a machine of the platform: macOS on Intel on an Intel runner, and Linux in each of the platform's images, Node 24's Debian 11 (older than the build's runner), AlmaLinux 8 (glibc 2.28, the oldest the binary starts on) and Amazon Linux 2023 for glibc, and Alpine for musl.
# Each platform's package installed as a project installs it, and run there: npm brings that platform's engine alone, which types a query with reylo analyze through the installed command, runs it under the reylo/register preload, and reads Postgres statements nested to its bound (.github/scripts/install-check.ts). Each runs on a machine of the platform: macOS on Intel on an Intel runner, and Linux in each of the platform's images, Node 24's Debian 11 (older than the build's runner), AlmaLinux 8 (glibc 2.28, the oldest the binary starts on) and Amazon Linux 2023 for glibc, and Alpine for musl.
install:
needs: [platforms, package]
name: Install and run (${{ matrix.platform }})
Expand Down
Loading
Loading
0