From 6f031e4dac0e0c331b3faf22a50760c539da1a14 Mon Sep 17 00:00:00 2001 From: Max Gaukler Date: Tue, 23 Jan 2024 19:15:41 +0100 Subject: [PATCH] Fix CI (hopefully) --- .github/workflows/unittest.yml | 28 +++++++++++++++++ .github/workflows/vagrant-unittest.yml | 24 -------------- install_debian.sh | 43 ++++++++++++++++++++------ 3 files changed, 61 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/unittest.yml delete mode 100644 .github/workflows/vagrant-unittest.yml diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml new file mode 100644 index 0000000..407a351 --- /dev/null +++ b/.github/workflows/unittest.yml @@ -0,0 +1,28 @@ +name: Run Unittests + +on: [push, pull_request] + +jobs: + vagrant-run-unittest: + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v2 + + + - name: install dependencies + run: ./install_debian.sh + + - name: debug + run: ls config.ini || true + + - name: debug + run: ./run.py --example --only-load-config + + - name: debug + run: ls config.ini || true + + + + - name: Run Unittests + run: ./run_unittests_locally.sh diff --git a/.github/workflows/vagrant-unittest.yml b/.github/workflows/vagrant-unittest.yml deleted file mode 100644 index fc4b1e9..0000000 --- a/.github/workflows/vagrant-unittest.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Vagrant run Unittest - -on: [pull_request] - -jobs: - vagrant-run-unittest: - runs-on: macos-latest - - steps: - - uses: actions/checkout@v2 - - - name: Cache Vagrant boxes - uses: actions/cache@v3 - with: - path: ~/.vagrant.d/boxes - key: ${{ runner.os }}-vagrant-${{ hashFiles('Vagrantfile') }} - restore-keys: | - ${{ runner.os }}-vagrant- - - - name: Run vagrant provision - run: vagrant provision - - - name: Run Unittests - run: ./run_unittests_in_vagrant.sh diff --git a/install_debian.sh b/install_debian.sh index 9ef8b49..75233e6 100755 --- a/install_debian.sh +++ b/install_debian.sh @@ -1,11 +1,23 @@ #!/bin/bash set -e + # provisioning for Debian / Ubuntu + + +# Detect CI (GitHub/Vagrant) + +GITHUB_ACTIONS="${GITHUB_ACTIONS:-false}" +[ -d /home/vagrant ] && echo "Running under Vagrant, using the vagrant user" && RUNNING_IN_VAGRANT=true || RUNNING_IN_VAGRANT=false + echo "ONLY RUN THIS SCRIPT on a disposable VM or a PC specially for setting up kasse. It will change your xsession and uninstall some packages." echo "press ctrl-c to exit, Enter to continue (will continue automatically under Vagrant provisioner)" -read -[ -d /home/vagrant ] && echo "Running under Vagrant, using the vagrant user" && RUNNING_IN_VAGRANT=true || RUNNING_IN_VAGRANT=false +if $GITHUB_ACTIONS; then + echo "continuing, we are in GitHub CI" +else + read +fi + # change to the git directory if $RUNNING_IN_VAGRANT; then @@ -40,13 +52,22 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get -y install psmisc socat # Intended for use in a separate VM or on the real cash system. # ~~~~~~~~~~~~~~~ -# Graphical environment and styling -sudo DEBIAN_FRONTEND=noninteractive apt-get -y install xserver-xorg git nodm ssh x11-apps xterm breeze breeze-icon-theme fonts-roboto-fontface curl -# try to install xrandr command -sudo DEBIAN_FRONTEND=noninteractive apt-get -y install x11-xserver-utils || true +if ! $GITHUB_ACTIONS; then + # Graphical environment and styling + sudo DEBIAN_FRONTEND=noninteractive apt-get -y install xserver-xorg git nodm ssh x11-apps xterm breeze breeze-icon-theme fonts-roboto-fontface curl + # try to install xrandr command + sudo DEBIAN_FRONTEND=noninteractive apt-get -y install x11-xserver-utils || true +fi # Setup user and 'kiosk mode' desktop manager that autostarts FabLabKasse -$RUNNING_IN_VAGRANT && INSTALL_USER=vagrant || INSTALL_USER=kasse +if $RUNNING_IN_VAGRANT; then + INSTALL_USER=vagrant +elif $GITHUB_ACTIONS; then + INSTALL_USER=runner +else + INSTALL_USER=kasse +fi + (! $RUNNING_IN_VAGRANT && ! test -d /home/kasse ) && sudo adduser kasse --disabled-password # not used in Vagrant, but in real system # some package installs lightdm; we don't want it. @@ -84,9 +105,11 @@ cd /home/$INSTALL_USER/FabLabKasse/ && sudo -u $INSTALL_USER ./run.py --example echo "Warning: if no config exists, an example config will be installed. Please change it if you use this for a real system" echo "Warning: For using it on a real system, cronjobs must be setup manually, please see INSTALLING.md" -sudo service nodm stop -sleep 2 -sudo service nodm start +if ! $GITHUB_ACTIONS; then + sudo service nodm stop + sleep 2 + sudo service nodm start +fi # append if no such line, similar to https://fai-project.org/doc/man/ainsl.html. # Adapted from https://unix.stackexchange.com/questions/530537/more-elegant-approach-to-append-text-to-a-file-only-if-the-string-doesnt-exist/530722#530722