Skip to content

Commit

Permalink
CI: Improve Caching
Browse files Browse the repository at this point in the history
  • Loading branch information
HTRamsey committed Jan 21, 2025
1 parent dd73a6b commit 003b06e
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 127 deletions.
81 changes: 81 additions & 0 deletions .github/actions/cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Caching
description: Setup Caching
inputs:
host:
description: Host OS
required: true
target:
description: Target OS
required: true
build-type:
description: Build Type
required: true
cpm-modules:
description: Path to CPM Modules
required: false
default: ${{ github.workspace }}/cpm-modules
ccache-version:
description: ccache Version to Install
required: false
default: 4.10.2
# windows-x86_64.zip, darwin.tar.gz, linux-x86_64.tar.xz
# https://github.com/ccache/ccache/releases/download/${version}/ccache-${version}-${host}.${zip}

runs:
using: "composite"
steps:
- name: Install ccache (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
set -e
echo "Downloading ccache..."
wget --quiet https://github.com/ccache/ccache/releases/download/v${{ inputs.ccache-version }}/ccache-${{ inputs.ccache-version }}-linux-x86_64.tar.xz
echo "Extracting archive..."
tar -xvf ccache-${{ inputs.ccache-version }}-linux-x86_64.tar.xz
cd ccache-${{ inputs.ccache-version }}-linux-x86_64
echo "Installing ccache..."
sudo make install
- name: Setup sccache (Windows)
if: runner.os == 'Windows'
uses: mozilla-actions/[email protected]

- run: echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
if: runner.os == 'Windows'
shell: bash

- name: Setup Build Cache
uses: hendrikmuhs/ccache-action@main
with:
create-symlink: ${{ runner.os != 'Windows' }}
variant: ${{ runner.os == 'Windows' && 'sccache' || 'ccache' }}
key: ${{ inputs.host }}-ccache-${{ inputs.target }}-${{ inputs.build-type }}
restore-keys: |
${{ inputs.host }}-ccache-${{ inputs.target }}
${{ inputs.host }}-ccache-
max-size: 1G
save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
verbose: 1
evict-old-files: job

# Ensure the CPM Modules directory exists (Linux/macOS)
- name: Ensure cpm-modules directory exists (Linux/macOS)
if: runner.os != 'Windows'
run: mkdir -p "${{ inputs.cpm-modules }}"
shell: bash

# Ensure the CPM Modules directory exists (Windows)
- name: Ensure cpm-modules directory exists (Windows)
if: runner.os == 'Windows'
run: New-Item -ItemType Directory -Force -Path "${{ inputs.cpm-modules }}"
shell: pwsh

- name: Cache CPM Modules
if: inputs.cpm-modules != ''
uses: actions/cache@v4
with:
path: ${{ inputs.cpm-modules }}
key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
restore-keys: ${{ github.workflow }}-cpm-modules-
enableCrossOsArchive: true
11 changes: 0 additions & 11 deletions .github/actions/checkout/action.yml

This file was deleted.

18 changes: 5 additions & 13 deletions .github/actions/qt-android/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,12 @@ runs:
run: sdkmanager --update
shell: bash

- name: Set Up Cache
uses: hendrikmuhs/ccache-action@main
- name: Setup Caching
uses: ./.github/actions/cache
with:
create-symlink: ${{ runner.os != 'Windows' }}
key: ${{ runner.os }}-Android-${{ matrix.BuildType }}
max-size: 1G
save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
verbose: 1
evict-old-files: 'job'

- uses: actions/cache@v4
with:
path: ${{ inputs.cpm-cache }}
key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
host: ${{ inputs.host }}
target: ${{ inputs.arch }}
build-type: ${{ matrix.BuildType }}

- name: Install Qt for ${{ runner.os }}
uses: jurplel/install-qt-action@v4
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/android-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@ jobs:
- uses: seanmiddleditch/gha-setup-ninja@v5
- uses: lukka/get-cmake@latest

- name: Install CCache
run: |
wget --quiet https://github.com/ccache/ccache/releases/download/v4.10.2/ccache-4.10.2-linux-x86_64.tar.xz
tar -xvf ccache-*-linux-x86_64.tar.xz
cd ccache-*-linux-x86_64
sudo make install
- name: Install Qt for Android
uses: ./.github/actions/qt-android
with:
Expand All @@ -82,7 +75,6 @@ jobs:
-DQT_ANDROID_SIGN_APK=${{ github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && 'ON' || 'OFF' }}
-DQT_DEBUG_FIND_PACKAGE=ON
-DQGC_STABLE_BUILD=${{ github.ref_type == 'tag' || contains(github.ref, 'Stable') && 'ON' || 'OFF' }}
-DCPM_SOURCE_CACHE=${{ env.CPM_SOURCE_CACHE }}

- name: Build
working-directory: ${{ runner.temp }}/shadow_build_dir
Expand Down
7 changes: 0 additions & 7 deletions .github/workflows/android-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ jobs:
- uses: seanmiddleditch/gha-setup-ninja@v5
- uses: lukka/get-cmake@latest

- name: Install Dependencies
run: |
brew update
brew install ccache
continue-on-error: true

- name: Install Qt for Android
uses: ./.github/actions/qt-android
with:
Expand All @@ -68,7 +62,6 @@ jobs:
-DQT_ANDROID_SIGN_APK=${{ github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && 'ON' || 'OFF' }}
-DQT_DEBUG_FIND_PACKAGE=ON
-DQGC_STABLE_BUILD=${{ github.ref_type == 'tag' || contains(github.ref, 'Stable') && 'ON' || 'OFF' }}
-DCPM_SOURCE_CACHE=${{ env.CPM_SOURCE_CACHE }}

- name: Build
working-directory: ${{ runner.temp }}/shadow_build_dir
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/android-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ jobs:
- uses: seanmiddleditch/gha-setup-ninja@v5
- uses: lukka/get-cmake@latest

- name: Update ccache
run: choco install ccache

- name: Install Qt for Android
uses: ./.github/actions/qt-android
with:
Expand All @@ -83,7 +80,6 @@ jobs:
-DQT_ANDROID_SIGN_APK=OFF
-DQT_DEBUG_FIND_PACKAGE=ON
-DQGC_STABLE_BUILD=${{ github.ref_type == 'tag' || contains(github.ref, 'Stable') && 'ON' || 'OFF' }}
-DCPM_SOURCE_CACHE=${{ env.CPM_SOURCE_CACHE }}

- name: Build
working-directory: ${{ runner.temp }}/shadow_build_dir
Expand Down
18 changes: 7 additions & 11 deletions .github/workflows/custom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ jobs:
ARTIFACT: QGroundControl-installer.exe
QT_VERSION: 6.8.1
GST_VERSION: 1.22.12
SCCACHE_GHA_ENABLED: "true"
CPM_SOURCE_CACHE: ${{ github.workspace }}/cpm_modules
cpm-cache: ${{ env.CPM_SOURCE_CACHE }}

steps:
- name: Checkout repo
Expand All @@ -61,17 +62,12 @@ jobs:
with:
version: ${{ env.GST_VERSION }}

- name: Set Up SCCache
uses: mozilla-actions/[email protected]

- name: Set Up Cache
uses: hendrikmuhs/ccache-action@main
- name: Setup Caching
uses: ./.github/actions/cache
with:
key: ${{ runner.os }}-${{ matrix.Arch }}-${{ matrix.BuildType }}-custom
max-size: 1G
variant: sccache
save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
verbose: 1
host: windows
target: win64_msvc2022_64
build-type: ${{ matrix.BuildType }}

- name: Install Qt for Windows (x64)
if: matrix.Arch == 'x64'
Expand Down
25 changes: 6 additions & 19 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,13 @@ jobs:
- uses: seanmiddleditch/gha-setup-ninja@v5
- uses: lukka/get-cmake@latest

- name: Install Dependencies
run: |
brew update
brew install ccache
- name: Set Up Cache
uses: hendrikmuhs/ccache-action@main
with:
create-symlink: true
key: ${{ runner.os }}-iOS-${{ matrix.BuildType }}
max-size: 1G
save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
verbose: 1
evict-old-files: 'job'

- uses: actions/cache@v4
- name: Setup Caching
uses: ./.github/actions/cache
with:
path: ${{ env.CPM_SOURCE_CACHE }}
key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
host: mac
target: ios
build-type: ${{ matrix.BuildType }}
cpm-cache: ${{ env.CPM_SOURCE_CACHE }}

- name: Install Qt for MacOS
uses: jurplel/install-qt-action@v4
Expand Down Expand Up @@ -92,7 +80,6 @@ jobs:
-DCMAKE_BUILD_TYPE=${{ matrix.BuildType }}
-DQT_HOST_PATH="${{ env.QT_ROOT_DIR }}/../macos"
-DQGC_STABLE_BUILD=${{ github.ref_type == 'tag' || contains(github.ref, 'Stable') && 'ON' || 'OFF' }}
-DCPM_SOURCE_CACHE=${{ env.CPM_SOURCE_CACHE }}

- name: Build
working-directory: ${{ runner.temp }}/shadow_build_dir
Expand Down
27 changes: 6 additions & 21 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,13 @@ jobs:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11
sudo update-alternatives --set gcc /usr/bin/gcc-11
- name: Install CCache
run: |
wget --quiet https://github.com/ccache/ccache/releases/download/v4.10.2/ccache-4.10.2-linux-x86_64.tar.xz
tar -xvf ccache-*-linux-x86_64.tar.xz
cd ccache-*-linux-x86_64
sudo make install
- name: Set Up Cache
uses: hendrikmuhs/ccache-action@main
- name: Setup Caching
uses: ./.github/actions/cache
with:
create-symlink: true
key: ${{ runner.os }}-${{ matrix.BuildType }}
max-size: 1G
save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
verbose: 1
evict-old-files: 'job'

- uses: actions/cache@v4
with:
path: ${{ env.CPM_SOURCE_CACHE }}
key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
host: linux
target: linux_gcc_64
build-type: ${{ matrix.BuildType }}
cpm-cache: ${{ env.CPM_SOURCE_CACHE }}

- name: Install Qt for Linux (x64)
uses: jurplel/install-qt-action@v4
Expand All @@ -112,7 +98,6 @@ jobs:
-DCMAKE_BUILD_TYPE=${{ matrix.BuildType }}
-DQGC_BUILD_TESTING=${{ matrix.BuildType == 'Debug' && 'ON' || 'OFF' }}
-DQGC_STABLE_BUILD=${{ github.ref_type == 'tag' || contains(github.ref, 'Stable') && 'ON' || 'OFF' }}
-DCPM_SOURCE_CACHE=${{ env.CPM_SOURCE_CACHE }}

- name: Build
working-directory: ${{ runner.temp }}/shadow_build_dir
Expand Down
24 changes: 7 additions & 17 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,12 @@ jobs:
with:
xcode-version: latest-stable

- uses: seanmiddleditch/gha-setup-ninja@v5

- name: Install Dependencies
working-directory: ${{ github.workspace }}/tools/setup
run: sh macos-dependencies.sh

- uses: lukka/get-cmake@latest
- uses: seanmiddleditch/gha-setup-ninja@v5
- uses: lukka/get-cmake@latest

- name: Install GStreamer
run: |
Expand All @@ -68,20 +66,13 @@ jobs:
done
echo "PKG_CONFIG_PATH=/Library/Frameworks/GStreamer.framework/lib/pkgconfig:/Library/Frameworks/GStreamer.framework/lib/gstreamer-1.0/pkgconfig:${{ env.PKG_CONFIG_PATH }}" >> "$GITHUB_ENV"
- name: Set Up Cache
uses: hendrikmuhs/ccache-action@main
with:
create-symlink: true
key: ${{ runner.os }}-${{ matrix.BuildType }}
max-size: 1G
save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
verbose: 1
evict-old-files: 'job'

- uses: actions/cache@v4
- name: Setup Caching
uses: ./.github/actions/cache
with:
path: ${{ env.CPM_SOURCE_CACHE }}
key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
host: mac
target: clang_64
build-type: ${{ matrix.BuildType }}
cpm-cache: ${{ env.CPM_SOURCE_CACHE }}

- name: Install Qt
uses: jurplel/install-qt-action@v4
Expand Down Expand Up @@ -110,7 +101,6 @@ jobs:
-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
-DMACOS_SIGNING_IDENTITY=${{ secrets.MACOS_SIGNING_IDENTITY }}
-DQGC_STABLE_BUILD=${{ github.ref_type == 'tag' || contains(github.ref, 'Stable') && 'ON' || 'OFF' }}
-DCPM_SOURCE_CACHE=${{ env.CPM_SOURCE_CACHE }}

- name: Build
working-directory: ${{ runner.temp }}/shadow_build_dir
Expand Down
22 changes: 6 additions & 16 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ jobs:
PACKAGE: QGroundControl-installer
QT_VERSION: 6.8.1
GST_VERSION: 1.22.12
SCCACHE_GHA_ENABLED: "true"
CPM_SOURCE_CACHE: ${{ github.workspace }}/cpm_modules

steps:
Expand All @@ -63,21 +62,13 @@ jobs:
with:
version: ${{ env.GST_VERSION }}

- name: Set Up sccache
uses: mozilla-actions/[email protected]

- name: Set Up Cache
uses: hendrikmuhs/ccache-action@main
with:
key: ${{ runner.os }}-${{ matrix.Arch }}-${{ matrix.BuildType }}
max-size: 1G
variant: sccache
save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}

