From ebd860f6fbf1fb76108e887cdf2fbf8639a871c7 Mon Sep 17 00:00:00 2001 From: Marco Walz Date: Thu, 9 Jul 2026 12:43:28 +0200 Subject: [PATCH 1/2] chore: migrate rust/backend_wasm64 to icp-cli - Remove dfx.json, BUILD.md, .devcontainer/ (dfx artifacts) - Update backend/Cargo.toml: edition 2024, ic-cdk 0.20, candid 0.10 - Add test.sh with greet query test - Update README: comment out ICP Ninja badge, update prerequisites format and security best practices link - Add CI workflow (.github/workflows/backend_wasm64.yml) using icp-dev-env-rust:1.0.1 with nightly toolchain via build.sh Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/backend_wasm64.yml | 25 ++++++++++++++++++ .../.devcontainer/devcontainer.json | 20 -------------- rust/backend_wasm64/BUILD.md | 26 ------------------- rust/backend_wasm64/README.md | 22 +++++++++------- rust/backend_wasm64/backend/Cargo.toml | 8 +++--- rust/backend_wasm64/dfx.json | 19 -------------- rust/backend_wasm64/test.sh | 7 +++++ 7 files changed, 47 insertions(+), 80 deletions(-) create mode 100644 .github/workflows/backend_wasm64.yml delete mode 100644 rust/backend_wasm64/.devcontainer/devcontainer.json delete mode 100644 rust/backend_wasm64/BUILD.md delete mode 100644 rust/backend_wasm64/dfx.json create mode 100755 rust/backend_wasm64/test.sh diff --git a/.github/workflows/backend_wasm64.yml b/.github/workflows/backend_wasm64.yml new file mode 100644 index 0000000000..068868535e --- /dev/null +++ b/.github/workflows/backend_wasm64.yml @@ -0,0 +1,25 @@ +name: backend_wasm64 +on: + push: + branches: [master] + pull_request: + paths: + - rust/backend_wasm64/** + - .github/workflows/backend_wasm64.yml +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + rust-backend_wasm64: + runs-on: ubuntu-24.04 + container: ghcr.io/dfinity/icp-dev-env-rust:1.0.1 + env: + ICP_CLI_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 + - name: Deploy and test + working-directory: rust/backend_wasm64 + run: | + icp network start -d + icp deploy + bash test.sh diff --git a/rust/backend_wasm64/.devcontainer/devcontainer.json b/rust/backend_wasm64/.devcontainer/devcontainer.json deleted file mode 100644 index ebb0b8bcc6..0000000000 --- a/rust/backend_wasm64/.devcontainer/devcontainer.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "ICP Dev Environment", - "image": "ghcr.io/dfinity/icp-dev-env-slim:22", - "forwardPorts": [4943, 5173], - "portsAttributes": { - "4943": { - "label": "dfx", - "onAutoForward": "ignore" - }, - "5173": { - "label": "vite", - "onAutoForward": "openBrowser" - } - }, - "customizations": { - "vscode": { - "extensions": ["dfinity-foundation.vscode-motoko"] - } - } -} diff --git a/rust/backend_wasm64/BUILD.md b/rust/backend_wasm64/BUILD.md deleted file mode 100644 index ffb6557ec1..0000000000 --- a/rust/backend_wasm64/BUILD.md +++ /dev/null @@ -1,26 +0,0 @@ -# Continue building locally - -Projects deployed through ICP Ninja are temporary; they will only be live for 30 minutes before they are removed. To continue building locally, follow these steps. - -### 1. Install developer tools - -Install [Node.js](https://nodejs.org/en/download/) and [icp-cli](https://cli.icp.build): - -```bash -npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm -``` - -Then navigate into your project's directory that you downloaded from ICP Ninja. - -### 2. Deploy locally - -Start the local network and deploy the project: - -```bash -icp network start -d -icp deploy -``` - -## Additional examples - -Additional code examples and sample applications can be found in the [DFINITY examples repo](https://github.com/dfinity/examples). diff --git a/rust/backend_wasm64/README.md b/rust/backend_wasm64/README.md index 3a4c9b55c5..c9ef7efff1 100644 --- a/rust/backend_wasm64/README.md +++ b/rust/backend_wasm64/README.md @@ -17,20 +17,16 @@ The Wasm64 target allows canisters to: This example uses the `build.sh` script to build for Wasm64 using Rust's nightly toolchain and the `-Z build-std` feature. -## Deploying from ICP Ninja - -This example can be deployed directly from [ICP Ninja](https://icp.ninja), a browser-based IDE for ICP. To continue developing locally after deploying from ICP Ninja, see [BUILD.md](BUILD.md). - + ## Build and deploy from the command line ### Prerequisites -- [x] Install [Node.js](https://nodejs.org/en/download/) -- [x] Install [icp-cli](https://cli.icp.build): `npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm` +- Node.js +- icp-cli: `npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm` ### Install @@ -41,7 +37,7 @@ git clone https://github.com/dfinity/examples cd examples/rust/backend_wasm64 ``` -### Deployment +### Deploy and test Start the local network: @@ -55,6 +51,12 @@ Deploy the canister: icp deploy ``` +Run the tests: + +```bash +bash test.sh +``` + Stop the local network when done: ```bash @@ -63,4 +65,4 @@ icp network stop ## Security considerations and best practices -If you base your application on this example, it is recommended that you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/building-apps/security/overview) for developing on ICP. This example may not implement all the best practices. +If you base your application on this example, it is recommended that you familiarize yourself with and adhere to the [security best practices](https://docs.internetcomputer.org/guides/security/overview) for developing on ICP. This example may not implement all the best practices. diff --git a/rust/backend_wasm64/backend/Cargo.toml b/rust/backend_wasm64/backend/Cargo.toml index 49b48571a7..ebcbb9dfcb 100644 --- a/rust/backend_wasm64/backend/Cargo.toml +++ b/rust/backend_wasm64/backend/Cargo.toml @@ -1,14 +1,12 @@ [package] name = "backend" version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +edition = "2024" [lib] crate-type = ["cdylib"] path = "lib.rs" [dependencies] -candid = "0.10.10" -ic-cdk = "0.18.0" +candid = "0.10" +ic-cdk = "0.20" diff --git a/rust/backend_wasm64/dfx.json b/rust/backend_wasm64/dfx.json deleted file mode 100644 index 46ffad9baa..0000000000 --- a/rust/backend_wasm64/dfx.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "canisters": { - "backend": { - "candid": "backend/backend.did", - "type": "custom", - "shrink": true, - "gzip": true, - "wasm": "target/backend.wasm", - "build": [ - "./build.sh" - ], - "metadata": [ - { - "name": "candid:service" - } - ] - } - } -} diff --git a/rust/backend_wasm64/test.sh b/rust/backend_wasm64/test.sh new file mode 100755 index 0000000000..ace6a18b83 --- /dev/null +++ b/rust/backend_wasm64/test.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +set -e + +echo "=== Test 1: greet returns expected greeting ===" +result=$(icp canister call --query backend greet '("World")') +echo "$result" +echo "$result" | grep -q "Hello, World!" && echo "PASS" || (echo "FAIL" && exit 1) From 1cc3684076ed037cb0d8943f6818287a5f0cf740 Mon Sep 17 00:00:00 2001 From: Marco Walz Date: Thu, 9 Jul 2026 13:08:32 +0200 Subject: [PATCH 2/2] fix: add hyperlinks and Rust prerequisite to README --- rust/backend_wasm64/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rust/backend_wasm64/README.md b/rust/backend_wasm64/README.md index c9ef7efff1..30554f1e60 100644 --- a/rust/backend_wasm64/README.md +++ b/rust/backend_wasm64/README.md @@ -25,8 +25,9 @@ This example uses the `build.sh` script to build for Wasm64 using Rust's nightly ### Prerequisites -- Node.js -- icp-cli: `npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm` +- [Node.js](https://nodejs.org/) v18+ +- [icp-cli](https://cli.internetcomputer.org/): `npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm` +- [Rust](https://www.rust-lang.org/tools/install) with nightly toolchain (installed automatically by `build.sh`) ### Install