Skip to content

Commit

Permalink
Add playground config validation script and CI (#1976)
Browse files Browse the repository at this point in the history
* Add playground config validation script and CI

Signed-off-by: Yashodhan Joshi <[email protected]>

* Fix the validation script to consider all passes

Also removes the invalid examples and passes

Signed-off-by: Yashodhan Joshi <[email protected]>

---------

Signed-off-by: Yashodhan Joshi <[email protected]>
Co-authored-by: Rachit Nigam <[email protected]>
  • Loading branch information
YJDoc2 and rachitnigam authored Mar 21, 2024
1 parent e89ed24 commit 1632dfd
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 49 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@ concurrency:
cancel-in-progress: true

jobs:
validate-playground-config:
name: Validate playground config
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust stable
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- name: Build calyx dev
run: cargo build
- name: Check calyx build
run: ./target/debug/calyx --version
- name: validate playground config
run: node web/validate-data.js

# Get the hash of the Dockerfile
hash:
name: Get Docker Hash
Expand Down
27 changes: 4 additions & 23 deletions web/data/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
{
"name": "Invoke (call)",
"file": "tests/passes/compile-invoke.futil",
"file": "tests/passes/compile-invoke/compile-invoke.futil",
"root": "/",
"passes": [
"compile-invoke"
Expand All @@ -51,40 +51,21 @@
"externalize"
]
},
{
"name": "Infer Static Timing",
"file": "tests/passes/infer-static/component.futil",
"root": "/",
"passes": [
"infer-static-timing"
]
},
{
"name": "Minimize Regs Simple",
"file": "tests/passes/minimize-regs/simple-liveness.futil",
"file": "tests/passes/cell-share/simple-liveness.futil",
"root": "/",
"passes": [
"minimize-regs",
"dead-cell-removal"
]
},
{
"name": "Minimize Regs (Nested Par)",
"file": "tests/passes/minimize-regs/nested-par.futil",
"root": "/",
"passes": [
"minimize-regs",
"dead-cell-removal"
]
},
{
"name": "Resource Sharing",
"file": "tests/passes/resource-sharing/share.futil",
"file": "tests/passes/cell-share/nested-par.futil",
"root": "/",
"passes": [
"resource-sharing",
"dead-cell-removal"
]
}
]
}
}
27 changes: 1 addition & 26 deletions web/data/passes.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,6 @@
"title": "Collapse Control",
"description": "collapse-control"
},
{
"name": "infer-static-timing",
"title": "Infer Static Timing",
"description": "infer-static-timing"
},
{
"name": "resource-sharing",
"title": "Resource Sharing",
"description": "resource-sharing"
},
{
"name": "minimize-regs",
"title": "Minimize Regs",
"description": "minimize-regs"
},
{
"name": "compile-empty",
"title": "Compile Empty",
"description": "compile-empty"
},
{
"name": "simplify-with-control",
"title": "Remove combinational groups",
Expand All @@ -70,11 +50,6 @@
"title": "Go Insertion",
"description": "go-insertion"
},
{
"name": "component-interface-inserter",
"title": "Component Interface Inserter",
"description": "component-interface-inserter"
},
{
"name": "hole-inliner",
"title": "Hole Inliner",
Expand All @@ -86,4 +61,4 @@
"description": "clk-insertion"
}
]
}
}
46 changes: 46 additions & 0 deletions web/validate-data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const fs = require("fs");
const path = require("path");
const childProcess = require("child_process");
const config = require("./data/config.json");
const passes = require("./data/passes.json").passes.map((p) => p.name);
const examples = config.examples;

// we assume that we have a debug build of calyx ready
const _spawned = childProcess.spawnSync(
path.join(__dirname, "..", "target/debug/calyx"),
["pass-help"],
);
const op = new String(_spawned.stdout);
const passList = op.split("Aliases:\n")[0];
const allPasses = passList
.split("\n")
.filter((s) => s.startsWith("-")) // each pass in the list starts with - , eg: - tdcc: something-about-tdcc
.map((s)=>s.split(":")[0]) // split by : to get the pass name and skip desc, eg : - tdcc
.map((s)=>s.replace("-","").trim()) // replcae the initial - and trim. Note this will not replace - from pass names, only the leading one
.join(",");

const errors = [];

for (const pass of passes) {
if (!allPasses.includes(pass)) {
errors.push(`pass ${pass} is not valid`);
}
}

const validPasses = passes.filter((p) => allPasses.includes(p));

for (const eg of examples) {
const filepath = path.join(__dirname, "..", eg.file);
if (!fs.existsSync(filepath)) {
errors.push(`file ${eg.file} does not exist`);
}
for (const pass of eg.passes) {
if (!validPasses.includes(pass)) {
errors.push(`pass ${pass} for example ${eg.name} is invalid`);
}
}
}
if (errors.length > 0) {
console.error(errors);
process.exit(1);
}

0 comments on commit 1632dfd

Please sign in to comment.