-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgithub-actions.yml
More file actions
104 lines (92 loc) · 4.14 KB
/
Copy pathgithub-actions.yml
File metadata and controls
104 lines (92 loc) · 4.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Example: run your Daml/Canton app tests against a throwaway Canton
# LocalNet in GitHub Actions, using canton-devkit.
#
# Copy this into your app repo at .github/workflows/localnet-tests.yml
# and adapt the "Run application tests" step. It relies on two
# canton-devkit contracts:
# 1. `localnet up` BLOCKS until the stack is healthy (or fails with
# a non-zero exit + timeout message) — no manual sleep needed.
# 2. Every command returns deterministic exit codes, so a failed
# step fails the job.
#
# The teardown step uses `if: always()` so the LocalNet is always
# cleaned up — even when the test step fails — leaving no dangling
# containers/volumes on a self-hosted runner.
name: LocalNet tests
on:
push:
pull_request:
jobs:
localnet-tests:
# Docker must be available on the runner. GitHub-hosted ubuntu
# runners ship Docker + Compose v2. For macOS/Windows hosted
# runners, or self-hosted, ensure Docker Desktop / Engine is up.
runs-on: ubuntu-latest
env:
# Pin the canton-devkit release you test against (reproducible CI).
DEVKIT_VERSION: v0.15.1
# Pin the Splice LocalNet version (must be in the curated catalogue;
# see `canton-devkit localnet versions`).
SPLICE_VERSION: "0.6.12"
INSTANCE: ci
steps:
- name: Check out app repository
# SHA-pin third-party actions (supply-chain hygiene). Resolve
# the SHA for the tag you want and keep the human-readable tag
# in a comment. This pin = actions/checkout@v5.
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
- name: Install canton-devkit
run: |
set -euo pipefail
# Releases publish a tar.gz per platform plus a SHA256SUMS file
# with one line per asset. Verify the archive against SHA256SUMS
# before extracting.
asset="canton-devkit_${DEVKIT_VERSION}_linux_amd64.tar.gz"
base="https://github.com/bitdynamics-ab/canton-devkit/releases/download/${DEVKIT_VERSION}"
curl -fL -o "${asset}" "${base}/${asset}"
curl -fL -o SHA256SUMS "${base}/SHA256SUMS"
grep " ${asset}\$" SHA256SUMS | sha256sum -c -
tar -xzf "${asset}"
chmod +x canton-devkit
sudo mv canton-devkit /usr/local/bin/
canton-devkit version
- name: Host preflight (Docker, Compose, memory, disk)
run: canton-devkit localnet doctor
- name: Start LocalNet (blocks until healthy)
run: |
canton-devkit localnet up \
--name "${INSTANCE}" \
--version "${SPLICE_VERSION}"
- name: Export endpoints for the test step
run: |
# `localnet env --format github-env` prints bare KEY=VALUE lines
# (Ledger API, JSON API, admin API, wallet/scan URLs, party IDs).
# Append them to $GITHUB_ENV so subsequent steps see them as env
# vars. The github-env format is required here: the default
# `shell` format emits `#` comment lines and `export KEY='value'`,
# which the GitHub Actions env-file parser rejects.
canton-devkit localnet env --name "${INSTANCE}" --format github-env >> "${GITHUB_ENV}"
- name: (Optional) Upload your DAR
run: |
if [ -f ./dist/my-app.dar ]; then
canton-devkit localnet dar upload ./dist/my-app.dar --instance "${INSTANCE}"
else
echo "No DAR to upload — skipping."
fi
- name: Run application tests
run: |
# Replace with your test runner. The endpoints exported above
# are available as env vars (e.g. PARTICIPANT_LEDGER_API_*,
# JSON_API_URL, party IDs — see `localnet env` output).
#
# npm test
# pytest
# daml test
echo "Run your integration tests here against the live LocalNet."
- name: Tear down LocalNet
if: always()
run: |
# always() ensures cleanup even if tests failed. `remove`
# removes containers, volumes, and registry state for the
# instance in one shot.
canton-devkit localnet remove --name "${INSTANCE}" --force || true