Skip to content

Commit 0e6ed44

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

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

.github/workflows/test-demo.yaml

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: 'actions/checkout@v4'
15+
16+
- name: Install Nix
17+
run: |
18+
sudo apt update
19+
sudo apt install --yes nix
20+
21+
- name: DEBUG
22+
uses: lhotari/action-upterm@v1
23+
24+
- name: Add Nix trusted user
25+
run: |
26+
echo "trusted-users = root $USER" | sudo tee -a /etc/nix/nix.conf
27+
28+
sudo usermod -a -G nix-users $USER
29+
sudo newgrp nix-users
30+
sudo systemctl restart nix-daemon.service
31+
32+
# FIXME: Failing on
33+
# /usr/bin/bash -c nix-env --quiet -j8 -iA cachix -f https://cachix.org/api/v1/install
34+
# error: getting status of /nix/var/nix/daemon-socket/socket: Permission denied
35+
# Error: Action failed with error: Error: The process '/usr/bin/bash' failed with exit code 1
36+
# - uses: cachix/cachix-action@v14
37+
# with: { name: 'ngi' }
38+
39+
# TODO: enable overview build
40+
# - name: Build overview
41+
# run: nix build .#overview
42+
43+
# TODO: download this file from overview
44+
- name: Download default.nix file
45+
run: |
46+
cat <<EOF >default.nix
47+
{
48+
ngipkgs ?
49+
import
50+
(fetchTarball "https://github.com/eljamm/ngipkgs/tarball/init-project-demos/8eb7f038fd62fd6490e017d78e6a30e7b64a13fa")
51+
{ },
52+
}:
53+
let
54+
servicePort = 9000;
55+
domainName = "localhost:\${toString servicePort}";
56+
in
57+
ngipkgs.demo {
58+
services.cryptpad = {
59+
enable = true;
60+
settings = {
61+
httpPort = servicePort;
62+
httpAddress = "0.0.0.0";
63+
httpUnsafeOrigin = "http://\${domainName}";
64+
httpSafeOrigin = "http://\${domainName}";
65+
};
66+
};
67+
68+
networking.firewall.allowedTCPPorts = [ servicePort ];
69+
networking.firewall.allowedUDPPorts = [ servicePort ];
70+
}
71+
EOF
72+
73+
- name: Build VM
74+
run: nix-build default.nix
75+
76+
- name: Run VM
77+
run: ./result &
78+
79+
- name: Test application
80+
run: curl --retry 10 --fail localhost:9000 | grep CryptPad

0 commit comments

Comments
 (0)