shibosoftwaredev/f1c100s-linux-nema17-stepper-controller

A four-layer NEMA 17 motor-controller PCB combining an Allwinner F1C100S Linux computer, USB‑PD/buck power system, W5500 Ethernet, STM32 real-time motion control, DRV8825 stepper driver, protection/temperature/current telemetry, USB interfaces, and local LED/buzzer diagnostics.

Version
0.4.56
License
unset
Stars
0

scripts/validate-software-current.mjs

import fs from "node:fs"
import assert from "node:assert/strict"
import { spawn } from "node:child_process"
const bun=process.execPath, python=process.env.ROUTING_PYTHON
assert.ok(python,"Use the pinned routing Python environment")
const circuit=JSON.parse(fs.readFileSync("dist/index/circuit.json","utf8"))
assert.ok(circuit.some(e=>e.type==="source_component"&&e.name==="U_CURRENT_DAC"),"Refuse to validate inherited pre-DAC dist")
const cli=["node_modules/@tscircuit/cli/cli/entrypoint.js","--use-global"]
const env={...process.env,PATH:"/opt/homebrew/bin:"+process.env.PATH,
  CIRCUIT_INPUT:"dist/index/circuit.json",PHYSICAL_INPUT:"routing/physical-copper.json",
  BASELINE_CIRCUIT:"baseline/v055-circuit.json"}
async function run(name,commandLine,{allowFailure=false}={}) {
  const [command,...args]=commandLine,fd=fs.openSync(`reports/software-current-${name}.log`,"w")
  const code=await new Promise((resolve,reject)=>{
    const p=spawn(command,args,{env,stdio:["ignore",fd,fd]})
    p.once("error",reject)
    p.once("exit",code=>{fs.closeSync(fd);resolve(code)})
  })
  console.log(JSON.stringify({step:name,exit:code}))
  if(code!==0&&!allowFailure)throw new Error(`${name} failed; inspect its log`)
}
await run("continuity",[bun,"scripts/check-continuity.mjs"])
const results=await Promise.allSettled([
  (async()=>{
    for(const [name,args] of [
      ["copper",["scripts/audit-local-copper.py"]],
      ["drill",["scripts/compare-drill-clearance.py","baseline/v055-circuit.json"]],
      ["copper-regression",["scripts/check-software-current-copper.py"]],
      ["dfm",["scripts/review-additional-dfm.py"]],
      ["solder",["scripts/audit-solder-process.py"]],
      ["kelvin",["scripts/audit-session-kelvin.py"]],
    ])await run(name,[python,...args])
    await run("motor",[bun,"scripts/check-assembly-motor-reference.mjs"])
    await run("gerbers",[bun,...cli,"export","dist/index/circuit.json","--format","gerbers","--output","../../reports/software-current-preview.zip"])
    await run("artwork",[python,"scripts/audit-stencil-artwork.py","dist/index/circuit.json","reports/software-current-preview.zip"])
  })(),
  (async()=>{
    await run("typecheck",[bun,"node_modules/typescript/bin/tsc","--noEmit"])
    await run("shorts",[bun,...cli,"check","shorts","dist/index/circuit.json","--mode","gerber","--layer","all"])
    await run("native",[bun,...cli,"check","dist/index/circuit.json"])
    await run("style-cli",[bun,...cli,"check","schematic-placement","dist/index/circuit.json"])
    await run("warnings",[bun,"scripts/check-software-current-warnings.mjs"])
    await run("style-current",["bash","scripts/check-current-schematic-style.sh","dist/index/circuit.json","reports/review-style"])
  })(),
  (async()=>{
    await run("stock",[bun,"scripts/audit-jlcpcb-stock.mjs","dist/index/circuit.json","reports"])
    await run("bom",[bun,"scripts/validate-bom.mjs"])
  })(),
  (async()=>{
    await run("module-tests",[bun,"test","./modules/f1c100s/tests"],{allowFailure:true})
    fs.copyFileSync("reports/software-current-module-tests.log","reports/current-module-tests.log")
    await run("module-regression",[bun,"scripts/check-software-current-module.mjs"])
    await run("firmware-tests",["make","-C","firmware/stm32","test"])
    await run("client-tests",[python,"-m","unittest","discover","-s","firmware","-p","test_motor_control.py","-v"])
  })(),
])
const failures=results.filter(r=>r.status==="rejected")
if(failures.length){console.error(failures.map(r=>r.reason.message).join("\n"));process.exitCode=1}
else {
  await run("board-tests",[bun,"test","./tests"])
  await run("verify",[bun,"scripts/verify.mjs"])
}