Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ICP Examples (Motoko + Rust)",
"image": "ghcr.io/dfinity/icp-dev-env-all:0.3.1",
"image": "ghcr.io/dfinity/icp-dev-env-all:v1.2.0",
"forwardPorts": [8000, 5173],
"portsAttributes": {
"8000": {
Expand Down
54 changes: 35 additions & 19 deletions .github/workflow-template.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
# Workflow template for ICP examples.
# Copy this file to .github/workflows/<example_name>.yml and replace the placeholders.
# Copy this file to .github/workflows/<example_name>.yml and replace <example_name>.
#
# PLACEHOLDERS:
# <example_name> e.g. hello_world
# <language> motoko | rust
# <image> ghcr.io/dfinity/icp-dev-env-motoko | ghcr.io/dfinity/icp-dev-env-rust
# Examples run inside the ICP dev-env container via the reusable _run-example.yml
# workflow, which is the single source of truth for the dev-env image version.
#
# This template shows a two-language example (Motoko + Rust). Adjust it:
# - Single-language example: keep only the relevant job and its path entry.
# - Frontend-only example: use one job with `language: all` and a
# `hosting/<example_name>/**` path + `working-directory: hosting/<example_name>`.
# - Integration tests needing PocketIC: add `install-pocketic: true` to the job
# (and optionally `pocketic-version`).
#
# Keep one pull_request path entry per language directory the example ships, so a
# change in any of them triggers this workflow.

name: <example_name>

Expand All @@ -14,24 +22,32 @@ on:
- master
pull_request:
paths:
- <language>/<example_name>/**
- motoko/<example_name>/**
- rust/<example_name>/**
- .github/workflows/<example_name>.yml
- .github/workflows/_run-example.yml

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
<language>-<example_name>:
runs-on: ubuntu-24.04
container: <image>
env:
ICP_CLI_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Deploy and test
working-directory: <language>/<example_name>
run: |
icp network start -d
icp deploy
make test
motoko-<example_name>:
uses: ./.github/workflows/_run-example.yml
with:
language: motoko
working-directory: motoko/<example_name>
run: |
icp network start -d
icp deploy
bash test.sh

rust-<example_name>:
uses: ./.github/workflows/_run-example.yml
with:
language: rust
working-directory: rust/<example_name>
run: |
icp network start -d
icp deploy
bash test.sh
65 changes: 65 additions & 0 deletions .github/workflows/_run-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Reusable workflow that runs an example's CI steps inside the ICP dev-env container.
#
# This is the single source of truth for the dev-env image version used in CI.
# It is kept in sync with .devcontainer/devcontainer.json by dev-env-version-check.yml.
#
# Callers provide the language (which selects the image variant), the working
# directory, and the commands to run. Example:
#
# jobs:
# motoko-hello_world:
# uses: ./.github/workflows/_run-example.yml
# with:
# language: motoko
# working-directory: motoko/hello_world
# run: |
# icp network start -d
# icp deploy
# bash test.sh
#
# Examples that need a PocketIC server for integration tests set
# install-pocketic: true (optionally overriding pocketic-version).
name: run-example

on:
workflow_call:
inputs:
language:
description: "Dev-env image variant to run in: motoko | rust | all"
type: string
required: true
working-directory:
description: "Path to the example directory to run the commands in"
type: string
required: true
run:
description: "Commands to execute inside the dev-env container"
type: string
default: |
icp network start -d
icp deploy
install-pocketic:
description: "Install the PocketIC server before running the commands"
type: boolean
default: false
pocketic-version:
description: "PocketIC server version to install when install-pocketic is true"
type: string
default: "15.0.0"

jobs:
run:
runs-on: ubuntu-24.04
container: ghcr.io/dfinity/icp-dev-env-${{ inputs.language }}:v1.2.0
env:
ICP_CLI_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Install PocketIC server
if: ${{ inputs.install-pocketic }}
uses: dfinity/pocketic@a980c334fab1b21b0b8a6bba38e1a10836e7258b # main
with:
pocket-ic-server-version: ${{ inputs.pocketic-version }}
- name: Run
working-directory: ${{ inputs.working-directory }}
run: ${{ inputs.run }}
41 changes: 17 additions & 24 deletions .github/workflows/backend_only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,29 @@ on:
- motoko/backend_only/**
- rust/backend_only/**
- .github/workflows/backend_only.yml
- .github/workflows/_run-example.yml

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
motoko-backend_only:
runs-on: ubuntu-24.04
container: ghcr.io/dfinity/icp-dev-env-motoko: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: motoko/backend_only
run: |
icp network start -d
icp deploy
bash test.sh
uses: ./.github/workflows/_run-example.yml
with:
language: motoko
working-directory: motoko/backend_only
run: |
icp network start -d
icp deploy
bash test.sh

rust-backend_only:
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_only
run: |
icp network start -d
icp deploy
bash test.sh
uses: ./.github/workflows/_run-example.yml
with:
language: rust
working-directory: rust/backend_only
run: |
icp network start -d
icp deploy
bash test.sh
22 changes: 10 additions & 12 deletions .github/workflows/backend_wasm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@ on:
paths:
- rust/backend_wasm64/**
- .github/workflows/backend_wasm64.yml
- .github/workflows/_run-example.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
uses: ./.github/workflows/_run-example.yml
with:
language: rust
working-directory: rust/backend_wasm64
run: |
icp network start -d
icp deploy
bash test.sh
21 changes: 9 additions & 12 deletions .github/workflows/basic_ethereum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@ on:
paths:
- rust/basic_ethereum/**
- .github/workflows/basic_ethereum.yml
- .github/workflows/_run-example.yml

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
rust-basic_ethereum:
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/basic_ethereum
run: |
icp network start -d
icp deploy
bash test.sh
uses: ./.github/workflows/_run-example.yml
with:
language: rust
working-directory: rust/basic_ethereum
run: |
icp network start -d
icp deploy
bash test.sh
21 changes: 9 additions & 12 deletions .github/workflows/candid_type_generation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,19 @@ on:
paths:
- rust/candid_type_generation/**
- .github/workflows/candid_type_generation.yml
- .github/workflows/_run-example.yml

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
rust-candid_type_generation:
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/candid_type_generation
run: |
icp network start -d
icp deploy
bash test.sh
uses: ./.github/workflows/_run-example.yml
with:
language: rust
working-directory: rust/candid_type_generation
run: |
icp network start -d
icp deploy
bash test.sh
21 changes: 9 additions & 12 deletions .github/workflows/canister-info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@ on:
paths:
- rust/canister-info/**
- .github/workflows/canister-info.yml
- .github/workflows/_run-example.yml

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
rust-canister-info:
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/canister-info
run: |
icp network start -d
icp deploy
bash test.sh
uses: ./.github/workflows/_run-example.yml
with:
language: rust
working-directory: rust/canister-info
run: |
icp network start -d
icp deploy
bash test.sh
21 changes: 9 additions & 12 deletions .github/workflows/canister-snapshot-download.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@ on:
paths:
- rust/canister-snapshot-download/**
- .github/workflows/canister-snapshot-download.yml
- .github/workflows/_run-example.yml

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
rust-canister-snapshot-download:
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/canister-snapshot-download
run: |
icp network start -d
icp deploy
bash test.sh
uses: ./.github/workflows/_run-example.yml
with:
language: rust
working-directory: rust/canister-snapshot-download
run: |
icp network start -d
icp deploy
bash test.sh
21 changes: 9 additions & 12 deletions .github/workflows/canister-snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@ on:
paths:
- rust/canister-snapshots/**
- .github/workflows/canister-snapshots.yml
- .github/workflows/_run-example.yml

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
rust-canister-snapshots:
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/canister-snapshots
run: |
icp network start -d
icp deploy
bash test.sh
uses: ./.github/workflows/_run-example.yml
with:
language: rust
working-directory: rust/canister-snapshots
run: |
icp network start -d
icp deploy
bash test.sh
Loading
Loading