Rework CI build caching for stability (#5170)

* improve github build caching

* add back network build flag

* add back sdlnet
This commit is contained in:
Archez 2025-03-21 07:23:01 -04:00 committed by GitHub
parent e21a3e4c0f
commit 1bcab06fed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 130 additions and 100 deletions

View file

@ -6,42 +6,44 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true cancel-in-progress: true
jobs: jobs:
generate-soh-otr: generate-soh-otr:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
- uses: actions/checkout@v4 - name: Git Checkout
uses: actions/checkout@v4
with: with:
submodules: true submodules: true
- name: ccache - name: Configure ccache
uses: hendrikmuhs/ccache-action@v1.2.14 uses: hendrikmuhs/ccache-action@v1.2
with: with:
save: ${{ github.ref_name == github.event.repository.default_branch }}
key: ${{ runner.os }}-otr-ccache-${{ github.ref }}-${{ github.sha }} key: ${{ runner.os }}-otr-ccache-${{ github.ref }}-${{ github.sha }}
restore-keys: | restore-keys: |
${{ runner.os }}-otr-ccache-${{ github.ref }} ${{ runner.os }}-otr-ccache-${{ github.ref }}
${{ runner.os }}-otr-ccache- ${{ runner.os }}-otr-ccache
- name: Install dependencies - name: Install dependencies
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install -y $(cat .github/workflows/apt-deps.txt) libzip-dev zipcmp zipmerge ziptool sudo apt-get install -y $(cat .github/workflows/apt-deps.txt) libzip-dev zipcmp zipmerge ziptool
- name: Cache build folders - name: Restore Cached deps folder
uses: actions/cache@v4 uses: actions/cache/restore@v4
with: with:
key: ${{ runner.os }}-otr-build-${{ github.ref }}-${{ github.sha }} key: ${{ runner.os }}-deps-${{ github.ref }}-${{ github.sha }}
restore-keys: | restore-keys: |
${{ runner.os }}-otr-build-${{ github.ref }} ${{ runner.os }}-deps-${{ github.ref }}-
${{ runner.os }}-otr-build- ${{ runner.os }}-deps-
path: | path: deps
build-cmake - name: Create deps folder
SDL2-2.30.3 run: mkdir -p deps
tinyxml2-10.0.0
- name: Install latest SDL - name: Install latest SDL
run: | run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
if [ ! -d "SDL2-2.30.3" ]; then if [ ! -d "deps/SDL2-2.30.3" ]; then
wget https://www.libsdl.org/release/SDL2-2.30.3.tar.gz wget https://github.com/libsdl-org/SDL/releases/download/release-2.30.3/SDL2-2.30.3.tar.gz
tar -xzf SDL2-2.30.3.tar.gz tar -xzf SDL2-2.30.3.tar.gz -C deps
fi fi
cd SDL2-2.30.3 cd deps/SDL2-2.30.3
./configure --enable-hidapi-libusb ./configure --enable-hidapi-libusb
make -j 10 make -j 10
sudo make install sudo make install
@ -50,11 +52,11 @@ jobs:
run: | run: |
sudo apt-get remove libtinyxml2-dev sudo apt-get remove libtinyxml2-dev
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
if [ ! -d "tinyxml2-10.0.0" ]; then if [ ! -d "deps/tinyxml2-10.0.0" ]; then
wget https://github.com/leethomason/tinyxml2/archive/refs/tags/10.0.0.tar.gz wget https://github.com/leethomason/tinyxml2/archive/refs/tags/10.0.0.tar.gz
tar -xzf 10.0.0.tar.gz tar -xzf 10.0.0.tar.gz -C deps
fi fi
cd tinyxml2-10.0.0 cd deps/tinyxml2-10.0.0
mkdir -p build mkdir -p build
cd build cd build
cmake .. cmake ..
@ -64,49 +66,57 @@ jobs:
run: | run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
cmake --no-warn-unused-cli -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Release cmake --no-warn-unused-cli -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Release
cmake --build build-cmake --config Release --target GenerateSohOtr cmake --build build-cmake --config Release --target GenerateSohOtr -j3
- uses: actions/upload-artifact@v4 - name: Upload soh.otr
uses: actions/upload-artifact@v4
with: with:
name: soh.otr name: soh.otr
path: soh.otr path: soh.otr
retention-days: 1 retention-days: 3
build-macos: build-macos:
needs: generate-soh-otr needs: generate-soh-otr
runs-on: macos-14 runs-on: macos-14
steps: steps:
- uses: actions/checkout@v4 - name: Git Checkout
uses: actions/checkout@v4
with: with:
submodules: true submodules: true
- name: ccache - name: Configure ccache
uses: hendrikmuhs/ccache-action@v1.2.14 uses: hendrikmuhs/ccache-action@v1.2
with: with:
create-symlink: true create-symlink: true
save: ${{ github.ref_name == github.event.repository.default_branch }}
key: ${{ runner.os }}-14-ccache-${{ github.ref }}-${{ github.sha }} key: ${{ runner.os }}-14-ccache-${{ github.ref }}-${{ github.sha }}
restore-keys: | restore-keys: |
${{ runner.os }}-14-ccache-${{ github.ref }} ${{ runner.os }}-14-ccache-${{ github.ref }}
${{ runner.os }}-14-ccache- ${{ runner.os }}-14-ccache
# Needed to apply sudo for macports cache restore
- name: Install gtar wrapper - name: Install gtar wrapper
run: | run: |
sudo mv /opt/homebrew/bin/gtar /opt/homebrew/bin/gtar.orig sudo mv /opt/homebrew/bin/gtar /opt/homebrew/bin/gtar.orig
sudo cp .github/workflows//gtar /opt/homebrew/bin/gtar sudo cp .github/workflows/gtar /opt/homebrew/bin/gtar
sudo chmod +x /opt/homebrew/bin/gtar sudo chmod +x /opt/homebrew/bin/gtar
- name: Cache MacPorts - name: Restore Cached MacPorts
id: cache-macports id: restore-cache-macports
uses: actions/cache@v4 uses: actions/cache/restore@v4
with: with:
path: /opt/local/ key: ${{ runner.os }}-14-macports-${{ hashFiles('.github/workflows/macports-deps.txt') }}-${{ github.sha }}
key: ${{ runner.os }}-14-macports-${{ hashFiles('.github/workflows/macports-deps.txt') }}
restore-keys: | restore-keys: |
${{ runner.os }}-14-macports-${{ hashFiles('.github/workflows/macports-deps.txt') }}-
${{ runner.os }}-14-macports- ${{ runner.os }}-14-macports-
path: /opt/local/
# Updated PATH applies to the next step and onwards
- name: Install MacPorts (if necessary) - name: Install MacPorts (if necessary)
run: | run: |
if [ -d /opt/local/ ]; then if command -v /opt/local/bin/port 2>&1 >/dev/null; then
echo "MacPorts already installed" echo "MacPorts already installed"
else else
echo "Installing MacPorts"
wget https://github.com/macports/macports-base/releases/download/v2.9.3/MacPorts-2.9.3-14-Sonoma.pkg wget https://github.com/macports/macports-base/releases/download/v2.9.3/MacPorts-2.9.3-14-Sonoma.pkg
sudo installer -pkg ./MacPorts-2.9.3-14-Sonoma.pkg -target / sudo installer -pkg ./MacPorts-2.9.3-14-Sonoma.pkg -target /
fi fi
echo "/opt/local/bin:/opt/local/sbin" >> $GITHUB_PATH echo "/opt/local/bin:/opt/local/sbin" >> "$GITHUB_PATH"
- name: Install dependencies - name: Install dependencies
run: | run: |
brew uninstall --ignore-dependencies libpng brew uninstall --ignore-dependencies libpng
@ -116,11 +126,12 @@ jobs:
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
name: soh.otr name: soh.otr
path: build-cmake/soh
- name: Build SoH - name: Build SoH
run: | run: |
export PATH="/usr/lib/ccache:/opt/homebrew/opt/ccache/libexec:/usr/local/opt/ccache/libexec:$PATH"
cmake --no-warn-unused-cli -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DBUILD_REMOTE_CONTROL=1 cmake --no-warn-unused-cli -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DBUILD_REMOTE_CONTROL=1
cmake --build build-cmake --config Release --parallel 10 cmake --build build-cmake --config Release --parallel 10
mv soh.otr build-cmake/soh
(cd build-cmake && cpack) (cd build-cmake && cpack)
mv _packages/*.dmg SoH.dmg mv _packages/*.dmg SoH.dmg
@ -132,44 +143,52 @@ jobs:
path: | path: |
SoH.dmg SoH.dmg
readme.txt readme.txt
- name: Save Cache MacPorts
if: ${{ github.ref_name == github.event.repository.default_branch }}
uses: actions/cache/save@v4
with:
key: ${{ steps.restore-cache-macports.outputs.cache-primary-key }}
path: /opt/local/
build-linux: build-linux:
needs: generate-soh-otr needs: generate-soh-otr
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
- uses: actions/checkout@v4 - name: Git Checkout
uses: actions/checkout@v4
with: with:
submodules: true submodules: true
- name: Install dependencies - name: Install dependencies
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install -y $(cat .github/workflows/apt-deps.txt) sudo apt-get install -y $(cat .github/workflows/apt-deps.txt)
- name: ccache - name: Configure ccache
uses: hendrikmuhs/ccache-action@v1.2.14 uses: hendrikmuhs/ccache-action@v1.2
with: with:
key: linux-ccache-${{ github.ref }}-${{ github.sha }} save: ${{ github.ref_name == github.event.repository.default_branch }}
key: ${{ runner.os }}-ccache-${{ github.ref }}-${{ github.sha }}
restore-keys: | restore-keys: |
linux-ccache-${{ github.ref }} ${{ runner.os }}-ccache-${{ github.ref }}
linux-ccache- ${{ runner.os }}-ccache
- name: Cache build folders - name: Restore Cached deps folder
uses: actions/cache@v4 id: restore-cache-deps
uses: actions/cache/restore@v4
with: with:
key: linux-build-${{ github.ref }}-${{ github.sha }} key: ${{ runner.os }}-deps-${{ github.ref }}-${{ github.sha }}
restore-keys: | restore-keys: |
linux-build-${{ github.ref }} ${{ runner.os }}-deps-${{ github.ref }}-
linux-build- ${{ runner.os }}-deps-
path: | path: deps
SDL2-2.30.3 - name: Create deps folder
SDL2_net-2.2.0 run: mkdir -p deps
tinyxml2-10.0.0
libzip-1.10.1
- name: Install latest SDL - name: Install latest SDL
run: | run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
if [ ! -d "SDL2-2.30.3" ]; then if [ ! -d "deps/SDL2-2.30.3" ]; then
wget https://www.libsdl.org/release/SDL2-2.30.3.tar.gz wget https://github.com/libsdl-org/SDL/releases/download/release-2.30.3/SDL2-2.30.3.tar.gz
tar -xzf SDL2-2.30.3.tar.gz tar -xzf SDL2-2.30.3.tar.gz -C deps
fi fi
cd SDL2-2.30.3 cd deps/SDL2-2.30.3
./configure --enable-hidapi-libusb ./configure --enable-hidapi-libusb
make -j 10 make -j 10
sudo make install sudo make install
@ -177,11 +196,11 @@ jobs:
- name: Install latest SDL_net - name: Install latest SDL_net
run: | run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
if [ ! -d "SDL2_net-2.2.0" ]; then if [ ! -d "deps/SDL2_net-2.2.0" ]; then
wget https://www.libsdl.org/projects/SDL_net/release/SDL2_net-2.2.0.tar.gz wget https://www.libsdl.org/projects/SDL_net/release/SDL2_net-2.2.0.tar.gz
tar -xzf SDL2_net-2.2.0.tar.gz tar -xzf SDL2_net-2.2.0.tar.gz -C deps
fi fi
cd SDL2_net-2.2.0 cd deps/SDL2_net-2.2.0
./configure ./configure
make -j 10 make -j 10
sudo make install sudo make install
@ -190,11 +209,11 @@ jobs:
run: | run: |
sudo apt-get remove libtinyxml2-dev sudo apt-get remove libtinyxml2-dev
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
if [ ! -d "tinyxml2-10.0.0" ]; then if [ ! -d "deps/tinyxml2-10.0.0" ]; then
wget https://github.com/leethomason/tinyxml2/archive/refs/tags/10.0.0.tar.gz wget https://github.com/leethomason/tinyxml2/archive/refs/tags/10.0.0.tar.gz
tar -xzf 10.0.0.tar.gz tar -xzf 10.0.0.tar.gz -C deps
fi fi
cd tinyxml2-10.0.0 cd deps/tinyxml2-10.0.0
mkdir -p build mkdir -p build
cd build cd build
cmake .. cmake ..
@ -203,11 +222,11 @@ jobs:
- name: Install libzip without crypto - name: Install libzip without crypto
run: | run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
if [ ! -d "libzip-1.10.1" ]; then if [ ! -d "deps/libzip-1.10.1" ]; then
wget https://github.com/nih-at/libzip/releases/download/v1.10.1/libzip-1.10.1.tar.gz wget https://github.com/nih-at/libzip/releases/download/v1.10.1/libzip-1.10.1.tar.gz
tar -xzf libzip-1.10.1.tar.gz tar -xzf libzip-1.10.1.tar.gz -C deps
fi fi
cd libzip-1.10.1 cd deps/libzip-1.10.1
mkdir -p build mkdir -p build
cd build cd build
cmake .. -DENABLE_COMMONCRYPTO=OFF -DENABLE_GNUTLS=OFF -DENABLE_MBEDTLS=OFF -DENABLE_OPENSSL=OFF cmake .. -DENABLE_COMMONCRYPTO=OFF -DENABLE_GNUTLS=OFF -DENABLE_MBEDTLS=OFF -DENABLE_OPENSSL=OFF
@ -218,6 +237,7 @@ jobs:
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
name: soh.otr name: soh.otr
path: build-cmake/soh
- name: Build SoH - name: Build SoH
run: | run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
@ -237,39 +257,52 @@ jobs:
path: | path: |
soh.appimage soh.appimage
readme.txt readme.txt
- name: Save Cache deps folder
if: ${{ github.ref_name == github.event.repository.default_branch }}
uses: actions/cache/save@v4
with:
key: ${{ steps.restore-cache-deps.outputs.cache-primary-key }}
path: deps
build-windows: build-windows:
needs: generate-soh-otr needs: generate-soh-otr
runs-on: ${{ (vars.WINDOWS_RUNNER && fromJSON(vars.WINDOWS_RUNNER)) || 'windows-latest' }} runs-on: windows-latest
steps: steps:
- name: Install dependencies - name: Install dependencies
if: ${{ !vars.WINDOWS_RUNNER }}
run: | run: |
choco install ninja choco install ninja -y
Remove-Item -Path "C:\ProgramData\Chocolatey\bin\ccache.exe" -Force -ErrorAction SilentlyContinue Remove-Item -Path "C:\ProgramData\Chocolatey\bin\ccache.exe" -Force -ErrorAction SilentlyContinue
- uses: actions/checkout@v4 - name: Git Checkout
uses: actions/checkout@v4
with: with:
submodules: true submodules: true
- name: ccache - name: Configure sccache
uses: hendrikmuhs/ccache-action@v1.2.14 uses: hendrikmuhs/ccache-action@v1.2
with: with:
variant: sccache variant: sccache
max-size: "1G" max-size: "2G"
evict-old-files: job
save: ${{ github.ref_name == github.event.repository.default_branch }}
key: ${{ runner.os }}-ccache-${{ github.ref }}-${{ github.sha }} key: ${{ runner.os }}-ccache-${{ github.ref }}-${{ github.sha }}
restore-keys: | restore-keys: |
${{ runner.os }}-ccache-${{ github.ref }} ${{ runner.os }}-ccache-${{ github.ref }}
${{ runner.os }}-ccache- ${{ runner.os }}-ccache
- name: Cache build folder - name: Restore Cached VCPKG folder
uses: actions/cache@v4 id: restore-cache-vcpkg
uses: actions/cache/restore@v4
with: with:
key: ${{ runner.os }}-build-${{ github.ref }}-${{ github.sha }} key: ${{ runner.os }}-vcpkg-${{ github.ref }}-${{ github.sha }}
restore-keys: | restore-keys: |
${{ runner.os }}-build-${{ github.ref }} ${{ runner.os }}-vcpkg-${{ github.ref }}-
${{ runner.os }}-build- ${{ runner.os }}-vcpkg-
path: | path: vcpkg
build-windows
vcpkg
- name: Configure Developer Command Prompt - name: Configure Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1 uses: ilammy/msvc-dev-cmd@v1
- name: Download soh.otr
uses: actions/download-artifact@v4
with:
name: soh.otr
path: build-windows/soh
- name: Build SoH - name: Build SoH
env: env:
VCPKG_ROOT: ${{github.workspace}}/vcpkg VCPKG_ROOT: ${{github.workspace}}/vcpkg
@ -278,22 +311,19 @@ jobs:
cmake -S . -B build-windows -G Ninja -DCMAKE_MAKE_PROGRAM=ninja -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DBUILD_REMOTE_CONTROL=1 cmake -S . -B build-windows -G Ninja -DCMAKE_MAKE_PROGRAM=ninja -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DBUILD_REMOTE_CONTROL=1
cmake --build build-windows --config Release --parallel 10 cmake --build build-windows --config Release --parallel 10
mkdir soh-windows (cd build-windows && cpack)
mv ./x64/Release/soh.exe ./soh-windows/soh.exe cd ..
mkdir soh-windows/debug mv _packages/*.zip _packages/soh-windows.zip
mkdir soh-windows/mods - name: Unzip package
New-Item soh-windows/mods/custom_otr_files_go_here.txt -type file run: Expand-Archive -Path _packages/soh-windows.zip -DestinationPath soh-windows
mv ./x64/Release/soh.pdb ./soh-windows/debug/soh.pdb
mv ./README.md ./soh-windows/readme.txt
mv ./build-windows/gamecontrollerdb.txt ./soh-windows/gamecontrollerdb.txt
mv ./x64/Release/assets ./soh-windows
- name: Download soh.otr
uses: actions/download-artifact@v4
with:
name: soh.otr
path: soh-windows
- name: Upload build - name: Upload build
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: soh-windows name: soh-windows
path: soh-windows path: soh-windows
- name: Save Cache VCPKG folder
if: ${{ github.ref_name == github.event.repository.default_branch }}
uses: actions/cache/save@v4
with:
key: ${{ steps.restore-cache-vcpkg.outputs.cache-primary-key }}
path: vcpkg

View file

@ -1,9 +1,9 @@
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
set(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY 0) set(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY 0)
set(CPACK_COMPONENTS_ALL "ship" "extractor" "appimage") set(CPACK_COMPONENTS_ALL "ship")
if (NOT CPACK_GENERATOR STREQUAL "External") if (CPACK_GENERATOR STREQUAL "External")
list(REMOVE_ITEM CPACK_COMPONENTS_ALL "appimage") list(APPEND CPACK_COMPONENTS_ALL "extractor" "appimage")
endif() endif()
if (CPACK_GENERATOR MATCHES "DEB|RPM") if (CPACK_GENERATOR MATCHES "DEB|RPM")

View file

@ -174,7 +174,7 @@ set_property(TARGET soh PROPERTY APPIMAGE_ICON_FILE "${CMAKE_BINARY_DIR}/sohIcon
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
install(PROGRAMS "${CMAKE_BINARY_DIR}/linux/soh.sh" DESTINATION . COMPONENT appimage) install(PROGRAMS "${CMAKE_BINARY_DIR}/linux/soh.sh" DESTINATION . COMPONENT appimage)
install(FILES "${CMAKE_SOURCE_DIR}/soh.otr" DESTINATION . COMPONENT ship) install(FILES "${CMAKE_BINARY_DIR}/soh/soh.otr" DESTINATION . COMPONENT ship)
install(TARGETS ZAPD DESTINATION ./assets/extractor COMPONENT extractor) install(TARGETS ZAPD DESTINATION ./assets/extractor COMPONENT extractor)
install(DIRECTORY "${CMAKE_SOURCE_DIR}/soh/assets/extractor/" DESTINATION ./assets/extractor COMPONENT extractor) install(DIRECTORY "${CMAKE_SOURCE_DIR}/soh/assets/extractor/" DESTINATION ./assets/extractor COMPONENT extractor)
install(DIRECTORY "${CMAKE_SOURCE_DIR}/soh/assets/xml/" DESTINATION ./assets/extractor/xmls COMPONENT extractor) install(DIRECTORY "${CMAKE_SOURCE_DIR}/soh/assets/xml/" DESTINATION ./assets/extractor/xmls COMPONENT extractor)