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