Skip to content

Commit f7702a6

Browse files
authored
Check on CI demo sanity on Mac and Linux (#2139)
After #2138 , we figured that it would be useful to actually check on CI that our Mac set-up is still running without any errors. I added a test workflow as part of the `nix flake check` to test the `demo` on both Linux and Mac machines. Currently, we have logic in `network-test.yaml`, which tests `demo`'s resilience to network failures. It uses specialised tools for this that are Linux-specific, so we can not reuse the current flow to simply adopt Mac. --- <!-- Consider each and tick it off one way or the other --> * [x] CHANGELOG updated or not needed * [x] Documentation updated or not needed * [x] Haddocks updated or not needed * [x] No new TODOs introduced or explained herafter
2 parents a308f41 + 27779fc commit f7702a6

File tree

3 files changed

+50
-5
lines changed

3 files changed

+50
-5
lines changed

.github/workflows/ci-nix.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,10 @@ jobs:
188188

189189
nix-flake-check:
190190
name: "nix flake check"
191-
runs-on: ubuntu-latest
191+
runs-on: ${{ matrix.os }}
192+
strategy:
193+
matrix:
194+
os: [ubuntu-latest, macos-latest]
192195
steps:
193196
- name: Reclaim the bytes
194197
uses: data-intuitive/reclaim-the-bytes@v2

nix/hydra/demo.nix

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@
1616

1717
processes = {
1818
prepare-devnet = {
19-
command = "${self}/demo/prepare-devnet.sh";
19+
working_dir = ".";
20+
command = ''
21+
${pkgs.bash}/bin/bash ${self}/demo/prepare-devnet.sh
22+
'';
2023
};
2124
cardano-node = {
25+
working_dir = ".";
2226
command = ''
2327
${pkgs.cardano-node}/bin/cardano-node run \
2428
--config devnet/cardano-node.json \
@@ -33,6 +37,7 @@
3337
depends_on."prepare-devnet".condition = "process_completed";
3438
};
3539
seed-devnet = {
40+
working_dir = ".";
3641
command = ''
3742
${self}/demo/seed-devnet.sh ${pkgs.cardano-cli}/bin/cardano-cli ${self'.packages.hydra-node}/bin/hydra-node
3843
'';
@@ -45,7 +50,7 @@
4550
checkPhase = ""; # not shellcheck and choke on sourcing .env
4651
text = ''
4752
# (Re-)Export all variables from .env
48-
set -a; source .env; set +a
53+
set -a; [ -f .env ] && source .env; set +a
4954
${self'.packages.hydra-node}/bin/hydra-node \
5055
--node-id 1 \
5156
--listen 127.0.0.1:5001 \
@@ -67,6 +72,7 @@
6772
--contestation-period 3s
6873
'';
6974
};
75+
working_dir = ".";
7076
ready_log_line = "NodeIsLeader";
7177
depends_on."seed-devnet".condition = "process_completed";
7278
};
@@ -77,7 +83,7 @@
7783
checkPhase = ""; # not shellcheck and choke on sourcing .env
7884
text = ''
7985
# (Re-)Export all variables from .env
80-
set -a; source .env; set +a
86+
set -a; [ -f .env ] && source .env; set +a
8187
${self'.packages.hydra-node}/bin/hydra-node \
8288
--node-id 2 \
8389
--listen 127.0.0.1:5002 \
@@ -99,6 +105,7 @@
99105
--contestation-period 3s
100106
'';
101107
};
108+
working_dir = ".";
102109
ready_log_line = "NodeIsLeader";
103110
depends_on."seed-devnet".condition = "process_completed";
104111
};
@@ -109,7 +116,7 @@
109116
checkPhase = ""; # not shellcheck and choke on sourcing .env
110117
text = ''
111118
# (Re-)Export all variables from .env
112-
set -a; source .env; set +a
119+
set -a; [ -f .env ] && source .env; set +a
113120
${self'.packages.hydra-node}/bin/hydra-node \
114121
--node-id 3 \
115122
--listen 127.0.0.1:5003 \
@@ -131,6 +138,7 @@
131138
--contestation-period 3s
132139
'';
133140
};
141+
working_dir = ".";
134142
ready_log_line = "NodeIsLeader";
135143
depends_on."seed-devnet".condition = "process_completed";
136144
};
@@ -170,6 +178,39 @@
170178
is_foreground = true;
171179
depends_on."hydra-node-carol".condition = "process_started";
172180
};
181+
test = {
182+
command = pkgs.writeShellApplication {
183+
name = "demo-test";
184+
runtimeInputs = [ pkgs.coreutils pkgs.cardano-cli pkgs.cardano-node self'.packages.hydra-node ];
185+
text = ''
186+
set -euo pipefail
187+
188+
echo "--- Testing demo components"
189+
190+
# Test that we can build and run basic components
191+
echo "Testing cardano-cli..."
192+
cardano-cli --version
193+
194+
echo "Testing cardano-node..."
195+
cardano-node --version
196+
197+
echo "✅ Demo setup completed successfully"
198+
199+
echo "--- Testing that devnet files exist"
200+
if [ -f "devnet/cardano-node.json" ] && [ -f "devnet/topology.json" ]; then
201+
echo "✅ Devnet configuration files created"
202+
else
203+
echo "❌ Devnet configuration files missing"
204+
exit 1
205+
fi
206+
207+
echo "--- Testing hydra-node"
208+
hydra-node --version
209+
'';
210+
};
211+
# Ensure test starts only after devnet has been prepared
212+
depends_on."prepare-devnet".condition = "process_completed";
213+
};
173214
};
174215
};
175216
};

nix/hydra/packages.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@
185185
hydra-node
186186
pkgs.cardano-node
187187
pkgs.cardano-cli
188+
] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [
188189
pkgs.dool
189190
];
190191
};

0 commit comments

Comments
 (0)