From 481680d07262230a788d8e2469da57139134c902 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Thu, 11 Jul 2024 15:26:38 +0100 Subject: [PATCH] Run `install_deps.py` script when building containers weekly (#7384) * Don't run CodeQL in PR draft * Speed up analysis workflows * Run install deps on Debian * Add badge to readme * Fixed copy and use workdir * Use mount instead of copy * Fixed unwanted && and changed workdir * Split deps and deps-full * Fixed context * Use /app dir * Use copy instead * Revert to --mount and use .py (not .sh) * Test * Add `./scripts/install_deps.py` to all platforms * Add missing syntax * Fixed Python dep for OpenSUSE * Temp remove WORKDIR for OpenSUSE * Re-add workdir * Increase timeout * Delete `zypper --non-interactive remove busybox-which` * Restore python3 * Test * Rename to `lint-source-code` * Beef up analysis runners * Fixed workflow runs-on * Use deps script * Try pipx for gcovr * Use containers with deps * Add -y arg * Install curl * Merge deps step * Add unzip dep * Make Git dir safe * Add .local/bin to env * Improve step name * Use `pipx ensurepath` * Install gcovr with apt * Use Ubuntu 22 with pip * Update ChangeLog * Use 16-core for Windows * Use choco cache * Test * Use 8-core for Windows (picked up quicker, more available?) --- .github/docker/archlinux/Dockerfile | 13 ++++++- .github/docker/debian/Dockerfile | 15 +++++++- .github/docker/fedora/Dockerfile | 14 +++++++- .github/docker/opensuse/Dockerfile | 15 +++++++- .github/workflows/build-containers.yml | 4 +-- .github/workflows/ci.yml | 10 ++++-- .github/workflows/codeql-analysis.yml | 36 +++++++------------ .../{lint-source.yml => lint-source-code.yml} | 2 +- .github/workflows/sonarcloud-analysis.yml | 17 +++++---- ChangeLog | 1 + README.md | 1 + config.yaml | 1 - 12 files changed, 89 insertions(+), 40 deletions(-) rename .github/workflows/{lint-source.yml => lint-source-code.yml} (97%) diff --git a/.github/docker/archlinux/Dockerfile b/.github/docker/archlinux/Dockerfile index fd409a6e9..172d2f182 100644 --- a/.github/docker/archlinux/Dockerfile +++ b/.github/docker/archlinux/Dockerfile @@ -1,6 +1,17 @@ +# syntax=docker/dockerfile:1 + ARG BASE_IMAGE FROM $BASE_IMAGE AS base -RUN pacman -Syu --noconfirm git python sudo && pacman -Scc --noconfirm +FROM base AS deps + +RUN pacman -Syu --noconfirm git python sudo && \ + pacman -Scc --noconfirm RUN useradd -m build + +WORKDIR /app + +RUN --mount=type=bind,target=/app,rw \ + ./scripts/install_deps.py && \ + pacman -Scc --noconfirm diff --git a/.github/docker/debian/Dockerfile b/.github/docker/debian/Dockerfile index 8939a5f1c..28a24804d 100644 --- a/.github/docker/debian/Dockerfile +++ b/.github/docker/debian/Dockerfile @@ -1,4 +1,17 @@ +# syntax=docker/dockerfile:1 + ARG BASE_IMAGE FROM $BASE_IMAGE AS base -RUN apt update && apt dist-upgrade -y && apt install -y git python3 && apt clean +FROM base AS deps + +RUN apt update && \ + apt dist-upgrade -y && \ + apt install -y git python3 && \ + apt clean + +WORKDIR /app + +RUN --mount=type=bind,target=/app,rw \ + ./scripts/install_deps.py && \ + apt clean diff --git a/.github/docker/fedora/Dockerfile b/.github/docker/fedora/Dockerfile index 327a9775c..819fd01ce 100644 --- a/.github/docker/fedora/Dockerfile +++ b/.github/docker/fedora/Dockerfile @@ -1,4 +1,16 @@ +# syntax=docker/dockerfile:1 + ARG BASE_IMAGE FROM $BASE_IMAGE AS base -RUN dnf upgrade -y && dnf install -y git python3 && dnf clean all +FROM base AS deps + +RUN dnf upgrade -y && \ + dnf install -y git python3 && \ + dnf clean all + +WORKDIR /app + +RUN --mount=type=bind,target=/app,rw \ + ./scripts/install_deps.py && \ + dnf clean all diff --git a/.github/docker/opensuse/Dockerfile b/.github/docker/opensuse/Dockerfile index fa3e00554..c075a1e12 100644 --- a/.github/docker/opensuse/Dockerfile +++ b/.github/docker/opensuse/Dockerfile @@ -1,4 +1,17 @@ +# syntax=docker/dockerfile:1 + ARG BASE_IMAGE FROM $BASE_IMAGE AS base -RUN zypper refresh && zypper update -y && zypper install -y git python3 && zypper clean --all +FROM base AS deps + +RUN zypper refresh && \ + zypper update -y && \ + zypper install -y git python3 && \ + zypper clean --all + +WORKDIR /app + +RUN --mount=type=bind,target=/app,rw \ + ./scripts/install_deps.py && \ + zypper clean --all diff --git a/.github/workflows/build-containers.yml b/.github/workflows/build-containers.yml index 5e2a3a26a..43b26dfca 100644 --- a/.github/workflows/build-containers.yml +++ b/.github/workflows/build-containers.yml @@ -18,7 +18,7 @@ jobs: name: ${{ matrix.os.name }} runs-on: ${{ matrix.os.runs-on }} if: ${{ vars.BUILD_CONTAINERS }} - timeout-minutes: 5 + timeout-minutes: 10 strategy: matrix: @@ -100,7 +100,7 @@ jobs: uses: docker/build-push-action@v6 with: push: true - context: ./.github/docker/${{ matrix.os.config-dir }} + context: . file: ./.github/docker/${{ matrix.os.config-dir }}/Dockerfile tags: symless/synergy-core:${{ matrix.os.name }} build-args: BASE_IMAGE=${{ matrix.os.base-image }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d10eca098..0c66c5a07 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: matrix: target: - name: windows-2022-x64 - runs-on: windows-2022 + runs-on: windows-2022-8-core-x64 steps: - name: Checkout @@ -54,6 +54,12 @@ jobs: with: submodules: "recursive" + - name: Cache Chocolatey packages + uses: actions/cache@v3 + with: + path: ${{ runner.temp }}/choco + key: choco-${{ hashFiles('Chocolatey.config') }} + - name: Install dependencies run: python ./scripts/install_deps.py @@ -61,14 +67,12 @@ jobs: run: python ./scripts/github_env.py --set-qt-version - name: Cache Qt - id: cache-qt uses: actions/cache@v4 with: path: ${{ env.QT_BASE_DIR }} key: ${{ runner.os }}-Qt_${{ env.QT_VERSION }} - name: Install Qt - if: steps.cache-qt.outputs.cache-hit != 'true' run: python ./scripts/install_deps.py --only qt - name: Setup VC++ environment diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 88685748a..92c3490ee 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -17,8 +17,11 @@ concurrency: jobs: analyze: + if: ${{ !github.event.pull_request.draft }} + name: Analyze - runs-on: ubuntu-latest + runs-on: ubuntu-24.04-16-core-x64 + container: symless/synergy-core:ubuntu-24.04-amd64 timeout-minutes: 20 strategy: @@ -27,29 +30,16 @@ jobs: language: ["cpp"] steps: - - name: Install dependencies - run: | - sudo apt-get update; \ - sudo apt-get install -y \ - build-essential \ - cmake \ - debhelper \ - devscripts \ - git \ - libavahi-compat-libdnssd-dev \ - libgdk-pixbuf2.0-dev \ - libgl1-mesa-dev \ - libglib2.0-dev \ - libnotify-dev \ - libssl-dev \ - libx11-dev \ - libxtst-dev \ - qtbase5-dev \ - qttools5-dev \ - qttools5-dev-tools + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: "recursive" - - name: Checkout git repo - uses: actions/checkout@v3 + - name: Config Git safe dir + run: git config --global --add safe.directory $GITHUB_WORKSPACE + + - name: Install dependencies + run: ./scripts/install_deps.py - name: Initialize CodeQL uses: github/codeql-action/init@v3 diff --git a/.github/workflows/lint-source.yml b/.github/workflows/lint-source-code.yml similarity index 97% rename from .github/workflows/lint-source.yml rename to .github/workflows/lint-source-code.yml index 63c353bd0..535a8181e 100644 --- a/.github/workflows/lint-source.yml +++ b/.github/workflows/lint-source-code.yml @@ -12,7 +12,7 @@ on: - ready_for_review jobs: - lint-cmake-files: + lint-source-code: runs-on: ubuntu-latest timeout-minutes: 5 diff --git a/.github/workflows/sonarcloud-analysis.yml b/.github/workflows/sonarcloud-analysis.yml index 17a134b3a..94ef25764 100644 --- a/.github/workflows/sonarcloud-analysis.yml +++ b/.github/workflows/sonarcloud-analysis.yml @@ -18,7 +18,9 @@ concurrency: jobs: sonarcloud-analysis: if: ${{ vars.SONAR_SCANNER_ENABLED }} - runs-on: ubuntu-latest + + runs-on: ubuntu-24.04-16-core-x64 + container: symless/synergy-core:ubuntu-22.04-amd64 timeout-minutes: 20 env: @@ -30,13 +32,16 @@ jobs: - name: Checkout uses: actions/checkout@v4 with: - fetch-depth: 0 + submodules: "recursive" + + - name: Config Git safe dir + run: git config --global --add safe.directory $GITHUB_WORKSPACE - name: Install dependencies - run: ./scripts/install_deps.py - - - name: Install gcovr - run: pip install gcovr + run: | + ./scripts/install_deps.py && + apt install curl unzip -y && + pip install gcovr - name: Install SonarScanner run: | diff --git a/ChangeLog b/ChangeLog index 1377e674d..c0308b168 100644 --- a/ChangeLog +++ b/ChangeLog @@ -50,6 +50,7 @@ Enhancements: - #7380 Add `qt6-qpa-plugins` Qt dependency for Debian - #7381 Set macOS min version to macOS 12.0 - #7382 Re-run `macdeployqt6` to copy missing Qt 6 dependencies +- #7384 Run `install_deps.py` script when building containers weekly # 1.14.6 diff --git a/README.md b/README.md index 48876d158..2567ff846 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![CI](https://github.com/symless/synergy-core/actions/workflows/ci.yml/badge.svg)](https://github.com/symless/synergy-core/actions/workflows/ci.yml) [![CodeQL Analysis](https://github.com/symless/synergy-core/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/symless/synergy-core/actions/workflows/codeql-analysis.yml) [![SonarCloud Analysis](https://github.com/symless/synergy-core/actions/workflows/sonarcloud-analysis.yml/badge.svg)](https://github.com/symless/synergy-core/actions/workflows/sonarcloud-analysis.yml) +[![Build containers](https://github.com/symless/synergy-core/actions/workflows/build-containers.yml/badge.svg)](https://github.com/symless/synergy-core/actions/workflows/build-containers.yml) This is the open source core component of Synergy, a keyboard and mouse sharing tool. diff --git a/config.yaml b/config.yaml index 910319013..98367f5bb 100644 --- a/config.yaml +++ b/config.yaml @@ -66,7 +66,6 @@ config: opensuse-tumbleweed: &opensuse-tumbleweed dependencies: command: sudo zypper refresh; \ - sudo zypper --non-interactive remove busybox-which; \ sudo zypper install -y --force-resolution \ cmake \ make \