Skip to content

Commit 83262a5

Browse files
committed
feat: add codecov
1 parent 4283816 commit 83262a5

9 files changed

Lines changed: 170 additions & 27 deletions

File tree

.github/workflows/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,19 @@ jobs:
3131

3232
- name: Check generated references
3333
run: bun run ref:check
34+
35+
- name: Run tests with coverage
36+
run: |
37+
bun run --cwd packages/testing test -- --coverage
38+
bun run --cwd packages/hikkaku test -- --coverage
39+
bun run --cwd packages/moonscratch test -- --coverage
40+
41+
- name: Upload coverage reports to Codecov
42+
uses: codecov/codecov-action@v5
43+
with:
44+
token: ${{ secrets.CODECOV_TOKEN }}
45+
files: |
46+
packages/hikkaku/coverage/lcov.info
47+
packages/testing/coverage/lcov.info
48+
packages/moonscratch/coverage/lcov.info
49+
fail_ci_if_error: false

bun.lock

Lines changed: 50 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"lint": "biome check",
1414
"fmt": "biome check --fix --unsafe",
1515
"typecheck": "turbo run typecheck",
16+
"test": "turbo run test",
1617
"ref:build": "bun run --cwd packages/skill build-blocks",
1718
"ref:check": "bun run --cwd packages/skill build-blocks:check",
1819
"build": "turbo run build"

packages/hikkaku/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@turbowarp/packager": "^3.11.0",
2121
"@types/bun": "latest",
2222
"@typescript/native-preview": "^7.0.0-dev.20260127.1",
23+
"@vitest/coverage-v8": "4.0.18",
2324
"rolldown": "1.0.0-rc.4",
2425
"tsdown": "^0.20.0-beta.4",
2526
"vite-plus": "^0.0.0-3262bda4.20260210-0221"

packages/hikkaku/vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@ import { defineConfig } from 'vite-plus'
33
export default defineConfig({
44
test: {
55
include: ['./src/**/*.test.ts'],
6+
coverage: {
7+
reporter: ['lcov'],
8+
},
69
},
710
})

packages/moonscratch/src/runtime_eval.mbt

Lines changed: 89 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,11 +1658,66 @@ fn block_input_or_field_string(
16581658
field_name : String,
16591659
depth : Int,
16601660
) -> String {
1661-
let from_input = json_to_string_value(
1662-
value_from_input(vm, target_index, block, input_name, depth),
1663-
)
1664-
.trim()
1665-
.to_string()
1661+
let mut from_input = ""
1662+
1663+
if target_index >= 0 && target_index < vm.targets.length() {
1664+
match block.input_block_ids.get(input_name) {
1665+
Some(input_block_id) =>
1666+
match vm.targets[target_index].blocks.get(input_block_id) {
1667+
Some(input_block) =>
1668+
match field_value(input_block, field_name) {
1669+
Some((value, _)) =>
1670+
if value.trim() != "" {
1671+
from_input = value
1672+
}
1673+
None => ()
1674+
}
1675+
None => ()
1676+
}
1677+
None => ()
1678+
}
1679+
}
1680+
1681+
if from_input == "" {
1682+
match block_input_payload(block, input_name) {
1683+
Some(String(raw)) =>
1684+
if target_index >= 0 && target_index < vm.targets.length() {
1685+
match vm.targets[target_index].blocks.get(raw) {
1686+
Some(input_block) =>
1687+
match field_value(input_block, field_name) {
1688+
Some((value, _)) =>
1689+
if value.trim() != "" {
1690+
from_input = value
1691+
} else if raw.trim() != "" {
1692+
from_input = raw
1693+
}
1694+
None =>
1695+
if raw.trim() != "" {
1696+
from_input = raw
1697+
}
1698+
}
1699+
None =>
1700+
if raw.trim() != "" {
1701+
from_input = raw
1702+
}
1703+
}
1704+
} else if raw.trim() != "" {
1705+
from_input = raw
1706+
}
1707+
Some(_) => {
1708+
let resolved = json_to_string_value(
1709+
value_from_input(vm, target_index, block, input_name, depth),
1710+
)
1711+
.trim()
1712+
.to_string()
1713+
if resolved != "" {
1714+
from_input = resolved
1715+
}
1716+
}
1717+
None => ()
1718+
}
1719+
}
1720+
16661721
if from_input != "" {
16671722
from_input
16681723
} else {
@@ -2411,6 +2466,11 @@ fn eval_reporter_block_depth(
24112466
Some((value, _)) => json_string(value)
24122467
None => json_string("")
24132468
}
2469+
"sensing_keyoptions" =>
2470+
match field_value(block, "KEY_OPTION") {
2471+
Some((value, _)) => json_string(value)
2472+
None => json_string("")
2473+
}
24142474
"pen_menu_colorParam" =>
24152475
match field_value(block, "colorParam") {
24162476
Some((value, _)) => json_string(value)
@@ -2621,9 +2681,32 @@ fn eval_reporter_block_depth(
26212681
}
26222682
"sensing_mousedown" => json_bool(read_mouse_down(vm))
26232683
"sensing_keypressed" => {
2624-
let option = block_input_or_field_string(
2684+
let raw_option = block_input_or_field_string(
26252685
vm, target_index, block, "KEY_OPTION", "KEY_OPTION", depth,
26262686
)
2687+
let option = if raw_option != "" &&
2688+
target_index >= 0 &&
2689+
target_index < vm.targets.length() {
2690+
match vm.targets[target_index].blocks.get(raw_option) {
2691+
Some(menu_block) =>
2692+
if menu_block.opcode == "sensing_keyoptions" {
2693+
match field_value(menu_block, "KEY_OPTION") {
2694+
Some((value, _)) =>
2695+
if value.trim() != "" {
2696+
value
2697+
} else {
2698+
raw_option
2699+
}
2700+
None => raw_option
2701+
}
2702+
} else {
2703+
raw_option
2704+
}
2705+
None => raw_option
2706+
}
2707+
} else {
2708+
raw_option
2709+
}
26272710
json_bool(key_is_pressed(vm, option))
26282711
}
26292712
"sensing_touchingobject" => {

packages/moonscratch/vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,8 @@ export default defineConfig({
5757
},
5858
test: {
5959
include: ['./js/**/*.test.ts'],
60+
coverage: {
61+
reporter: ['lcov'],
62+
},
6063
},
6164
})

packages/testing/vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@ export default defineConfig({
77
},
88
test: {
99
include: ['./src/**/*.test.ts'],
10+
coverage: {
11+
reporter: ['lcov'],
12+
},
1013
},
1114
})

turbo.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
"dependsOn": ["moonscratch#build", "@hikkaku/testing#build"],
1111
"outputs": []
1212
},
13+
"test": {
14+
"cache": false,
15+
"outputs": []
16+
},
1317
"build-blocks": {
1418
"outputs": ["src/blocks/**"]
1519
},

0 commit comments

Comments
 (0)