Skip to content

Commit b63d2c7

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

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

.github/workflows/test-demo.yaml

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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: "debian:12"
16+
- distro: "debian:unstable"
17+
- distro: "ubuntu:24.04"
18+
- distro: "ubuntu:devel"
19+
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: 'actions/checkout@v4'
23+
24+
# TODO: enable overview build
25+
# - name: Build overview
26+
# run: nix build .#overview
27+
28+
# TODO: download this file from overview
29+
- name: Create default.nix file
30+
run: |
31+
cat <<EOF >default.nix
32+
{
33+
ngipkgs ?
34+
import
35+
(fetchTarball "https://github.com/eljamm/ngipkgs/tarball/init-project-demos/8eb7f038fd62fd6490e017d78e6a30e7b64a13fa")
36+
{ },
37+
}:
38+
let
39+
servicePort = 9000;
40+
domainName = "localhost:\${toString servicePort}";
41+
in
42+
ngipkgs.demo {
43+
services.cryptpad = {
44+
enable = true;
45+
settings = {
46+
httpPort = servicePort;
47+
httpAddress = "0.0.0.0";
48+
httpUnsafeOrigin = "http://\${domainName}";
49+
httpSafeOrigin = "http://\${domainName}";
50+
};
51+
};
52+
53+
networking.firewall.allowedTCPPorts = [ servicePort ];
54+
networking.firewall.allowedUDPPorts = [ servicePort ];
55+
}
56+
EOF
57+
58+
- name: Create test script
59+
run: |
60+
cat <<EOF >test-script.sh
61+
62+
if echo ${{ matrix.distro }} | grep --quiet ubuntu || echo ${{ matrix.distro }} | grep --quiet debian; then
63+
apt update
64+
apt install --yes curl git nix
65+
else
66+
echo "Unknown distro. Exiting ..."
67+
exit 1
68+
fi
69+
70+
nix-build \
71+
--option binary-caches 'https://cache.nixos.org/ https://ngi.cachix.org/' \
72+
--option trusted-public-keys 'cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= ngi.cachix.org-1:n+CAL72ROC3qQuLxIHpV+Tw5t42WhXmMhprAGkRSrOw= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=' \
73+
/default.nix
74+
./result &
75+
curl --retry 20 --retry-all-errors --fail localhost:9000 | grep CryptPad
76+
EOF
77+
78+
- name: Run and test VM
79+
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)