Skip to content
Merged
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
86 changes: 61 additions & 25 deletions .github/workflows/ci-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,14 @@ jobs:
uses: actions/checkout@v2

- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
target: wasm32-unknown-unknown
uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check
args: --target=wasm32-unknown-unknown

clippy:
name: Lint (clippy)
runs-on: ubuntu-latest
Expand All @@ -32,11 +27,8 @@ jobs:
uses: actions/checkout@v4

- name: Install nightly toolchain with clippy available
uses: actions-rs/toolchain@v1
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: clippy

- name: Run cargo clippy
Expand All @@ -45,40 +37,44 @@ jobs:
command: clippy
args: --all-targets -- -D warnings

rustfmt:
fmt:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install nightly toolchain with rustfmt available
uses: actions-rs/toolchain@v1
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rustfmt

- name: Install node
uses: actions/setup-node@v3
with:
node-version: "20.x"

- name: Run npm install
uses: bahmutov/npm-install@v1

- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

test:
name: Run unit tests

- name: Run prettier
run: npm run format:check

unit-test:
name: Run rust unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Run cargo test
uses: actions-rs/cargo@v1
Expand All @@ -102,4 +98,44 @@ jobs:
--skip looks::think::tests_debug::js_functions_match_declared_types
--skip looks::think::tests_non_debug::js_functions_match_declared_types
--skip js_functions


integration-test:
name: Run integration tests
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install nightly rust
uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Install wasm-bindgen-cli
uses: baptiste0928/cargo-install@v3
with:
crate: wasm-bindgen-cli

- name: Install cargo-outdir
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-outdir

- name: Install node
uses: actions/setup-node@v6
with:
node-version: "25.x"
cache: "npm"

- name: Run npm install
uses: bahmutov/npm-install@v1

- name: Install binaryen
uses: bahmutov/npm-install@v1
with:
install-command: npm i -g binaryen@nightly
cache-key-prefix: binaryen

- name: Build
run: chmod +x build.sh && ./build.sh -Wpz

- name: Run integration tests
run: npm run test
60 changes: 27 additions & 33 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,70 +7,64 @@ jobs:
name: Build WASM & website
runs-on: ubuntu-latest
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
permissions:
contents: write
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
target: wasm32-unknown-unknown

- name: Install wasm-bindgen
uses: actions-rs/cargo@v1
uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Install wasm-bindgen-cli
uses: baptiste0928/cargo-install@v3
with:
command: install
args: -f wasm-bindgen-cli

crate: wasm-bindgen-cli

- name: Install cargo-outdir
uses: actions-rs/cargo@v1
uses: baptiste0928/cargo-install@v3
with:
command: install
args: cargo-outdir
crate: cargo-outdir

- name: Install binaryen
run: sudo apt-get install binaryen

- name: Install node
uses: actions/setup-node@v3
uses: actions/setup-node@v6
with:
node-version: "20.x"

node-version: "25.x"
cache: "npm"

- name: Run npm install
run: |
npm install
npm i -g vite
npm i -g binaryen@nightly

uses: bahmutov/npm-install@v1

- name: Install binaryen
uses: bahmutov/npm-install@v1
with:
install-command: npm i -g binaryen@nightly
cache-key-prefix: binaryen

- name: Build
env:
VITE_HASH_HISTORY: true
run: |
chmod +x build.sh && ./build.sh -Wpz
vite build --base=/hyperquark/$BRANCH_NAME/
npx vite build --base=/hyperquark/$BRANCH_NAME/

- name: Move files to tmp
run: mv ./playground/dist /tmp/hq-dist

- name: checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages

- name: move file to gh-pages
run: |
rm -rf ./$BRANCH_NAME
mv /tmp/hq-dist ./$BRANCH_NAME
#mv ./main/* ./

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: gh-pages
push_options: '--force-with-lease'
push_options: "--force-with-lease"
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
/js/imports.ts
/js/opcodes.js
/node_modules/
/package-lock.json
/playground/dist/
/.vite/
/.vscode/
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.md
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ HyperQuark compiles [Scratch](https://scratch.mit.edu) projects to [WebAssembly]

## Prerequisites

- [Rust](https://rust-lang.org) v1.65.0 or later
- [Rust](https://rust-lang.org) with a nightly toolchain - install via [rustup](https://rustup.rs)
- the `wasm32-unknown-unknown` target (`rustup target add wasm32-unknown-unknown`)
- wasm-bindgen-cli (`cargo install -f wasm-bindgen-cli`)
- wasm-opt (install binaryen using whatever package manager you use)
Expand Down
1 change: 0 additions & 1 deletion hq-test.project.json

This file was deleted.

4 changes: 2 additions & 2 deletions js/cast/float2string.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function float2string(s: number): string {
return s.toString();
}
return s.toString();
}
4 changes: 2 additions & 2 deletions js/cast/int2string.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function int2string(s: number): string {
return s.toString();
}
return s.toString();
}
4 changes: 2 additions & 2 deletions js/cast/string2float.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function string2float(s: string): number {
return parseFloat(s);
}
return parseFloat(s);
}
4 changes: 2 additions & 2 deletions js/looks/say_debug_float.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { target_names } from "../shared";

