Skip to content

Commit b8a16b3

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

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

.github/workflows/test-demo.yaml

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