From 5aa28c31d5505dde86e77b5b26854dbcd92cf617 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Wed, 1 May 2024 04:06:00 -0600 Subject: [PATCH] CI: Use a local GitHub Action to setup installed packages --- .github/actions/setup/action.yml | 86 +++++++++++++++++++ .github/workflows/cmake.yml | 40 +-------- .../workflows/pvs-studio-static-analysis.yml | 16 ++-- .github/workflows/serenity-js-artifacts.yml | 27 ++---- .../workflows/sonar-cloud-static-analysis.yml | 18 ++-- 5 files changed, 110 insertions(+), 77 deletions(-) create mode 100644 .github/actions/setup/action.yml diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 00000000000..0b5b6ec5be7 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,86 @@ +name: 'Setup action' +description: 'Sets up the dependencies for the CI VM' +author: 'Andrew Kaster ' +inputs: + os: + description: 'Operating System to set up' + required: true + default: 'Linux' + arch: + description: 'Target Architecture to set up' + required: false + default: 'x86_64' +runs: + using: "composite" + steps: + # Set default Python to python 3.x, and set Python path such that pip install works properly + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: 'Install Dependencies' + if: ${{ inputs.os == 'Linux' }} + shell: bash + run: | + # These packages are already part of the ubuntu-22.04 image: + # cmake libgmp-dev npm shellcheck + # Packages below aren't. + + set -e + sudo apt-get purge -y clang-13 clang-14 clang-15 gcc-10 gcc-11 gcc-12 + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main' + sudo apt-get update + sudo apt-get install ccache clang-18 clang++-18 lld-18 clang-format-18 ninja-build unzip qt6-base-dev qt6-tools-dev-tools libqt6svg6-dev qt6-multimedia-dev libgl1-mesa-dev libpulse-dev libssl-dev libegl1-mesa-dev + + sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-18 100 + sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 100 + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 100 + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 100 + + wget https://github.com/WebAssembly/wabt/releases/download/1.0.23/wabt-1.0.23-ubuntu.tar.gz + tar -xzf ./wabt-1.0.23-ubuntu.tar.gz + rm ./wabt-1.0.23-ubuntu.tar.gz + + - name: 'Install JS dependencies' + if: ${{ inputs.os == 'Linux' || inputs.os == 'Serenity' }} + shell: bash + run: sudo npm install -g prettier@2.7.1 + + - name: 'Install Python dependencies' + if: ${{ inputs.os == 'Linux' || inputs.os == 'Serenity' }} + shell: bash + # The setup-python action set default python to python3.x. Note that we are not using system python here. + run: | + python -m pip install --upgrade pip + pip install flake8 requests + + - name: 'Install Dependencies' + if: ${{ inputs.os == 'Serenity' }} + shell: bash + run: | + set -e + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main' + sudo apt-get update + sudo apt-get install clang-format-18 ccache e2fsprogs gcc-13 g++-13 libstdc++-13-dev libmpfr-dev libmpc-dev ninja-build optipng qemu-utils qemu-system-i386 unzip generate-ninja libegl1-mesa-dev + + if ${{ inputs.arch == 'aarch64' }}; then + # FIXME: Remove this when we no longer build our own Qemu binary. + sudo apt-get install libgtk-3-dev libpixman-1-dev libsdl2-dev libslirp-dev + fi + + - name: Enable KVM group perms + if: ${{ inputs.os == 'Serenity' }} + shell: bash + 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: 'Install Dependencies' + if: ${{ inputs.os == 'macOS' }} + shell: bash + run: | + set -e + brew install coreutils bash ninja wabt ccache unzip qt llvm@18 diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 0450beb8236..4ad1a84c1c1 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -42,43 +42,11 @@ jobs: with: ref: refs/pull/${{ github.event.pull_request.number }}/merge - # Set default Python to python 3.x, and set Python path such that pip install works properly - - uses: actions/setup-python@v5 + - name: 'Set up environment' + uses: ./.github/actions/setup with: - python-version: '3.x' - - # === OS SETUP === - - # Do we need to update the package cache first? - # sudo apt-get update -qq - - name: "Install Ubuntu dependencies" - # These packages are already part of the ubuntu-22.04 image: - # cmake libgmp-dev npm shellcheck - # Packages below aren't. - run: | - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main' - sudo apt-get update - sudo apt-get install -y clang-format-18 ccache e2fsprogs gcc-13 g++-13 libstdc++-13-dev libmpfr-dev libmpc-dev ninja-build optipng qemu-utils qemu-system-i386 unzip generate-ninja libegl1-mesa-dev - if ${{ matrix.arch == 'aarch64' }}; then - # FIXME: Remove this when we no longer build our own Qemu binary. - sudo apt-get install libgtk-3-dev libpixman-1-dev libsdl2-dev libslirp-dev - fi - - name: Install JS dependencies - run: sudo npm install -g prettier@2.7.1 - - name: Install Python dependencies - # The setup-python action set default python to python3.x. Note that we are not using system python here. - run: | - python -m pip install --upgrade pip - pip install flake8 requests - - name: Check versions - run: set +e; g++ --version; g++-13 --version; clang-format --version; clang-format-18 --version; prettier --version; python --version; python3 --version; ninja --version; flake8 --version; ccache --version; qemu-system-i386 --version; gn --version - - - name: Enable KVM group perms - 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 + os: 'Serenity' + arch: ${{ matrix.arch }} # === PREPARE FOR BUILDING === diff --git a/.github/workflows/pvs-studio-static-analysis.yml b/.github/workflows/pvs-studio-static-analysis.yml index 5ec11abdff1..b0fa1245efa 100644 --- a/.github/workflows/pvs-studio-static-analysis.yml +++ b/.github/workflows/pvs-studio-static-analysis.yml @@ -19,16 +19,16 @@ jobs: wget -q -O - https://files.pvs-studio.com/beta/etc/pubkey.txt | sudo apt-key add - sudo wget -O /etc/apt/sources.list.d/viva64.list https://files.pvs-studio.com/beta/etc/viva64.list - - name: "Install Ubuntu dependencies" - # These packages are already part of the ubuntu-22.04 image: - # cmake libgmp-dev npm shellcheck - # Packages below aren't. - # + - name: "Set up environment" + uses: ./.github/actions/setup + with: + os: 'Serenity' + arch: ${{ env.PVS_STUDIO_ANALYSIS_ARCH }} + + - name: "Install PVS Studio" run: | - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main' sudo apt-get update - sudo apt-get install -y clang-format-18 gcc-13 g++-13 libstdc++-13-dev libmpfr-dev libmpc-dev ninja-build unzip pvs-studio + sudo apt-get install -y pvs-studio - name: Check versions run: set +e; g++ --version; g++-13 --version; ninja --version; diff --git a/.github/workflows/serenity-js-artifacts.yml b/.github/workflows/serenity-js-artifacts.yml index 1ee410f0a90..7047eb6ca35 100644 --- a/.github/workflows/serenity-js-artifacts.yml +++ b/.github/workflows/serenity-js-artifacts.yml @@ -14,9 +14,11 @@ jobs: matrix: os: [ubuntu-22.04] package_type: [Linux-x86_64] + os_name: [Linux] include: - os: macos-14 package_type: macOS-universal2 + os_name: macOS concurrency: group: ${{ github.workflow }}-${{ matrix.os }} @@ -26,26 +28,11 @@ jobs: - name: Checkout SerenityOS/serenity uses: actions/checkout@v4 - - name: Install dependencies Ubuntu - run: | - sudo apt-get update - sudo apt-get install -y ninja-build unzip gcc-13 g++-13 - if: ${{ matrix.os == 'ubuntu-22.04' }} - - - name: Install dependencies macOS - run: | - brew install bash ninja unzip - if: ${{ matrix.os == 'macos-14' }} - - - name: Check versions Ubuntu - run: | - ninja --version; gcc-13 --version; g++-13 --version - if: ${{ matrix.os == 'ubuntu-22.04' }} - - - name: Check versions macOS - run: | - ninja --version; clang++ --version - if: ${{ matrix.os == 'macos-14' }} + - name: "Set up environment" + uses: ./.github/actions/setup + with: + os: ${{ matrix.os_name }} + arch: 'Lagom' - name: Create build directory run: | diff --git a/.github/workflows/sonar-cloud-static-analysis.yml b/.github/workflows/sonar-cloud-static-analysis.yml index 057b2963e17..3540113129e 100644 --- a/.github/workflows/sonar-cloud-static-analysis.yml +++ b/.github/workflows/sonar-cloud-static-analysis.yml @@ -50,20 +50,12 @@ jobs: echo "sonar.python.version=3.7, 3.8, 3.9" >> ${{ github.workspace }}/sonar-project.properties # === OS SETUP === - # TODO: Is there someway to share these steps with the cmake.yml? - - name: "Install Ubuntu dependencies" - # These packages are already part of the ubuntu-22.04 image: - # cmake libgmp-dev npm shellcheck - # Packages below aren't. - run: | - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main' - sudo apt-get update - sudo apt-get install -y clang-format-18 gcc-13 g++-13 libstdc++-13-dev libmpfr-dev libmpc-dev ninja-build unzip - - - name: Check versions - run: set +e; g++ --version; g++-13 --version; ninja --version; + - name: "Set up environment" + uses: ./.github/actions/setup + with: + os: 'Serenity' + arch: ${{ env.SONAR_ANALYSIS_ARCH }} - name: Prepare useful stamps id: stamps