|
1 | 1 | # Workflow template for ICP examples. |
2 | | -# Copy this file to .github/workflows/<example_name>.yml and replace the placeholders. |
| 2 | +# Copy this file to .github/workflows/<example_name>.yml and replace <example_name>. |
3 | 3 | # |
4 | | -# PLACEHOLDERS: |
5 | | -# <example_name> e.g. hello_world |
6 | | -# <language> motoko | rust |
7 | | -# <image> ghcr.io/dfinity/icp-dev-env-motoko | ghcr.io/dfinity/icp-dev-env-rust |
| 4 | +# Examples run inside the ICP dev-env container via the reusable _run-example.yml |
| 5 | +# workflow, which is the single source of truth for the dev-env image version. |
| 6 | +# |
| 7 | +# This template shows a two-language example (Motoko + Rust). Adjust it: |
| 8 | +# - Single-language example: keep only the relevant job and its path entry. |
| 9 | +# - Frontend-only example: use one job with `language: all` and a |
| 10 | +# `hosting/<example_name>/**` path + `working-directory: hosting/<example_name>`. |
| 11 | +# - Integration tests needing PocketIC: add `install-pocketic: true` to the job |
| 12 | +# (and optionally `pocketic-version`). |
| 13 | +# |
| 14 | +# Keep one pull_request path entry per language directory the example ships, so a |
| 15 | +# change in any of them triggers this workflow. |
8 | 16 |
|
9 | 17 | name: <example_name> |
10 | 18 |
|
|
14 | 22 | - master |
15 | 23 | pull_request: |
16 | 24 | paths: |
17 | | - - <language>/<example_name>/** |
| 25 | + - motoko/<example_name>/** |
| 26 | + - rust/<example_name>/** |
18 | 27 | - .github/workflows/<example_name>.yml |
| 28 | + - .github/workflows/_run-example.yml |
19 | 29 |
|
20 | 30 | concurrency: |
21 | 31 | group: ${{ github.workflow }}-${{ github.ref }} |
22 | 32 | cancel-in-progress: true |
23 | 33 |
|
24 | 34 | jobs: |
25 | | - <language>-<example_name>: |
26 | | - runs-on: ubuntu-24.04 |
27 | | - container: <image> |
28 | | - env: |
29 | | - ICP_CLI_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
30 | | - steps: |
31 | | - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 |
32 | | - - name: Deploy and test |
33 | | - working-directory: <language>/<example_name> |
34 | | - run: | |
35 | | - icp network start -d |
36 | | - icp deploy |
37 | | - make test |
| 35 | + motoko-<example_name>: |
| 36 | + uses: ./.github/workflows/_run-example.yml |
| 37 | + with: |
| 38 | + language: motoko |
| 39 | + working-directory: motoko/<example_name> |
| 40 | + run: | |
| 41 | + icp network start -d |
| 42 | + icp deploy |
| 43 | + bash test.sh |
| 44 | +
|
| 45 | + rust-<example_name>: |
| 46 | + uses: ./.github/workflows/_run-example.yml |
| 47 | + with: |
| 48 | + language: rust |
| 49 | + working-directory: rust/<example_name> |
| 50 | + run: | |
| 51 | + icp network start -d |
| 52 | + icp deploy |
| 53 | + bash test.sh |
0 commit comments