- uses: actions/cache@v4
- name: Setup Caching
uses: ./.github/actions/cache
with:
path: ${{ env.CPM_SOURCE_CACHE }}
key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
host: windows
target: win64_msvc2022_64
build-type: ${{ matrix.BuildType }}
cpm-cache: ${{ env.CPM_SOURCE_CACHE }}

- name: Install Qt for Windows (x64)
uses: jurplel/install-qt-action@v4
Expand Down Expand Up @@ -119,7 +110,6 @@ jobs:
-DQT_HOST_PATH="${{ env.QT_ROOT_DIR }}/../msvc2022_64"
-DQT_DEBUG_FIND_PACKAGE=ON
-DQGC_STABLE_BUILD=${{ github.ref_type == 'tag' || contains(github.ref, 'Stable') && 'ON' || 'OFF' }}
-DCPM_SOURCE_CACHE=${{ env.CPM_SOURCE_CACHE }}

- name: Build
working-directory: ${{ runner.temp }}\shadow_build_dir
Expand Down
1 change: 1 addition & 0 deletions tools/setup/install-dependencies-debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ DEBIAN_FRONTEND=noninteractive apt-get -y --quiet install \
python3 \
python3-pip \
rsync \
wget2 \
zsync

# Qt Required - https://doc.qt.io/qt-6/linux-requirements.html
Expand Down

0 comments on commit 003b06e

Please sign in to comment.