From 469c94af00214d7a2e12d43f5641704bf8b1be9c Mon Sep 17 00:00:00 2001 From: myfreess Date: Wed, 22 Apr 2026 18:50:34 +0800 Subject: [PATCH 1/7] promote --- .github/workflows/check.yml | 51 +++++++++++++++++++++++++++++++++++++ .gitignore | 3 ++- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/check.yml diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..cec25ed --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,51 @@ +name: check + +on: + push: + branches: + - master + - main + pull_request: + +jobs: + check: + strategy: + fail-fast: false + runs-on: ubuntu-latest + continue-on-error: false + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: install + run: | + curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash + echo "$HOME/.moon/bin" >> $GITHUB_PATH + + - name: moon version + run: | + moon version --all + + - name: moon check + run: | + moon update + moon check --deny-warn + + - name: moon info + run: | + moon info --target all + git diff --exit-code + + - name: format diff + run: | + moon fmt + git diff --exit-code + + - name: Set ulimit + run: | + ulimit -s 8176 + + - name: moon test + run: | + moon test --target all diff --git a/.gitignore b/.gitignore index 5335371..ea492e5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ target/ -.mooncakes/ \ No newline at end of file +.mooncakes/ +_build/ From 3188899acb8ffa62f36f01ed1cf876dda3439d17 Mon Sep 17 00:00:00 2001 From: myfreess Date: Wed, 22 Apr 2026 18:51:21 +0800 Subject: [PATCH 2/7] need fix dependency: error from peter-jerry-ye/io --- codex_report.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 codex_report.md diff --git a/codex_report.md b/codex_report.md new file mode 100644 index 0000000..dfe74a1 --- /dev/null +++ b/codex_report.md @@ -0,0 +1,38 @@ +# Dependency Error Report + +## Dependency + +`peter-jerry-ye/io@0.3.4` + +## Command + +```bash +moon check +``` + +## Error + +`moon check` fails while calculating the build plan: + +```text +Error: Failed to calculate build plan + +Caused by: + 0: Failed to solve package relationship + 1: Import tonyfettes/encoding@0.3.7 exists in global environment, + but its containing module is not imported by peter-jerry-ye/io@0.3.4, thus cannot be imported by its package 'http' +``` + +## Attempted Fix + +Ran: + +```bash +moon add peter-jerry-ye/io +``` + +The command completed, but did not update `moon.mod.json` or any other tracked repository file. Running `moon check` afterwards produced the same dependency resolution error. + +## Conclusion + +The failure comes from `peter-jerry-ye/io@0.3.4`: its `http` package imports `tonyfettes/encoding@0.3.7`, but that containing module is not declared by `peter-jerry-ye/io@0.3.4`. This needs to be fixed in the dependency or by moving this repository to a dependency version where that relationship is declared correctly. From 8b03fc283bb8701c12dd746158c5a61438fd55d5 Mon Sep 17 00:00:00 2001 From: myfreess Date: Sun, 26 Apr 2026 21:34:27 +0800 Subject: [PATCH 3/7] update ci --- .github/workflows/check.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index cec25ed..485b268 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -42,10 +42,6 @@ jobs: moon fmt git diff --exit-code - - name: Set ulimit - run: | - ulimit -s 8176 - - name: moon test run: | moon test --target all From a25dac82ed33626deb98406696207685abf6a7bb Mon Sep 17 00:00:00 2001 From: myfreess Date: Sun, 26 Apr 2026 21:34:51 +0800 Subject: [PATCH 4/7] moon fmt --- src/moon.pkg | 19 +++++++++++++++++++ src/moon.pkg.json | 21 --------------------- 2 files changed, 19 insertions(+), 21 deletions(-) create mode 100644 src/moon.pkg delete mode 100644 src/moon.pkg.json diff --git a/src/moon.pkg b/src/moon.pkg new file mode 100644 index 0000000..bdbea3c --- /dev/null +++ b/src/moon.pkg @@ -0,0 +1,19 @@ +import { + "peter-jerry-ye/wasi-imports/ffi" @ffi, + "peter-jerry-ye/io/io", + "peter-jerry-ye/async/loop", + "peter-jerry-ye/async/promise", +} + +options( + link: { + "wasm": { + "export-memory-name": "memory", + "exports": [ + "cabi_realloc:cabi_realloc", + "wasmExportRun:wasi:cli/run@0.2.0#run", + ], + "heap-start-address": 16, + }, + }, +) \ No newline at end of file diff --git a/src/moon.pkg.json b/src/moon.pkg.json deleted file mode 100644 index 2d8be61..0000000 --- a/src/moon.pkg.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "link": { - "wasm": { - "exports": [ - "cabi_realloc:cabi_realloc", - "wasmExportRun:wasi:cli/run@0.2.0#run" - ], - "export-memory-name": "memory", - "heap-start-address": 16 - } - }, - "import": [ - { - "path": "peter-jerry-ye/wasi-imports/ffi", - "alias": "ffi" - }, - "peter-jerry-ye/io/io", - "peter-jerry-ye/async/loop", - "peter-jerry-ye/async/promise" - ] -} \ No newline at end of file From f288eb5ec2fcb7eab454ce3b431d30434ed926ee Mon Sep 17 00:00:00 2001 From: myfreess Date: Sun, 26 Apr 2026 21:39:06 +0800 Subject: [PATCH 5/7] fix dependency --- moon.mod.json | 9 ++++----- src/moon.pkg | 7 +++---- src/stub.mbt | 23 +++++++++-------------- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/moon.mod.json b/moon.mod.json index 0fd3e72..a068fea 100644 --- a/moon.mod.json +++ b/moon.mod.json @@ -1,9 +1,8 @@ { "name": "moonbit-community/cli-template", "deps": { - "peter-jerry-ye/wasi-imports": "0.1.3", - "peter-jerry-ye/io": "0.3.4", - "peter-jerry-ye/async": "0.2.0" + "peter-jerry-ye/wasi-imports": "0.1.5" }, - "source": "src" -} \ No newline at end of file + "source": "src", + "preferred-target": "wasm" +} diff --git a/src/moon.pkg b/src/moon.pkg index bdbea3c..09aec87 100644 --- a/src/moon.pkg +++ b/src/moon.pkg @@ -1,8 +1,7 @@ import { "peter-jerry-ye/wasi-imports/ffi" @ffi, - "peter-jerry-ye/io/io", - "peter-jerry-ye/async/loop", - "peter-jerry-ye/async/promise", + "peter-jerry-ye/wasi-imports/interface/wasi/cli/stdout" @stdout, + "peter-jerry-ye/wasi-imports/interface/wasi/io/streams", } options( @@ -16,4 +15,4 @@ options( "heap-start-address": 16, }, }, -) \ No newline at end of file +) diff --git a/src/stub.mbt b/src/stub.mbt index 6311aef..08083e7 100644 --- a/src/stub.mbt +++ b/src/stub.mbt @@ -1,22 +1,17 @@ ///| /// Run the program. pub fn run() -> Result[Unit, Unit] { - let mut result = Ok(()) - @promise.spawn(async fn() { - top() catch { - error => { - result = Err(()) - @io.println_sync("Error \{error}", stream=@io.stderr) - } - } - }) - |> ignore - @io.event_loop.run() - result + top() } ///| /// User should change this function to do what they want -async fn top() -> Unit { - @io.println("Hello, world!") +fn top() -> Result[Unit, Unit] { + let stdout = @stdout.get_stdout() + let result = stdout.blocking_write_and_flush(b"Hello, world!\n".to_fixedarray()) + stdout.drop() + match result { + Ok(_) => Ok(()) + Err(_) => Err(()) + } } From 4407d6ca67c43ca1950c29786d2d36d14bcb1e24 Mon Sep 17 00:00:00 2001 From: myfreess Date: Sun, 26 Apr 2026 21:39:11 +0800 Subject: [PATCH 6/7] moon info --- src/pkg.generated.mbti | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/pkg.generated.mbti diff --git a/src/pkg.generated.mbti b/src/pkg.generated.mbti new file mode 100644 index 0000000..7ec68f2 --- /dev/null +++ b/src/pkg.generated.mbti @@ -0,0 +1,18 @@ +// Generated using `moon info`, DON'T EDIT IT +package "moonbit-community/cli-template" + +// Values +pub fn cabi_realloc(Int, Int, Int, Int) -> Int + +pub fn run() -> Result[Unit, Unit] + +pub fn wasmExportRun() -> Int + +// Errors + +// Types and methods + +// Type aliases + +// Traits + From 67d1a7d419e166a589baffba38ecf39bfc4371c6 Mon Sep 17 00:00:00 2001 From: myfreess Date: Sun, 26 Apr 2026 21:41:56 +0800 Subject: [PATCH 7/7] fix wasm target --- src/moon.pkg | 1 + src/stub.mbt | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/moon.pkg b/src/moon.pkg index 09aec87..d4a696c 100644 --- a/src/moon.pkg +++ b/src/moon.pkg @@ -15,4 +15,5 @@ options( "heap-start-address": 16, }, }, + supported_targets: [ "wasm" ], ) diff --git a/src/stub.mbt b/src/stub.mbt index 08083e7..2183a81 100644 --- a/src/stub.mbt +++ b/src/stub.mbt @@ -8,7 +8,9 @@ pub fn run() -> Result[Unit, Unit] { /// User should change this function to do what they want fn top() -> Result[Unit, Unit] { let stdout = @stdout.get_stdout() - let result = stdout.blocking_write_and_flush(b"Hello, world!\n".to_fixedarray()) + let result = stdout.blocking_write_and_flush( + b"Hello, world!\n".to_fixedarray(), + ) stdout.drop() match result { Ok(_) => Ok(())