Skip to content

Commit d65ea1a

Browse files
Feat and Fix: Fix release pipeline and wire demo to latest wasm.
1 parent 6fb8a3f commit d65ea1a

4 files changed

Lines changed: 109 additions & 28 deletions

File tree

.github/workflows/native.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,26 @@ on:
44
jobs:
55
build:
66
strategy:
7+
fail-fast: false
78
matrix:
89
include:
910
- name: Linux
1011
os: ubuntu-latest
1112
target: x86_64-unknown-linux-gnu
1213
binary: edge
14+
asset: edge-linux-x86_64
1315

1416
- name: Windows
1517
os: windows-latest
1618
target: x86_64-pc-windows-msvc
1719
binary: edge.exe
20+
asset: edge-windows-x86_64.exe
1821

1922
- name: Mac
2023
os: macos-latest
2124
target: aarch64-apple-darwin
2225
binary: edge
26+
asset: edge-macos-aarch64
2327

2428
name: ${{ matrix.name }}
2529
runs-on: ${{ matrix.os }}
@@ -67,9 +71,14 @@ jobs:
6771
run: cargo bloat --release --target ${{ matrix.target }} --crates -n 7
6872
working-directory: compiler
6973

74+
- name: Rename for release
75+
if: startsWith(github.ref, 'refs/tags/')
76+
shell: bash
77+
run: cp compiler/target/${{ matrix.target }}/release/${{ matrix.binary }} ${{ matrix.asset }}
78+
7079
- name: Upload Native Release
7180
uses: softprops/action-gh-release@v2
7281
if: startsWith(github.ref, 'refs/tags/')
7382
with:
74-
files: compiler/target/${{ matrix.target }}/release/${{ matrix.binary }}
75-
token: ${{ secrets.RELEASE_TOKEN }}
83+
files: ${{ matrix.asset }}
84+
fail_on_unmatched_files: true

.github/workflows/pages.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: pages
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ["v*"]
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: pages
16+
cancel-in-progress: false
17+
18+
jobs:
19+
deploy:
20+
environment:
21+
name: github-pages
22+
url: ${{ steps.deployment.outputs.page_url }}
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v5
26+
27+
- name: Setup Pages
28+
uses: actions/configure-pages@v5
29+
30+
- name: Upload artifact
31+
uses: actions/upload-pages-artifact@v3
32+
with:
33+
path: demo
34+
35+
- name: Deploy to GitHub Pages
36+
id: deployment
37+
uses: actions/deploy-pages@v4

.github/workflows/wasm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ jobs:
6666
if: startsWith(github.ref, 'refs/tags/')
6767
with:
6868
files: compiler/target/wasm32-unknown-unknown/release/compiler_lib.wasm
69-
token: ${{ secrets.RELEASE_TOKEN }}
69+
fail_on_unmatched_files: true

demo/main.html

Lines changed: 60 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@
2323
<div class="bg-[#1c1c1c] border-t border-[#2d2d2d] px-3 py-2 flex justify-between items-center">
2424
<div class="text-[12px] tracking-tighter font-semibold text-zinc-500 flex items-center gap-1 w-full">
2525
<p>editor</p>
26-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="ml-auto w-3 h-3">
27-
<path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"/>
28-
<path d="M14 2v5a1 1 0 0 0 1 1h5"/>
29-
</svg>
26+
<button id="run" disabled class="ml-auto flex items-center gap-1 px-2 py-0.5 bg-[#d97757] text-white rounded hover:bg-[#c16644] disabled:opacity-40 disabled:cursor-not-allowed transition">
27+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-3 h-3">
28+
<polygon points="6 4 20 12 6 20"/>
29+
</svg>
30+
<span>run</span>
31+
</button>
3032
</div>
3133
</div>
3234

@@ -37,7 +39,7 @@
3739
class="no-scrollbar w-full bg-transparent p-2 outline-none resize-none text-[#c2c2c2] placeholder-[#404040] overflow-y-auto"
3840
spellcheck="false"
3941
placeholder="Type your Python code here..."
40-
></textarea>
42+
>print("Hello, world!")</textarea>
4143
</div>
4244
</div>
4345

