From b2532c81b933572884bfe04fc554e9f24e6d52a0 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Sun, 20 Oct 2024 19:22:13 -0400 Subject: [PATCH] ci: Add install-dependencies action --- .../actions/install-dependencies/action.yml | 100 ++++++++++++++++++ .github/workflows/ci-linux.json | 10 +- .github/workflows/ci.yml | 56 +++------- .github/workflows/codeql-analysis.yml | 7 +- .github/workflows/sonarcloud-analysis.yml | 14 ++- .github/workflows/valgrind-analysis.yml | 14 ++- 6 files changed, 134 insertions(+), 67 deletions(-) create mode 100644 .github/actions/install-dependencies/action.yml diff --git a/.github/actions/install-dependencies/action.yml b/.github/actions/install-dependencies/action.yml new file mode 100644 index 000000000..6778ff7d8 --- /dev/null +++ b/.github/actions/install-dependencies/action.yml @@ -0,0 +1,100 @@ +# SPDX-FileCopyrightText: 2024 Chris Rizzitello +# SPDX-License-Identifier: MIT + +name: "Install dependencies for deskflow" +description: "Install the dependencies needed to build deskflow" + +inputs: + like: + description: "Used only on linux distro type: debian, fedora, suse, arch" + required: false + + mac-qt-version: + description: "The verison of Qt to install on mac os" + required: false + +outputs: + vcpkg-cmake-config: + description: "windows vcpkg output for cmaket" + value: ${{ steps.vcpkg.outputs.vcpkg-cmake-config }} + +runs: + using: "composite" + + steps: + - name: Install Depends + run: | + if [ "$RUNNER_OS" == "Windows" ]; then + echo "Window not supported yet" + elif [ "$RUNNER_OS" == "macOS" ]; then + brew install cmake googletest ninja openssl --quiet + elif [ "$RUNNER_OS" == "Linux" ]; then + if [ ${{inputs.like}} == "debian" ]; then + apt update -qqq > /dev/null + apt install -qqq cmake build-essential ninja-build \ + xorg-dev libx11-dev libxtst-dev libssl-dev \ + libglib2.0-dev libgdk-pixbuf-2.0-dev libnotify-dev \ + libxkbfile-dev qt6-base-dev qt6-tools-dev \ + libgtk-3-dev libgtest-dev libgmock-dev libpugixml-dev \ + libei-dev libportal-dev libtomlplusplus-dev libcli11-dev -y >/dev/null + elif [ ${{inputs.like}} == "fedora" ]; then + dnf install -y cmake make ninja-build gcc-c++ \ + rpm-build openssl-devel glib2-devel \ + gdk-pixbuf2-devel libXtst-devel libnotify-devel \ + libxkbfile-devel qt6-qtbase-devel qt6-qttools-devel \ + gtk3-devel gtest-devel gmock-devel pugixml-devel \ + libei-devel libportal-devel tomlplusplus-devel \ + cli11-devel + elif [ ${{inputs.like}} == "suse" ]; then + zypper refresh + zypper install -y --force-resolution \ + cmake make ninja gcc-c++ rpm-build libopenssl-devel \ + glib2-devel gdk-pixbuf-devel libXtst-devel libnotify-devel \ + libxkbfile-devel qt6-base-devel qt6-tools-devel gtk3-devel \ + googletest-devel googlemock-devel pugixml-devel libei-devel \ + libportal-devel tomlplusplus-devel cli11-devel + elif [ ${{ inputs.like }} == "arch" ]; then + pacman -Syu --noconfirm base-devel cmake ninja \ + gcc openssl glib2 gdk-pixbuf2 libxtst libnotify \ + libxkbfile gtest pugixml libei libportal \ + qt6-base qt6-tools gtk3 tomlplusplus cli11 + else + echo "Unknown like" + fi + else + echo "Unknown OS: $RUNNER_OS" + fi + shell: bash + + - name: Install Qt + if: ${{runner.os == 'macOS' }} + uses: jurplel/install-qt-action@v4 + with: + dir: "/Users/runner" + version: ${{inputs.mac-qt-version}} + cache: true + cache-key-prefix: ${{matrix.target.os}}-${{env.qt-version}} + + # Install Ninja with an action instead of using Chocolatey, as it's more + # reliable and faster. The Ninja install action is pretty good as it + # downloads directly from the `ninja-build` GitHub project releases. + - name: Install Ninja + if: ${{ runner.os == 'Windows' }} + uses: seanmiddleditch/gha-setup-ninja@master + + - name: Build and cache vcpkg + if: ${{ runner.os == 'Windows' }} + id: vcpkg + uses: johnwason/vcpkg-action@v6 + with: + manifest-dir: ${{ github.workspace }} + triplet: x64-windows-release + token: ${{ github.token }} + github-binarycache: true + + - name: Install Wix + if: ${{ runner.os == 'Windows' }} + run: | + dotnet tool install --global wix --version 4.0.4 + wix extension add --global WixToolset.UI.wixext/4.0.4 + shell: pwsh diff --git a/.github/workflows/ci-linux.json b/.github/workflows/ci-linux.json index d5385d8ee..a25ef90d7 100644 --- a/.github/workflows/ci-linux.json +++ b/.github/workflows/ci-linux.json @@ -4,21 +4,25 @@ "name": "debian-13-amd64", "container": "deskflow/deskflow:debian-13-amd64", "runs-on": "ubuntu-latest", + "like": "debian" }, { "name": "fedora-40-arm64", "container": "deskflow/deskflow:fedora-40-arm64", - "runs-on": "ubuntu-24.04-4-core-arm64" + "runs-on": "ubuntu-24.04-4-core-arm64", + "like": "fedora" }, { "name": "fedora-40-amd64", "container": "deskflow/deskflow:fedora-40-amd64", - "runs-on": "ubuntu-latest" + "runs-on": "ubuntu-latest", + "like": "fedora" }, { "name": "opensuse-amd64", "container": "deskflow/deskflow:opensuse-amd64", - "runs-on": "ubuntu-latest" + "runs-on": "ubuntu-latest", + "like": "suse" }, { "name": "archlinux-amd64", diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 468f324ef..d8fd5bf02 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -134,20 +134,9 @@ jobs: - name: Setup VC++ environment uses: ilammy/msvc-dev-cmd@v1 - # Install Ninja with an action instead of using Chocolatey, as it's more - # reliable and faster. The Ninja install action is pretty good as it - # downloads directly from the `ninja-build` GitHub project releases. - - name: Install Ninja - uses: seanmiddleditch/gha-setup-ninja@master - - - name: Dependencies (vcpkg) - id: vcpkg - uses: johnwason/vcpkg-action@v6 - with: - manifest-dir: ${{ github.workspace }} - triplet: x64-windows-release - token: ${{ github.token }} - github-binarycache: true + - name: Install dependencies + id: install-dependencies + uses: ./.github/actions/install-dependencies - name: Setup Python venv run: python ./scripts/setup_venv.py @@ -155,7 +144,7 @@ jobs: - name: Configure run: | ${{env.CMAKE_CONFIGURE}} -G Ninja ` - ${{ steps.vcpkg.outputs.vcpkg-cmake-config }} + ${{ steps.install-dependencies.outputs.vcpkg-cmake-config }} - name: Build run: cmake --build build -j8 @@ -210,19 +199,10 @@ jobs: - name: Fancy Checkout uses: sithlord48/fancy-checkout@v1.0.0 - - name: Install dependencies - run: brew install cmake ninja openssl googletest --quiet - - - name: Install Qt - uses: jurplel/install-qt-action@v4 + - name: Install Dependencies + uses: ./.github/actions/install-dependencies with: - dir: ${{env.qt-install-dir}} - version: ${{env.qt-version}} - cache: true - cache-key-prefix: ${{matrix.target.os}}-${{env.qt-version}} - env: - qt-version: 6.7.2 - qt-install-dir: "/Users/runner" + mac-qt-version: 6.7.2 - name: Configure run: ${{env.CMAKE_CONFIGURE}} ${{matrix.target.extra-cmake-config}} @@ -293,22 +273,10 @@ jobs: - name: Fancy Checkout uses: sithlord48/fancy-checkout@v1.0.0 - - name: Add Kitware repo - if: ${{ matrix.distro.name == 'ubuntu-22.04-amd64' }} - uses: ./.github/actions/add-kitware-repo - with: - distro: jammy - - - name: Update CMake - if: ${{ matrix.distro.name == 'ubuntu-22.04-amd64' }} - run: apt install cmake -y - - name: Install dependencies - run: | - ./scripts/install_deps.py - env: - # Prevent apt prompting for input. - DEBIAN_FRONTEND: noninteractive + uses: ./.github/actions/install-dependencies + with: + distro-like: ${{ matrix.distro.like }} - name: Configure run: | @@ -317,11 +285,11 @@ jobs: ${{ matrix.distro.extra-cmake-args }} - name: Build package - if: ${{ matrix.distro.arch-like != 'true'}} + if: ${{ matrix.distro.like != 'arch'}} run: cmake --build build -j8 --target package - name: Build package (Arch-like) - if: ${{ matrix.distro.arch-like == 'true' }} + if: ${{ matrix.distro.like == 'arch' }} run: | cmake --build build -j8 sudo chown -R build build diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 87dfb21b7..48e29fe0b 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -42,10 +42,9 @@ jobs: uses: sithlord48/fancy-checkout@v1.0.0 - name: Install dependencies - run: ./scripts/install_deps.py - env: - # Prevent apt prompting for input. - DEBIAN_FRONTEND: noninteractive + uses: ./.github/actions/install-dependencies + with: + like: "debian" - name: Initialize CodeQL uses: github/codeql-action/init@v3 diff --git a/.github/workflows/sonarcloud-analysis.yml b/.github/workflows/sonarcloud-analysis.yml index 443bac5f1..37e36ae07 100644 --- a/.github/workflows/sonarcloud-analysis.yml +++ b/.github/workflows/sonarcloud-analysis.yml @@ -25,18 +25,16 @@ jobs: - name: Fancy Checkout uses: sithlord48/fancy-checkout@v1.0.0 - - name: Add Kitware repo - uses: ./.github/actions/add-kitware-repo - with: - distro: jammy - - name: Install dependencies + uses: ./.github/actions/install-dependencies + with: + like: "debian" + + - name: Install dependencies (extra) + run: apt install curl unzip gcovr -y env: # Prevent apt prompting for input. DEBIAN_FRONTEND: noninteractive - run: | - ./scripts/install_deps.py - apt install curl unzip cmake gcovr -y - name: Install sonar-scanner and build-wrapper uses: sonarsource/sonarcloud-github-c-cpp@v3 diff --git a/.github/workflows/valgrind-analysis.yml b/.github/workflows/valgrind-analysis.yml index 63e72823c..ab1ce1895 100644 --- a/.github/workflows/valgrind-analysis.yml +++ b/.github/workflows/valgrind-analysis.yml @@ -14,15 +14,13 @@ jobs: - name: Fancy Checkout uses: sithlord48/fancy-checkout@v1.0.0 - - name: Add Kitware repo - uses: ./.github/actions/add-kitware-repo - with: - distro: jammy - - name: Install dependencies - run: | - ./scripts/install_deps.py - apt install valgrind cmake -y + uses: ./.github/actions/install-dependencies + with: + like: "debian" + + - name: Install valgrind + run: apt install valgrind -y env: # Prevent apt prompting for input. DEBIAN_FRONTEND: noninteractive