export function say_debug_float(data: number, target_idx: number): void {
console.log('%s says: %d', target_names()[target_idx], data);
}
console.log("%s says: %d", target_names()[target_idx], data);
}
4 changes: 2 additions & 2 deletions js/looks/say_debug_int.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { target_names } from "../shared";

export function say_debug_int(data: number, target_idx: number): void {
console.log('%s says: %d', target_names()[target_idx], data);
}
console.log("%s says: %d", target_names()[target_idx], data);
}
4 changes: 2 additions & 2 deletions js/looks/say_debug_string.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { target_names } from "../shared";

export function say_debug_string(data: string, target_idx: number): void {
console.log('%s says: %s', target_names()[target_idx], data);
}
console.log("%s says: %s", target_names()[target_idx], data);
}
2 changes: 1 addition & 1 deletion js/looks/say_float.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { update_bubble } from "../shared";

export function say_float(data: number, target_idx: number): void {
update_bubble(target_idx, "say", data.toString());
}
}
2 changes: 1 addition & 1 deletion js/looks/say_int.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { update_bubble } from "../shared";

export function say_int(data: number, target_idx: number): void {
update_bubble(target_idx, "say", data.toString());
}
}
2 changes: 1 addition & 1 deletion js/looks/say_string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { update_bubble } from "../shared";

export function say_string(data: string, target_idx: number): void {
update_bubble(target_idx, "say", data);
}
}
6 changes: 4 additions & 2 deletions js/looks/setsizeto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { renderer, costumes, target_skins } from '../shared';
import { renderer, costumes, target_skins } from "../shared";

export function setsizeto(size: number, target_index: number) {
renderer().getDrawable(target_skins()[target_index][1]).updateScale([size, size]);
renderer()
.getDrawable(target_skins()[target_index][1])
.updateScale([size, size]);
}
6 changes: 4 additions & 2 deletions js/looks/setvisible.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { renderer, costumes, target_skins } from '../shared';
import { renderer, costumes, target_skins } from "../shared";

export function setvisible(visible: boolean, target_index: number) {
renderer().getDrawable(target_skins()[target_index][1]).updateVisible(visible);
renderer()
.getDrawable(target_skins()[target_index][1])
.updateVisible(visible);
}
8 changes: 4 additions & 4 deletions js/looks/switchcostumeto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { renderer, costumes, target_skins } from '../shared';
import { renderer, costumes, target_skins } from "../shared";

export function switchcostumeto(costume_num: number, target_index: number) {
const costume = costumes()[target_index][costume_num];
renderer().getSkin(target_skins()[target_index][0]).setSVG(costume.data);
}
const costume = costumes()[target_index][costume_num];
renderer().getSkin(target_skins()[target_index][0]).setSVG(costume.data);
}
4 changes: 2 additions & 2 deletions js/looks/think_debug_float.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { target_names } from "../shared";

export function think_debug_float(data: number, target_idx: number): void {
console.log('%s thinks: %d', target_names()[target_idx], data);
}
console.log("%s thinks: %d", target_names()[target_idx], data);
}
4 changes: 2 additions & 2 deletions js/looks/think_debug_int.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { target_names } from "../shared";

export function think_debug_int(data: number, target_idx: number): void {
console.log('%s thinks: %d', target_names()[target_idx], data);
}
console.log("%s thinks: %d", target_names()[target_idx], data);
}
4 changes: 2 additions & 2 deletions js/looks/think_debug_string.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { target_names } from "../shared";

export function think_debug_string(data: string, target_idx: number): void {
console.log('%s thinks: %s', target_names()[target_idx], data);
}
console.log("%s thinks: %s", target_names()[target_idx], data);
}
2 changes: 1 addition & 1 deletion js/looks/think_float.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { update_bubble } from "../shared";

export function think_float(data: number, target_idx: number): void {
update_bubble(target_idx, "think", data.toString());
}
}
2 changes: 1 addition & 1 deletion js/looks/think_int.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { update_bubble } from "../shared";

export function think_int(data: number, target_idx: number): void {
update_bubble(target_idx, "think", data.toString());
}
}
Loading
Loading