Skip to content
Closed
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
28 changes: 28 additions & 0 deletions .github/workflows/node-snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Node Snapshot Test

on:
pull_request:
push:
branches: [main]

jobs:
node-snapshot:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install
- name: Build and install tsci
run: |
bun run build
npm install -g .
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use bun?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the point of this test is to make sure that someone who doesn't have bun installed can still run tsci, because in the past we had breakage for people who just did npm install -g tscircuit and tsci dev without ever using bun

- name: Run Node snapshot smoke test
run: node scripts/node-snapshot-test.js
38 changes: 38 additions & 0 deletions scripts/node-snapshot-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { mkdtempSync, writeFileSync, existsSync } from "fs"
import { tmpdir } from "os"
import { join } from "path"
import { spawnSync } from "child_process"

const tmpDir = mkdtempSync(join(tmpdir(), "tsci-node-"))
writeFileSync(
join(tmpDir, "test.board.tsx"),
`export const TestBoard = () => (
<board width="10mm" height="10mm">
<chip name="U1" footprint="soic8" />
</board>
)`,
)

const result = spawnSync("tsci", ["snapshot", "--update", "--3d"], {
cwd: tmpDir,
encoding: "utf8",
})
console.log(result.stdout)
console.error(result.stderr)

if (result.status !== 0) {
console.error("tsci snapshot failed")
process.exit(result.status || 1)
}

const snapDir = join(tmpDir, "__snapshots__")
const pcbExists = existsSync(join(snapDir, "test.board-pcb.snap.svg"))
const schExists = existsSync(join(snapDir, "test.board-schematic.snap.svg"))
const threeExists = existsSync(join(snapDir, "test.board-3d.snap.svg"))

if (!pcbExists || !schExists || !threeExists) {
console.error("Snapshots were not created as expected")
process.exit(1)
}

console.log("Node snapshot smoke test passed")