@@ -46,53 +48,86 @@
4648
<div class="bg-[#1c1c1c] border-b border-[#2d2d2d] px-3 py-2 flex justify-between items-center">
4749
<div class="text-[12px] tracking-tighter font-semibold text-zinc-500 flex items-center gap-1 w-full">
4850
<p>terminal</p>
49-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="ml-auto w-3 h-3">
50-
<path d="M12 19h8"/>
51-
<path d="m4 17 6-6-6-6"/>
52-
</svg>
51+
<span id="status" class="ml-auto text-[#525252]">loading wasm…</span>
5352
</div>
5453
</div>
5554

56-
<div class="code-font text-sm p-3 text-[#c2c2c2] flex-1 overflow-y-auto no-scrollbar">
57-
<p>[2026-04-18T04:45:39Z INFO edge] emit: snapshot created [ops=3 consts=1]</p>
58-
<p>Hello, world!</p>
59-
</div>
55+
<div id="term" class="code-font text-sm p-3 text-[#c2c2c2] flex-1 overflow-y-auto no-scrollbar whitespace-pre-wrap"></div>
6056
</div>
61-
57+
6258
<script>
59+
const WASM_URL = 'https://github.com/dylan-sutton-chavez/edge-python/releases/latest/download/compiler_lib.wasm';
60+
const SZ = 1 << 20;
61+
6362
const ed = document.getElementById('ed');
6463
const ln = document.getElementById('ln');
64+
const btn = document.getElementById('run');
65+
const term = document.getElementById('term');
66+
const status = document.getElementById('status');
67+
68+
let wasm = null;
69+
70+
async function loadWasm() {
71+
try {
72+
status.textContent = 'fetching latest wasm…';
73+
const res = await fetch(WASM_URL, { cache: 'no-cache' });
74+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
75+
const bytes = await res.arrayBuffer();
76+
const { instance } = await WebAssembly.instantiate(bytes, {});
77+
wasm = instance.exports;
78+
btn.disabled = false;
79+
status.textContent = 'ready';
80+
status.className = 'ml-auto text-emerald-500';
81+
} catch (e) {
82+
status.textContent = `load failed: ${e.message}`;
83+
status.className = 'ml-auto text-red-500';
84+
}
85+
}
86+
87+
function runCode() {
88+
if (!wasm) return;
89+
const srcBytes = new TextEncoder().encode(ed.value);
90+
if (srcBytes.length > SZ) {
91+
term.textContent = `error: source exceeds ${SZ} bytes`;
92+
return;
93+
}
94+
const mem = new Uint8Array(wasm.memory.buffer);
95+
mem.set(srcBytes, wasm.src_ptr());
96+
const outLen = wasm.run(srcBytes.length);
97+
const outView = new Uint8Array(wasm.memory.buffer, wasm.out_ptr(), outLen);
98+
term.textContent = new TextDecoder().decode(outView);
99+
}
100+
101+
btn.addEventListener('click', runCode);
65102

66103
ed.addEventListener('keydown', (e) => {
67-
if (e.key === 'Enter') {
68-
const currentLines = ed.value.split('\n').length;
69-
if (currentLines >= 99) {
70-
e.preventDefault();
71-
}
104+
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') {
105+
e.preventDefault();
106+
runCode();
107+
return;
108+
}
109+
if (e.key === 'Enter' && ed.value.split('\n').length >= 99) {
110+
e.preventDefault();
72111
}
73112
});
74113

75114
const sync = () => {
76115
let lines = ed.value.split('\n');
77-
78116
if (lines.length > 99) {
79117
ed.value = lines.slice(0, 99).join('\n');
80118
lines = ed.value.split('\n');
81119
}
82-
83-
const count = lines.length;
84-
85-
ln.textContent = Array.from({length: count}, (_, i) =>
120+
ln.textContent = Array.from({length: lines.length}, (_, i) =>
86121
String(i + 1).padStart(2, '0')
87122
).join('\n');
88-
89123
ln.scrollTop = ed.scrollTop;
90124
};
91125

92126
ed.oninput = sync;
93127
ed.onscroll = sync;
94128

95129
sync();
130+
loadWasm();
96131
</script>
97132

98133
</body>

0 commit comments

Comments
 (0)