diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..485b268 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,47 @@ +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: 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/ 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. 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 new file mode 100644 index 0000000..d4a696c --- /dev/null +++ b/src/moon.pkg @@ -0,0 +1,19 @@ +import { + "peter-jerry-ye/wasi-imports/ffi" @ffi, + "peter-jerry-ye/wasi-imports/interface/wasi/cli/stdout" @stdout, + "peter-jerry-ye/wasi-imports/interface/wasi/io/streams", +} + +options( + link: { + "wasm": { + "export-memory-name": "memory", + "exports": [ + "cabi_realloc:cabi_realloc", + "wasmExportRun:wasi:cli/run@0.2.0#run", + ], + "heap-start-address": 16, + }, + }, + supported_targets: [ "wasm" ], +) 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 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 + diff --git a/src/stub.mbt b/src/stub.mbt index 6311aef..2183a81 100644 --- a/src/stub.mbt +++ b/src/stub.mbt @@ -1,22 +1,19 @@ ///| /// 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(()) + } }