Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Improve Caching #12360

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/actions/cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
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
verbose: 1
evict-old-files: job

- name: Ensure cpm-modules directory exists (Linux/macOS)
run: mkdir -p "${{ inputs.cpm-modules }}"
shell: bash

- 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.

12 changes: 12 additions & 0 deletions .github/actions/common/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Common Setup
description: Common Setup for All Runners
runs:
using: "composite"
steps:
- uses: lukka/get-cmake@latest
- uses: actions/setup-python@v5
with:
python-version: '>=3.9.x'

- run: mkdir $RUNNER_TEMP/shadow_build_dir
shell: bash
35 changes: 16 additions & 19 deletions .github/actions/qt-android/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ inputs:
cpm-cache:
description: CPM Cache Path
required: false
default: ${{ github.workspace }}/cpm_modules
default: $GITHUB_WORKSPACE/cpm_modules
runs:
using: "composite"
steps:
Expand All @@ -27,6 +27,10 @@ runs:
with:
distribution: temurin
java-version: 17
cache: 'gradle'
cache-dependency-path: |
**/*.gradle*
**/gradle-wrapper.properties

- name: Setup Android Environment
uses: android-actions/setup-android@v3
Expand All @@ -53,20 +57,13 @@ 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 }}
cpm-modules: ${{ inputs.cpm-cache }}

- name: Install Qt for ${{ runner.os }}
uses: jurplel/install-qt-action@v4
Expand All @@ -77,7 +74,7 @@ runs:
arch: ${{ inputs.arch }}
dir: ${{ runner.temp }}
modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors
cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
setup-python: false

- name: Install Qt for Android (armv7)
if: contains( inputs.abis, 'armeabi-v7a')
Expand All @@ -89,7 +86,7 @@ runs:
arch: android_armv7
dir: ${{ runner.temp }}
modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors
cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
setup-python: false

- name: Install Qt for Android (arm64_v8a)
if: contains( inputs.abis, 'arm64-v8a')
Expand All @@ -101,7 +98,7 @@ runs:
arch: android_arm64_v8a
dir: ${{ runner.temp }}
modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors
cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
setup-python: false

- name: Install Qt for Android (x86)
if: contains( inputs.abis, 'x86')
Expand All @@ -113,7 +110,7 @@ runs:
arch: android_x86
dir: ${{ runner.temp }}
modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors
cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
setup-python: false

- name: Install Qt for Android (x86_64)
if: contains( inputs.abis, 'x86_64')
Expand All @@ -125,4 +122,4 @@ runs:
arch: android_x86_64
dir: ${{ runner.temp }}
modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors
cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
setup-python: false
15 changes: 2 additions & 13 deletions .github/workflows/android-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,9 @@ jobs:
with:
submodules: recursive
fetch-tags: true
fetch-depth: 0

- 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: Initial Setup
uses: ./.github/actions/common

- name: Install Qt for Android
uses: ./.github/actions/qt-android
Expand All @@ -70,8 +62,6 @@ jobs:
abis: ${{ env.QT_ANDROID_ABIS }}
cpm-cache: ${{ env.CPM_SOURCE_CACHE }}

- run: mkdir ${{ runner.temp }}/shadow_build_dir

- name: Configure
working-directory: ${{ runner.temp }}/shadow_build_dir
run: ${{ env.QT_ROOT_DIR }}/bin/qt-cmake -S ${{ github.workspace }} -B . -G Ninja
Expand All @@ -82,7 +72,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
14 changes: 2 additions & 12 deletions .github/workflows/android-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,9 @@ jobs:
with:
submodules: recursive
fetch-tags: true
fetch-depth: 0

- 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: Initial Setup
uses: ./.github/actions/common

- name: Install Qt for Android
uses: ./.github/actions/qt-android
Expand All @@ -56,8 +49,6 @@ jobs:
abis: ${{ env.QT_ANDROID_ABIS }}
cpm-cache: ${{ env.CPM_SOURCE_CACHE }}

- run: mkdir ${{ runner.temp }}/shadow_build_dir

- name: Configure
working-directory: ${{ runner.temp }}/shadow_build_dir
run: ${{ env.QT_ROOT_DIR }}/bin/qt-cmake -S ${{ github.workspace }} -B . -G Ninja
Expand All @@ -68,7 +59,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
13 changes: 3 additions & 10 deletions .github/workflows/android-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,17 @@ jobs:
QT_ANDROID_KEYSTORE_STORE_PASS: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
QT_ANDROID_KEYSTORE_KEY_PASS: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
QT_ANDROID_ABIS: 'arm64-v8a'
CPM_SOURCE_CACHE: ${{ github.workspace }}/cpm_modules
CPM_SOURCE_CACHE: ${{ github.workspace }}\cpm_modules

steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
submodules: recursive
fetch-tags: true
fetch-depth: 0

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

- name: Update ccache
run: choco install ccache
- name: Initial Setup
uses: ./.github/actions/common

- name: Install Qt for Android
uses: ./.github/actions/qt-android
Expand All @@ -71,8 +67,6 @@ jobs:
with:
arch: x64

- run: mkdir ${{ runner.temp }}\shadow_build_dir

- name: Configure
working-directory: ${{ runner.temp }}/shadow_build_dir
run: ${{ env.QT_ROOT_DIR }}/bin/qt-cmake -S ${{ github.workspace }} -B . -G Ninja
Expand All @@ -83,7 +77,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
28 changes: 10 additions & 18 deletions .github/workflows/custom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ 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

steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
submodules: recursive
fetch-tags: true
fetch-depth: 0

- name: Initial Setup
uses: ./.github/actions/common

- name: Enable custom build
run: |
Expand All @@ -53,25 +55,18 @@ jobs:
)
xcopy /E /I ".\custom-example" ".\custom"

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

- name: Install GStreamer
uses: blinemedical/setup-gstreamer@v1
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 }}
cpm-modules: ${{ env.CPM_SOURCE_CACHE }}

- name: Install Qt for Windows (x64)
if: matrix.Arch == 'x64'
Expand All @@ -84,15 +79,12 @@ jobs:
arch: win64_msvc2022_64
dir: ${{ runner.temp }}
modules: qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors
cache: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}

- name: Set up Visual Studio shell
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64

- run: mkdir ${{ runner.temp }}\shadow_build_dir

- name: Configure
working-directory: ${{ runner.temp }}\shadow_build_dir
run: ${{ env.QT_ROOT_DIR }}/bin/qt-cmake -S ${{ github.workspace }} -B . -G Ninja
Expand Down
Loading
Loading