-
Notifications
You must be signed in to change notification settings - Fork 169
Add wasm-spring-shell demo. #364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| name: native-image/wasm-spring-shell | ||
| on: | ||
| push: | ||
| paths: | ||
| - 'native-image/wasm-spring-shell/**' | ||
| - '.github/workflows/native-image-wasm-spring-shell.yml' | ||
| pull_request: | ||
| paths: | ||
| - 'native-image/wasm-spring-shell/**' | ||
| - '.github/workflows/native-image-wasm-spring-shell.yml' | ||
| schedule: | ||
| - cron: "0 0 1 * *" # run every month | ||
| workflow_dispatch: | ||
| permissions: | ||
| contents: read | ||
| jobs: | ||
| run: | ||
| name: Run 'native-image/wasm-spring-shell' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Download GraalVM 25.1 EA builds | ||
| run: curl -sL -o $RUNNER_TEMP/graalvm-jdk-25e1-linux-amd64.tar.gz https://github.com/graalvm/oracle-graalvm-ea-builds/releases/download/jdk-25e1-25.0.0-ea.01/graalvm-jdk-25e1-25.0.0-ea.01_linux-x64_bin.tar.gz | ||
| - uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: '25' | ||
| distribution: 'jdkfile' | ||
| jdkFile: ${{ runner.temp }}/graalvm-jdk-25e1-linux-amd64.tar.gz | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22 | ||
| - name: Set up Binaryen | ||
| run: | | ||
| curl -sLO https://github.com/WebAssembly/binaryen/releases/download/version_122/binaryen-version_122-x86_64-linux.tar.gz | ||
| tar xzf binaryen-version_122-x86_64-linux.tar.gz | ||
| echo "$(pwd)/binaryen-version_122/bin" >> "$GITHUB_PATH" | ||
| - name: Run 'native-image/wasm-spring-shell' | ||
| run: | | ||
| cd native-image/wasm-spring-shell | ||
| ./mvnw --no-transfer-progress -Pnative native:compile | ||
| node target/wasm-spring-shell help | ||
| node target/wasm-spring-shell hello Jane | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| /mvnw text eol=lf | ||
| *.cmd text eol=crlf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| HELP.md | ||
| target/ | ||
| .mvn/wrapper/maven-wrapper.jar | ||
| !**/src/main/**/target/ | ||
| !**/src/test/**/target/ | ||
|
|
||
| ### STS ### | ||
| .apt_generated | ||
| .classpath | ||
| .factorypath | ||
| .project | ||
| .settings | ||
| .springBeans | ||
| .sts4-cache | ||
|
|
||
| ### IntelliJ IDEA ### | ||
| .idea | ||
| *.iws | ||
| *.iml | ||
| *.ipr | ||
|
|
||
| ### NetBeans ### | ||
| /nbproject/private/ | ||
| /nbbuild/ | ||
| /dist/ | ||
| /nbdist/ | ||
| /.nb-gradle/ | ||
| build/ | ||
| !**/src/main/**/build/ | ||
| !**/src/test/**/build/ | ||
|
|
||
| ### VS Code ### | ||
| .vscode/ |
3 changes: 3 additions & 0 deletions
3
native-image/wasm-spring-shell/.mvn/wrapper/maven-wrapper.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| wrapperVersion=3.3.4 | ||
| distributionType=only-script | ||
| distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Compile Spring Shell into a Wasm Module | ||
|
|
||
| This demo illustrates how to use GraalVM Web Image to compile a Spring Shell application into a Wasm module that can then run on the command-line or in the browser. [Check out the live demo here](https://graalvm.github.io/graalvm-demos/native-image/wasm-spring-shell/). | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| This demo requires: | ||
|
|
||
| 1. This [Early Access Build](https://github.com/graalvm/oracle-graalvm-ea-builds/releases/tag/jdk-25e1-25.0.0-ea.01) of Oracle GraalVM 25.1 or later. | ||
| 2. The [Binaryen toolchain](https://github.com/WebAssembly/binaryen) in version 119 or later and on the system path. | ||
| For example, using Homebrew: `brew install binaryen` | ||
|
|
||
| ## Run Spring Shell on Node | ||
|
|
||
| 1. Build the Wasm module with the `native` profile: | ||
| ```bash | ||
| $ ./mvnw -Pnative package | ||
| ``` | ||
| The demo uses the [Native Build Tools](https://graalvm.github.io/native-build-tools/latest/index.html) for building native images with GraalVM and Maven. | ||
| This command generates a Wasm file and a corresponding JavaScript binding in the `target` directory. | ||
|
|
||
| 2. Run the Wasm module on Node: | ||
| ```bash | ||
| node target/wasm-spring-shell help | ||
| node target/wasm-spring-shell hello Jane | ||
| ``` | ||
| This requires Node.js 22 or later. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use the
graalvm/setup-graalvmaction here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not yet unfortunately, because we don't have a file for 25.1 in here.