diff --git a/.github/deskrun b/.github/deskrun new file mode 100755 index 000000000..367c9898d --- /dev/null +++ b/.github/deskrun @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus +export WAYLAND_DISPLAY=wayland-0 +export DISPLAY=:0.0 + +exec "$@" diff --git a/.github/workflows/test-snap-can-build.yml b/.github/workflows/test-snap-can-build.yml index 5b55a10bd..dceb6b828 100644 --- a/.github/workflows/test-snap-can-build.yml +++ b/.github/workflows/test-snap-can-build.yml @@ -9,19 +9,65 @@ permissions: contents: read jobs: - build: + build-and-test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 - - uses: snapcore/action-build@v1 + - name: Build snap + uses: snapcore/action-build@v1 id: build - - uses: diddlesnaps/snapcraft-review-action@v1 + - name: Review snap + uses: diddlesnaps/snapcraft-review-action@v1 with: snap: ${{ steps.build.outputs.snap }} isClassic: 'false' - # Plugs and Slots declarations to override default denial (requires store assertion to publish) - # plugs: ./plug-declaration.json - # slots: ./slot-declaration.json \ No newline at end of file + + - name: Enable KVM on runner + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + + - name: Setup LXD + uses: canonical/setup-lxd@v0.1.1 + + - name: Setup test VM + run: | + # Start a desktop VM + lxc launch images:ubuntu/22.04/desktop test-vm --vm \ + -c limits.cpu=1 -c limits.memory=6GiB -d root,size=12GiB + + # Push the snap we just built into the VM and install it + lxc file push "${{ steps.build.outputs.snap }}" test-vm/home/ubuntu/signal.snap + lxc exec test-vm -- snap install /home/ubuntu/signal.snap --dangerous + + # Install gnome-screenshot + lxc exec test-vm -- apt-get update + lxc exec test-vm -- apt-get -y gnome-screenshot + + # Push the deskrun tool into the VM + lxc file push .github/deskrun test-vm/bin/deskrun + + - name: Start Signal Desktop in the VM + run: | + lxc exec test-vm -- sudo -u ubuntu bash -c "/bin/deskrun snap run signal-desktop &>/home/ubuntu/signal.log &" + sleep 10 + + - name: Take screenshots and pull from VM + run: | + lxc exec test-vm -- sudo -u ubuntu bash -c "/bin/deskrun gnome-screenshot -f /home/ubuntu/screen.png" + lxc exec test-vm -- sudo -u ubuntu bash -c "/bin/deskrun gnome-screenshot -w -f /home/ubuntu/window.png" + lxc file pull test-vm/home/ubuntu/screen.png screen.png + lxc file pull test-vm/home/ubuntu/window.png window.png + + - name: Upload screenshots as artifacts + uses: actions/upload-artifact@v3 + with: + name: screenshots + path: | + screen.png + window.png \ No newline at end of file