Skip to content

Commit c6f63b9

Browse files
authored
Merge pull request jamulussoftware#2284 from hoffie/cache-autobuild-deps
Autobuild: Refactor & use actions/cache
2 parents fa04a8d + 82761fc commit c6f63b9

File tree

5 files changed

+89
-31
lines changed

5 files changed

+89
-31
lines changed

.github/workflows/autobuild.yml

+32
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,38 @@ jobs:
169169
with:
170170
submodules: true
171171

172+
# Enable caching of downloaded dependencies
173+
- name: "Cache Mac dependencies"
174+
if: ${{ matrix.config.target_os == 'macos' }}
175+
uses: actions/cache@v2
176+
with:
177+
path: |
178+
/usr/local/opt/qt
179+
~/Library/Caches/pip
180+
key: ${{ matrix.config.target_os }}-${{ hashFiles('.github/workflows/autobuild.yml', 'autobuild/mac/artifacts/autobuild_mac_1_prepare.sh', 'autobuild/mac/codeQL/autobuild_mac_1_prepare.sh') }}-${{ matrix.config.cmd1_prebuild }}
181+
182+
- name: "Cache Windows dependencies"
183+
if: ${{ matrix.config.target_os == 'windows' }}
184+
uses: actions/cache@v2
185+
with:
186+
path: |
187+
C:\Qt
188+
C:\ChocoCache
189+
~\AppData\Local\pip\Cache
190+
~\windows\NSIS
191+
~\windows\ASIOSDK2
192+
key: ${{ matrix.config.target_os }}-${{ hashFiles('.github/workflows/autobuild.yml', 'autobuild/windows/autobuild_windowsinstaller_1_prepare.ps1', 'windows/deploy_windows.ps1') }}-${{ matrix.config.cmd1_prebuild }}
193+
194+
- name: "Cache Android dependencies"
195+
if: ${{ matrix.config.target_os == 'android' }}
196+
uses: actions/cache@v2
197+
with:
198+
path: |
199+
/opt/Qt
200+
/opt/android/android-sdk
201+
/opt/android/android-ndk
202+
key: ${{ matrix.config.target_os }}-${{ hashFiles('.github/workflows/autobuild.yml', 'autobuild/android/autobuild_apk_1_prepare.sh', 'autobuild/android/install-qt.sh') }}-${{ matrix.config.cmd1_prebuild }}
203+
172204
# Prepare (install QT & dependencies)
173205
- name: "Prepare for ${{ matrix.config.config_name }}"
174206
if: ${{ matrix.config.cmd1_prebuild }}

autobuild/android/autobuild_apk_1_prepare.sh

+15-7
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,26 @@ export ANDROID_NDK_HOST="linux-x86_64"
3434
export ANDROID_SDKMANAGER="${COMMANDLINETOOLS_DIR}/bin/sdkmanager"
3535

3636
# paths for Android SDK
37-
mkdir -p "${COMMANDLINETOOLS_DIR}"
3837
mkdir -p "${ANDROID_SDK_ROOT}"/build-tools/latest/
3938

