From ab6cb2ba0f2b1c2d7058c934dff39c567c690bde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=20Go=C3=B1i?= Date: Tue, 29 Oct 2024 13:25:01 +0100 Subject: [PATCH] Improve CI to check the install script --- .github/workflows/rust.yml | 25 +++++++++++++++++++++---- ci-helpers/check-installation.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 4 deletions(-) create mode 100755 ci-helpers/check-installation.sh diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index b83d0a3..da91454 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,6 +1,7 @@ -name: Rust +name: CI on: + workflow_dispatch: push: branches: [ main ] pull_request: @@ -11,16 +12,14 @@ env: jobs: build: - runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: rui314/setup-mold@v1 - uses: awalsh128/cache-apt-pkgs-action@latest with: - packages: libdbus-1-dev libusb-dev libhidapi-dev libhidapi-hidraw0 pkg-config libudev-dev libgtk-3-dev + packages: libdbus-1-dev libusb-dev libhidapi-dev libhidapi-hidraw0 pkg-config libudev-dev libgtk-3-dev version: 1.0 - - name: "Install Rust" uses: dtolnay/rust-toolchain@stable - name: "Cache cargo" @@ -31,3 +30,21 @@ jobs: - name: Run tests working-directory: ./razer_control_gui run: cargo test --verbose + + install: + # This assumes that the worker will be using systemctl + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v4 + - uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: libdbus-1-dev libusb-dev libhidapi-dev libhidapi-hidraw0 pkg-config libudev-dev libgtk-3-dev + version: 1.0 + - name: "Install" + working-directory: ./razer_control_gui + # According to this, sudo sould run ok: https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#administrative-privileges + run: ./install.sh install + - name: "Check installation" + working-directory: ./razer_control_gui + run: ../ci-helpers/check_installation.sh diff --git a/ci-helpers/check-installation.sh b/ci-helpers/check-installation.sh new file mode 100755 index 0000000..f54c233 --- /dev/null +++ b/ci-helpers/check-installation.sh @@ -0,0 +1,29 @@ +set -o errexit +set -o nounset +set -o pipefail + +check_file() { + if [ ! -e $1 ]; then + echo "File \"$1\" does not exist." + exit 1 + fi +} + +echo "Checking the existence of the necessary files..." +# Daemon +# check_file "~/.local/share/razercontrol" +check_file "/usr/share/razercontrol/daemon" +check_file "/usr/share/razercontrol/laptops.json" +check_file "/etc/udev/rules.d/99-hidraw-permissions.rules" +# CLI +check_file "/usr/bin/razer-cli" +# GUI +check_file "/usr/bin/razer-settings" +check_file "/usr/share/applications/razer-settings.desktop" +echo "All files are present" + + +printf "Checking that the service is enabled: " +systemctl --user is-enabled razercontrol.service + +echo "Done!"