Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/test-demo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash

# nix build .#overview
# podman run --privileged \
# --volume ./result/project/Cryptpad/default.nix:/default.nix \
# --volume .github/workflows/test-demo.sh:/test-demo.sh <DISTRO> /bin/bash \
# -c "bash /test-demo.sh <DISTRO>"

set -euo pipefail

DISTRO="$1"
# shellcheck disable=SC2089,2026
NIX_CONFIG='substituters = https://cache.nixos.org/ https://ngi.cachix.org/'$'\n''trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= ngi.cachix.org-1:n+CAL72ROC3qQuLxIHpV+Tw5t42WhXmMhprAGkRSrOw='
export NIX_CONFIG


echo -e "\n-> Installing Nix ..."
# Debian/Ubuntu
if echo "$DISTRO" | grep --quiet "debian\|ubuntu"; then
apt update
apt install --yes curl git jq nix
# Archlinux
elif echo "$DISTRO" | grep --quiet archlinux; then
pacman --sync --refresh --noconfirm curl git jq nix
# Other
Comment thread
eljamm marked this conversation as resolved.
else
echo "ERROR: Unknown distro. Exiting ..."
exit 1
fi

echo -e "\n-> Nix version ..."
function fver { printf '%d%02d%02d' "${1}" "${2:-0}" "${3:-0}"; }
NIX_VERSION=$(fver $(nix --version | grep -oP '([0-9]+\.?)+' | sed 's/\./ /g'))
echo "Nix version: $NIX_VERSION"

echo -e "\n-> Building VM ..."
# Nix versions < 2.24 don't work for our use case due to regression in
# closureInfo.
# https://github.com/NixOS/nix/issues/6820
if [ "$NIX_VERSION" -ge 22400 ]; then
Comment thread
imincik marked this conversation as resolved.
echo "Using Nix installed by Linux package manager"
nix-build /default.nix
else
echo "Using Nix from Nixpkgs unstable"

nixpkgs_revision=$(
nix-instantiate --eval --attr sources.nixpkgs.rev https://github.com/ngi-nix/ngipkgs/archive/master.tar.gz \
| jq --raw-output
)
NIXPKGS="https://github.com/NixOS/nixpkgs/archive/$nixpkgs_revision.tar.gz"

nix-shell --include nixpkgs="$NIXPKGS" --packages nix --run "nix-build /default.nix"
fi

echo -e "\n-> Launching VM ..."
./result &

echo -e "\n-> Running test ..."
curl --retry 10 --retry-all-errors --fail localhost:9000 | grep CryptPad
42 changes: 42 additions & 0 deletions .github/workflows/test-demo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Test VM demo

permissions: {}

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

Comment thread
imincik marked this conversation as resolved.
jobs:
test:
strategy:
fail-fast: false
matrix:
distro:
- "archlinux:latest"
- "debian:12"
- "debian:unstable"
- "ubuntu:24.04"
- "ubuntu:24.10"
- "ubuntu:devel"

runs-on: ubuntu-latest
steps:
- uses: 'actions/checkout@v4'
Comment thread
imincik marked this conversation as resolved.
with: { persist-credentials: false }

- uses: DeterminateSystems/nix-installer-action@21a544727d0c62386e78b4befe52d19ad12692e3 #v17

- name: Build projects overview
run: nix build .#overview

- name: Run and test VM
run: >
docker run
--privileged
--volume ./result/project/Cryptpad/default.nix:/default.nix
Comment thread
imincik marked this conversation as resolved.
--volume "$(pwd)/.github/workflows/test-demo.sh:/test-demo.sh"
${{ matrix.distro }}
/bin/bash -c "bash /test-demo.sh ${{ matrix.distro }}"