4039
# Install Android sdk
41-
wget -q -O downloadfile https://dl.google.com/android/repository/commandlinetools-linux-${COMMANDLINETOOLS_VERSION}_latest.zip
42-
unzip -q downloadfile
43-
mv cmdline-tools/* "${COMMANDLINETOOLS_DIR}"
40+
if [[ -d "${COMMANDLINETOOLS_DIR}" ]]; then
41+
echo "Using commandlinetools installation from previous run (actions/cache)"
42+
else
43+
mkdir -p "${COMMANDLINETOOLS_DIR}"
44+
wget -q -O downloadfile https://dl.google.com/android/repository/commandlinetools-linux-${COMMANDLINETOOLS_VERSION}_latest.zip
45+
unzip -q downloadfile
46+
mv cmdline-tools/* "${COMMANDLINETOOLS_DIR}"
47+
fi
4448

4549
# Install Android ndk
46-
wget -q -O downloadfile https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip
47-
unzip -q downloadfile
48-
mv android-ndk-${ANDROID_NDK_VERSION} "${ANDROID_NDK_ROOT}"
50+
if [[ -d "${ANDROID_NDK_ROOT}" ]]; then
51+
echo "Using NDK installation from previous run (actions/cache)"
52+
else
53+
wget -q -O downloadfile https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip
54+
unzip -q downloadfile
55+
mv android-ndk-${ANDROID_NDK_VERSION} "${ANDROID_NDK_ROOT}"
56+
fi
4957

5058
# Install Android SDK
5159
yes | "${ANDROID_SDKMANAGER}" --licenses

autobuild/mac/artifacts/autobuild_mac_1_prepare.sh

+7-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ AQTINSTALL_VERSION=2.0.5
1515
### PROCEDURE ###
1616
###################
1717

18-
echo "Install dependencies..."
19-
python3 -m pip install "aqtinstall==${AQTINSTALL_VERSION}"
20-
python3 -m aqt install-qt --outputdir "${QT_DIR}" mac desktop ${QT_VER}
18+
if [[ -d "${QT_DIR}" ]]; then
19+
echo "Using Qt installation from previous run (actions/cache)"
20+
else
21+
echo "Install dependencies..."
22+
python3 -m pip install "aqtinstall==${AQTINSTALL_VERSION}"
23+
python3 -m aqt install-qt --outputdir "${QT_DIR}" mac desktop ${QT_VER}
24+
fi
2125

2226
# Add the qt binaries to the PATH.
2327
# The clang_64 entry can be dropped when Qt <6.2 compatibility is no longer needed.

autobuild/mac/codeQL/autobuild_mac_1_prepare.sh

+7-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ AQTINSTALL_VERSION=2.0.5
1515
### PROCEDURE ###
1616
###################
1717

18-
echo "Install dependencies..."
19-
python3 -m pip install "aqtinstall==${AQTINSTALL_VERSION}"
20-
python3 -m aqt install-qt --outputdir "${QT_DIR}" mac desktop ${QT_VER}
18+
if [[ -d "${QT_DIR}" ]]; then
19+
echo "Using Qt installation from previous run (actions/cache)"
20+
else
21+
echo "Install dependencies..."
22+
python3 -m pip install "aqtinstall==${AQTINSTALL_VERSION}"
23+
python3 -m aqt install-qt --outputdir "${QT_DIR}" mac desktop ${QT_VER}
24+
fi
2125

2226
# Add the qt binaries to the PATH.
2327
# The clang_64 entry can be dropped when Qt <6.2 compatibility is no longer needed.

autobuild/windows/autobuild_windowsinstaller_1_prepare.ps1

+28-18
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,42 @@ $ErrorActionPreference = "Stop"
2020
###################
2121

2222
$QtDir = 'C:\Qt'
23+
$ChocoCacheDir = 'C:\ChocoCache'
2324
$Qt32Version = "5.15.2"
2425
$Qt64Version = "5.15.2"
2526
$AqtinstallVersion = "2.0.5"
2627
$JackVersion = "1.9.17"
2728
$MsvcVersion = "2019"
2829

29-
echo "Install Qt..."
30-
# Install Qt
31-
pip install "aqtinstall==$AqtinstallVersion"
32-
if ( !$? )
30+
if ( Test-Path -Path $QtDir )
3331
{
34-
throw "pip install aqtinstall failed with exit code $LastExitCode"
32+
echo "Using Qt installation from previous run (actions/cache)"
3533
}
36-
37-
echo "Get Qt 64 bit..."
38-
# intermediate solution if the main server is down: append e.g. " -b https://mirrors.ocf.berkeley.edu/qt/" to the "aqt"-line below
39-
aqt install-qt --outputdir "${QtDir}" windows desktop "${Qt64Version}" "win64_msvc${MsvcVersion}_64"
40-
if ( !$? )
34+
else
4135
{
42-
throw "64bit Qt installation failed with exit code $LastExitCode"
43-
}
36+
echo "Install Qt..."
37+
# Install Qt
38+
pip install "aqtinstall==$AqtinstallVersion"
39+
if ( !$? )
40+
{
41+
throw "pip install aqtinstall failed with exit code $LastExitCode"
42+
}
4443

45-
echo "Get Qt 32 bit..."
46-
# intermediate solution if the main server is down: append e.g. " -b https://mirrors.ocf.berkeley.edu/qt/" to the "aqt"-line below
47-
aqt install-qt --outputdir "${QtDir}" windows desktop "${Qt32Version}" "win32_msvc${MsvcVersion}"
48-
if ( !$? )
49-
{
50-
throw "32bit Qt installation failed with exit code $LastExitCode"
44+
echo "Get Qt 64 bit..."
45+
# intermediate solution if the main server is down: append e.g. " -b https://mirrors.ocf.berkeley.edu/qt/" to the "aqt"-line below
46+
aqt install-qt --outputdir "${QtDir}" windows desktop "${Qt64Version}" "win64_msvc${MsvcVersion}_64"
47+
if ( !$? )
48+
{
49+
throw "64bit Qt installation failed with exit code $LastExitCode"
50+
}
51+
52+
echo "Get Qt 32 bit..."
53+
# intermediate solution if the main server is down: append e.g. " -b https://mirrors.ocf.berkeley.edu/qt/" to the "aqt"-line below
54+
aqt install-qt --outputdir "${QtDir}" windows desktop "${Qt32Version}" "win32_msvc${MsvcVersion}"
55+
if ( !$? )
56+
{
57+
throw "32bit Qt installation failed with exit code $LastExitCode"
58+
}
5159
}
5260

5361

@@ -57,6 +65,8 @@ if ( !$? )
5765

5866
if ($BuildOption -Eq "jackonwindows")
5967
{
68+
choco config set cacheLocation $ChocoCacheDir
69+
6070
echo "Install JACK2 64-bit..."
6171
# Install JACK2 64-bit
6272
choco install --no-progress -y jack --version "${JackVersion}"

0 commit comments

Comments
 (0)