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
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ jobs:
- name: Lint
run: yarn lint

- name: Type-check
run: yarn typecheck

- name: Check type-check programs use live source
run: yarn tsx bin/check-typecheck-sources.ts

run-tests:
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -66,3 +72,24 @@ jobs:
- name: Build website
run: yarn build
working-directory: ./packages/web

build-playground:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
cache-dependency-path: yarn.lock

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build all packages
run: yarn build

- name: Build playground
run: yarn build
working-directory: ./packages/playground
36 changes: 36 additions & 0 deletions bin/check-typecheck-sources.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { describe, expect, it } from "vitest";
import { builtFiles } from "./check-typecheck-sources.js";

const listing = [
"/repo/node_modules/typescript/lib/lib.es2020.d.ts",
"/repo/packages/format/src/index.ts",
"/repo/packages/pointers/src/read.ts",
"/repo/node_modules/@types/node/index.d.ts",
"",
];

describe("builtFiles", () => {
it("accepts source files and third-party declarations", () => {
expect(builtFiles(listing.join("\n"))).toEqual([]);
});

it("reports a sibling package's built declarations", () => {
const stdout = [
...listing,
"/repo/packages/format/dist/src/index.d.ts",
].join("\n");
expect(builtFiles(stdout)).toEqual([
"/repo/packages/format/dist/src/index.d.ts",
]);
});

it("reports declarations reached through node_modules/@ethdebug", () => {
const stdout = [
...listing,
"/repo/node_modules/@ethdebug/format/dist/src/index.d.ts",
].join("\n");
expect(builtFiles(stdout)).toEqual([
"/repo/node_modules/@ethdebug/format/dist/src/index.d.ts",
]);
});
});
52 changes: 52 additions & 0 deletions bin/check-typecheck-sources.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { execFileSync } from "node:child_process";
import { existsSync } from "node:fs";
import { join } from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
import { readWorkspaces } from "./publish-tagged.js";

const built = [/packages\/[^/]+\/dist\//, /node_modules\/@ethdebug\//];

export function builtFiles(stdout: string): string[] {
return stdout
.split("\n")
.map((line) => line.trim())
.filter((line) => line.length > 0 && built.some((re) => re.test(line)));
}

function tsc(root: string, packageDir: string): string {
const local = join(packageDir, "node_modules", ".bin", "tsc");
return existsSync(local) ? local : join(root, "node_modules", ".bin", "tsc");
}

function listFiles(root: string, packageDir: string): string {
return execFileSync(
tsc(root, packageDir),
["-p", "tsconfig.typecheck.json", "--listFiles", "--noEmit"],
{ cwd: packageDir, encoding: "utf8", stdio: ["ignore", "pipe", "inherit"] },
);
}

function main(): number {
const root = fileURLToPath(new URL("..", import.meta.url));
let failed = false;
for (const workspace of readWorkspaces(root)) {
if (!existsSync(join(workspace.dir, "tsconfig.typecheck.json"))) {
continue;
}
const bad = builtFiles(listFiles(root, workspace.dir));
if (bad.length > 0) {
failed = true;
console.error(`${workspace.name}: type-check reads built declarations:`);

Check warning on line 39 in bin/check-typecheck-sources.ts

View workflow job for this annotation

GitHub Actions / lint-and-format

Unexpected console statement
for (const path of bad) {
console.error(` ${path}`);

Check warning on line 41 in bin/check-typecheck-sources.ts

View workflow job for this annotation

GitHub Actions / lint-and-format

Unexpected console statement
}
} else {
console.log(`${workspace.name}: ok`);

Check warning on line 44 in bin/check-typecheck-sources.ts

View workflow job for this annotation

GitHub Actions / lint-and-format

Unexpected console statement
}
}
return failed ? 1 : 0;
}

if (import.meta.url === pathToFileURL(process.argv[1]).href) {
process.exit(main());
}
7 changes: 5 additions & 2 deletions bin/start
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

# Check if the --no-open flag is provided
if [[ " $* " == *" --no-open "* ]]; then
Expand All @@ -10,11 +10,14 @@ else
fi

# Run the commands with concurrently
concurrently --names=format,pointers,evm,bugc,programs-react,playground,web,tests \
concurrently \
--names=format,pointers,evm,bugc,bugc-react,pointers-react,programs-react,playground,web,tests \
"cd ./packages/format && yarn watch" \
"cd ./packages/pointers && yarn watch" \
"cd ./packages/evm && yarn watch" \
"cd ./packages/bugc && yarn watch" \
"cd ./packages/bugc-react && yarn watch" \
"cd ./packages/pointers-react && yarn watch" \
"cd ./packages/programs-react && yarn watch" \
"cd ./packages/playground && yarn watch" \
"cd ./packages/web && yarn start $DOCUSAURUS_NO_OPEN" \
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"packages/*"
],
"scripts": {
"build": "yarn lerna run build --no-private",
"build": "yarn lerna run build --ignore @ethdebug/format-web --ignore @ethdebug/bug-playground",
"bundle": "tsx ./bin/bundle-schema.ts",
"typecheck": "yarn lerna run typecheck --ignore @ethdebug/format-web --ignore @ethdebug/bug-playground",
"test": "vitest run",
"test:coverage": "vitest run --coverage",
"start": "./bin/start",
Expand Down
5 changes: 4 additions & 1 deletion packages/bugc-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"scripts": {
"build": "rm -rf dist && tsc --build tsconfig.build.json && copyfiles -u 1 \"src/**/*.css\" dist/src",
"prepare": "yarn build",
"watch": "tsc --watch --preserveWatchOutput",
"typecheck": "tsc -p tsconfig.typecheck.json",
"watch": "copyfiles -u 1 \"src/**/*.css\" dist/src && concurrently --names=tsc,css \"tsc --watch --preserveWatchOutput\" \"nodemon --watch src -e css --exec 'copyfiles -u 1 \\\"src/**/*.css\\\" dist/src'\"",
"test": "vitest run"
},
"dependencies": {
Expand All @@ -58,7 +59,9 @@
"@types/dagre": "^0.7.52",
"@types/react": "^18.2.43",
"@types/react-dom": "^18.2.17",
"concurrently": "^8.2.2",
"jsdom": "^26.0.0",
"nodemon": "^3.1.11",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.0.0",
Expand Down
16 changes: 16 additions & 0 deletions packages/bugc-react/tsconfig.typecheck.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": true,
"composite": false,
"incremental": false,
"rootDir": "../..",
"paths": {
"@ethdebug/bugc": ["../bugc/src/index.ts"],
"@ethdebug/evm": ["../evm/src/index.ts"],
"@ethdebug/format": ["../format/src/index.ts"],
"@ethdebug/pointers": ["../pointers/src/index.ts"],
"@ethdebug/bugc/examples": ["../bugc/src/examples/index.ts"]
}
}
}
Loading
Loading