Skip to content

Commit c2fc374

Browse files
committed
CI: run λ-box and Rust outputs
1 parent 4e65649 commit c2fc374

8 files changed

Lines changed: 96 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,17 @@ jobs:
108108
109109
- name: Install Peregrine
110110
working-directory: peregrine-tool/
111-
run: |
112-
eval $(opam env) && opam install -j4 ./rocq-peregrine.opam
111+
run: eval $(opam env) && opam install -j4 ./rocq-peregrine.opam
112+
113+
- name: Set up Rust
114+
uses: dtolnay/rust-toolchain@v1
115+
with:
116+
toolchain: 1.85.0
113117

114118
- name: Generate HTML
115119
run: |
116120
sudo apt-get install -y pandoc zsh wabt
117-
eval $(opam env) && make html
121+
eval $(opam env) && make gen run html
118122
119123
- name: Deploy HTML website
120124
if: github.ref == 'refs/heads/master'

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: default build install coq html clean
1+
.PHONY: default build install coq gen run html clean
22

33
default: build
44

@@ -17,6 +17,12 @@ coq:
1717
coq_makefile -f _CoqProject -o CoqMakefile
1818
make -f CoqMakefile
1919

20+
gen: test
21+
make -C test gen
22+
23+
run: test
24+
make -C test run
25+
2026
html: test
2127
make -C test html
2228

test/Agda.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262

6363
/* Tabs */
6464
[data-tab-info] { display: none; }
65-
.active[data-tab-info] { display: block; }
65+
.active[data-tab-info] { display: flex; }
6666

6767
.tabs {
6868
font-size: 25px;

test/Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ gen:
99
mkdir -p gen/
1010
./compile.sh
1111

12-
html: gen
12+
run: # gen
13+
@echo == Evaluating λ-box output ==
14+
./runRocq.sh
15+
@echo == Running Rust ==
16+
./runRust.sh
17+
18+
html: # gen run
1319
@echo == Generating HTML ==
1420
mkdir -p html/ && cp Agda.css html/
1521
-cabal run -- agda2lambox --html --css=Agda.css $(MAIN).agda

test/compile.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/bin/zsh
22

3-
# PREREQUISITES:
3+
# PRE:
44
# - generated target files are placed under dist/
55
BUILD_DIR=dist
66
# - Peregrine compilation output is placed under gen/
77
GEN_DIR=gen
8-
# - `peregrine` binary should be available
8+
# - `peregrine` command should be available
99

1010
echo "Compiling λ-box..."
1111

test/renderTranslations.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
#!/bin/zsh
22

3-
# PREREQUISITES:
4-
# - generated target files are placed under dist/
3+
# PRE:
4+
# - path to generated λ-box files
55
BUILD_DIR=dist
6-
# - Peregrine compilation output is placed under gen/
6+
# - path to Peregrine compilation output
77
GEN_DIR=gen
8-
# - Agda generated HTML is placed under html/
8+
# POST:
9+
# - path to Agda generated HTML
910
AGDA_HTML_DIR=html
1011

1112
echo "Rendering translations..."
1213

13-
for f in $BUILD_DIR/**/* $GEN_DIR/**/**/*; do
14+
for f in $BUILD_DIR/* $GEN_DIR/*/*; do
1415

1516
echo " * $f"
1617
ext=${f##*.}
@@ -23,6 +24,7 @@ for f in $BUILD_DIR/**/* $GEN_DIR/**/**/*; do
2324
"v") echo "coq";; # alas, pandoc has no coq/rocq syntax-highlighting support
2425
"rs") echo "rust";;
2526
"ml"|"sml") echo "ocaml";;
27+
"result") echo "";;
2628
*) echo "$ext";;
2729
esac)
2830
echo "\`\`\`$lang" > $mdFn
@@ -82,6 +84,8 @@ for f in $BUILD_DIR/**/**.txt; do
8284
</div>\
8385
<div class=\"tabs__tab\" id=\"in_3\" data-tab-info>\
8486
<embed src=\"$fCoq.html\"/>\
87+
<div style=\"font-size:50px;\">\&nbsp; ↪ \&nbsp;</div>\
88+
<embed src=\"$fCoq.result.html\"/>\
8589
</div>\
8690
<div class=\"tabs__tab\" id=\"out_1\" data-tab-info>\
8791
<embed src=\"$fWasm.html\"/>\
@@ -97,6 +101,8 @@ for f in $BUILD_DIR/**/**.txt; do
97101
</div>\
98102
<div class=\"tabs__tab\" id=\"out_5\" data-tab-info>\
99103
<embed src=\"$fRust.html\"/>\
104+
<div style=\"font-size:50px;\">\&nbsp; ↪ \&nbsp;</div>\
105+
<embed src=\"$fRust.result.html\"/>\
100106
</div>\
101107
<div class=\"tabs__tab\" id=\"out_6\" data-tab-info>\
102108
<embed src=\"$fElm.html\"/>\

test/runRocq.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/zsh
2+
3+
# PRE:
4+
# - path to agda2lambox compilation output
5+
# - `coqc` command should be available
6+
BUILD_DIR=dist
7+
8+
echo "Running λ-box output..."
9+
10+
cd $BUILD_DIR
11+
12+
for f in *.v; do
13+
coqc -R ../../theories Agda2Lambox $f &> $f.result
14+
done
15+
16+
echo "...done!"

test/runRust.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/zsh
2+
3+
# PRE:
4+
# - path to Peregrine compilation output
5+
GEN_DIR=gen
6+
# - `cargo` command should be available
7+
8+
echo "Running Peregrine (Rust) output..."
9+
10+
cd $GEN_DIR/rust
11+
12+
# 1. make everything public
13+
sed -i -e 's/^fn/pub fn/g' -e 's/^struct/pub struct/g' *.rs
14+
15+
# 2. Create Cargo package
16+
rustPackage="\
17+
[package]
18+
name = \"main\"
19+
[dependencies]
20+
bumpalo = \"3.20.1\"
21+
"
22+
echo $rustPackage > Cargo.toml
23+
24+
for fn in *.rs; do
25+
f=${fn%.*}
26+
rustBin="\
27+
[[bin]]
28+
name = \"$f\"
29+
path = \"$f.rs\"
30+
"
31+
echo $rustBin >> Cargo.toml
32+
33+
# 3. Attach an individual main function to each test
34+
rustMain="\
35+
pub fn main() {
36+
println!(\"{:?}\", Program::new().${f}_test());
37+
}
38+
"
39+
echo $rustMain >> $f.rs
40+
41+
# 4. Run and record the result of evaluation
42+
cargo run --bin $f &> $f.rs.result
43+
done
44+
45+
echo "...done!"

0 commit comments

Comments
 (0)