Skip to content

Commit 8305ec2

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

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

.github/workflows/test-demo.yaml

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