Self Hosted Runner Ubuntu 18 and 20 Unit Testing #22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Self Hosted Runner Ubuntu 18 and 20 Unit Testing | |
on: | |
schedule: | |
- cron: "0 17 * * 0-4" # sunday to thursday at 5 pm UTC, for Amsterdam it is +1 UTC during winter and +2 UTC during summer | |
jobs: | |
full_test: | |
runs-on: [self-hosted, Linux] | |
# strategy.matrix total timeout of 20 hours | |
timeout-minutes: 1200 | |
strategy: | |
# Don't cancel all in-progress and queued jobs in the matrix if any job in the matrix fails | |
fail-fast: false | |
matrix: | |
vm_name: ["Odemis Testing 18", "Odemis Testing 20"] | |
steps: | |
- name: List of all VMs | |
run: VBoxManage list vms | |
- name: List of running VMs | |
run: VBoxManage list runningvms | |
- name: Stop VM and VirtualBox Manager in case its running | |
env: | |
VM_NAME: ${{ matrix.vm_name }} | |
run: | | |
VBoxManage controlvm "$VM_NAME" acpipowerbutton | |
exit_status=$? | |
if [ $exit_status -eq 0 ]; then sleep 10s; fi | |
if [ $(pidof VirtualBox) >/dev/null ]; then killall VirtualBox; fi | |
continue-on-error: true | |
- name: Start VM and execute test-cases inside VM | |
env: | |
# See in GitHub Settings/Security sidebar/Secrets and variables/Actions/Secrets tab/Repository secrets | |
CI_VM_PASSWORD: ${{ secrets.CI_VM_PASSWORD }} | |
VM_NAME: ${{ matrix.vm_name }} | |
# The ci user of the CI server should automatically be logged in | |
# The autologin starts up the gdm-session-worker -> gdm-x-session -> Xorg | |
# The Xorg process is /usr/lib/xorg/Xorg vt2 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -background none -noreset -keeptty -verbose 3 | |
# When Xorg starts on the virtual terminal specified by vt2, it becomes the X server running on :0 | |
# This allows applications to connect and display their graphical output on that display | |
# Start the VirtualBox Manager | |
# Sleep for 5s to give VirtualBox Manager some time to start | |
# The testing user of the Virtual Machine should automatically be logged in for the display (or the xserver) to be started | |
# Pass the DISPLAY to the Virtual Machine while starting it | |
# Sleep for 1.5m to give the Virtual Machine time to start and automatically login | |
# Set runpytest_wrapper.sh execution timeout of 8 hours, i.e. 8 * 60 * 60 * 1000 = 28800000 milliseconds | |
run: | | |
export DISPLAY=:0 | |
VirtualBox & | |
sleep 5s | |
echo "Started VirtualBox with PID $(pidof VirtualBox)" | |
VBoxManage startvm "$VM_NAME" --putenv "DISPLAY=:0" | |
sleep 1.5m | |
VBoxManage --nologo guestcontrol "$VM_NAME" run --exe "/home/testing/development/odemis-testing/runpytest_wrapper.sh" --putenv "DISPLAY=:0" --username testing --password "$CI_VM_PASSWORD" --wait-stdout --timeout 28800000 | |
continue-on-error: true | |
- name: Summary | |
env: | |
CI_VM_PASSWORD: ${{ secrets.CI_VM_PASSWORD }} | |
VM_NAME: ${{ matrix.vm_name }} | |
run: VBoxManage --nologo guestcontrol "$VM_NAME" run --exe "/bin/bash" --username testing --password "$CI_VM_PASSWORD" --wait-stdout -- bash -c 'cat $(ls -Art /home/testing/development/odemis-testing/pytest-summary-*.log | tail -n 1)' | |
- name: Full report | |
env: | |
CI_VM_PASSWORD: ${{ secrets.CI_VM_PASSWORD }} | |
VM_NAME: ${{ matrix.vm_name }} | |
run: VBoxManage --nologo guestcontrol "$VM_NAME" run --exe "/bin/bash" --username testing --password "$CI_VM_PASSWORD" --wait-stdout -- bash -c 'cat $(ls -Art /home/testing/development/odemis-testing/unittest-full-*.log | tail -n 1)' | |
- name: Stop VM, VirtualBox Manager | |
env: | |
VM_NAME: ${{ matrix.vm_name }} | |
run: | | |
VBoxManage controlvm "$VM_NAME" acpipowerbutton | |
sleep 10s | |
echo "Killing VirtualBox Manager" | |
killall VirtualBox |