Skip to content

Commit 794b2ac

Browse files
committed
ci: add test-demo workflow
Closes: ngi-nix#698
1 parent e7dd2a3 commit 794b2ac

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

.github/workflows/test-demo.yaml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Test VM demo
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
strategy:
13+
matrix:
14+
include:
15+
- distro: "ubuntu:25.04"
16+
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: 'actions/checkout@v4'
20+
21+
# TODO: enable overview build
22+
# - name: Build overview
23+
# run: nix build .#overview
24+
25+
# TODO: download this file from overview
26+
- name: Create default.nix file
27+
run: |
28+
cat <<EOF >default.nix
29+
{
30+
ngipkgs ?
31+
import
32+
(fetchTarball "https://github.com/eljamm/ngipkgs/tarball/init-project-demos/8eb7f038fd62fd6490e017d78e6a30e7b64a13fa")
33+
{ },
34+
}:
35+
let
36+
servicePort = 9000;
37+
domainName = "localhost:\${toString servicePort}";
38+
in
39+
ngipkgs.demo {
40+
services.cryptpad = {
41+
enable = true;
42+
settings = {
43+
httpPort = servicePort;
44+
httpAddress = "0.0.0.0";
45+
httpUnsafeOrigin = "http://\${domainName}";
46+
httpSafeOrigin = "http://\${domainName}";
47+
};
48+
};
49+
50+
networking.firewall.allowedTCPPorts = [ servicePort ];
51+
networking.firewall.allowedUDPPorts = [ servicePort ];
52+
}
53+
EOF
54+
55+
- name: Create test script
56+
run: |
57+
cat <<EOF >test-script.sh
58+
apt update
59+
apt install --yes curl git nix
60+
nix-build \
61+
--option binary-caches 'https://cache.nixos.org/ https://ngi.cachix.org/' \
62+
--option trusted-public-keys 'cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= ngi.cachix.org-1:n+CAL72ROC3qQuLxIHpV+Tw5t42WhXmMhprAGkRSrOw= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=' \
63+
/default.nix
64+
./result &
65+
curl --retry 20 --retry-all-errors --fail localhost:9000 | grep CryptPad
66+
EOF
67+
68+
- name: Run and test VM
69+
run: docker run --privileged --volume ./default.nix:/default.nix --volume ./test-script.sh:/test-script.sh ${{ matrix.distro }} /bin/bash -c "bash /test-script.sh"

0 commit comments

Comments
 (0)