From 9f615edb84008fac2e202e615bc863c1edc755f1 Mon Sep 17 00:00:00 2001 From: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Date: Sat, 13 Jul 2024 17:38:59 +0200 Subject: [PATCH] [CI] Upload build cache before running tests --- .../action.yml | 11 +++++------ .github/actions/godot-cache-save/action.yml | 17 +++++++++++++++++ .github/workflows/android_builds.yml | 8 ++++++-- .github/workflows/ios_builds.yml | 8 ++++++-- .github/workflows/linux_builds.yml | 10 ++++++++-- .github/workflows/macos_builds.yml | 10 ++++++++-- .github/workflows/web_builds.yml | 8 ++++++-- .github/workflows/windows_builds.yml | 10 ++++++++-- 8 files changed, 64 insertions(+), 18 deletions(-) rename .github/actions/{godot-cache => godot-cache-restore}/action.yml (87%) create mode 100644 .github/actions/godot-cache-save/action.yml diff --git a/.github/actions/godot-cache/action.yml b/.github/actions/godot-cache-restore/action.yml similarity index 87% rename from .github/actions/godot-cache/action.yml rename to .github/actions/godot-cache-restore/action.yml index b7ca01bb47d..eb955affef9 100644 --- a/.github/actions/godot-cache/action.yml +++ b/.github/actions/godot-cache-restore/action.yml @@ -1,18 +1,17 @@ -name: Setup Godot build cache -description: Setup Godot build cache. +name: Restore Godot build cache +description: Restore Godot build cache. inputs: cache-name: description: The cache base name (job name by default). default: "${{github.job}}" scons-cache: - description: The scons cache path. + description: The SCons cache path. default: "${{github.workspace}}/.scons-cache/" runs: using: "composite" steps: - # Upload cache on completion and check it out now - - name: Load .scons_cache directory - uses: actions/cache@v4 + - name: Restore SCons cache directory + uses: actions/cache/restore@v4 with: path: ${{inputs.scons-cache}} key: ${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} diff --git a/.github/actions/godot-cache-save/action.yml b/.github/actions/godot-cache-save/action.yml new file mode 100644 index 00000000000..b7cbf91f94f --- /dev/null +++ b/.github/actions/godot-cache-save/action.yml @@ -0,0 +1,17 @@ +name: Save Godot build cache +description: Save Godot build cache. +inputs: + cache-name: + description: The cache base name (job name by default). + default: "${{github.job}}" + scons-cache: + description: The SCons cache path. + default: "${{github.workspace}}/.scons-cache/" +runs: + using: "composite" + steps: + - name: Save SCons cache directory + uses: actions/cache/save@v4 + with: + path: ${{inputs.scons-cache}} + key: ${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} diff --git a/.github/workflows/android_builds.yml b/.github/workflows/android_builds.yml index 7596c0efec0..04c4af11054 100644 --- a/.github/workflows/android_builds.yml +++ b/.github/workflows/android_builds.yml @@ -26,8 +26,8 @@ jobs: distribution: temurin java-version: 17 - - name: Setup Godot build cache - uses: ./.github/actions/godot-cache + - name: Restore Godot build cache + uses: ./.github/actions/godot-cache-restore continue-on-error: true - name: Setup python and scons @@ -49,6 +49,10 @@ jobs: target: template_release tests: false + - name: Save Godot build cache + uses: ./.github/actions/godot-cache-save + continue-on-error: true + - name: Generate Godot templates run: | cd platform/android/java diff --git a/.github/workflows/ios_builds.yml b/.github/workflows/ios_builds.yml index 3e31fe13aff..781cea18e92 100644 --- a/.github/workflows/ios_builds.yml +++ b/.github/workflows/ios_builds.yml @@ -20,8 +20,8 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Setup Godot build cache - uses: ./.github/actions/godot-cache + - name: Restore Godot build cache + uses: ./.github/actions/godot-cache-restore continue-on-error: true - name: Setup python and scons @@ -35,5 +35,9 @@ jobs: target: template_release tests: false + - name: Save Godot build cache + uses: ./.github/actions/godot-cache-save + continue-on-error: true + - name: Upload artifact uses: ./.github/actions/upload-artifact diff --git a/.github/workflows/linux_builds.yml b/.github/workflows/linux_builds.yml index 9d1c5efc190..9fb2ba700ef 100644 --- a/.github/workflows/linux_builds.yml +++ b/.github/workflows/linux_builds.yml @@ -102,8 +102,8 @@ jobs: sudo rm -rf /usr/local/lib/android echo "Disk usage after:" && df -h - - name: Setup Godot build cache - uses: ./.github/actions/godot-cache + - name: Restore Godot build cache + uses: ./.github/actions/godot-cache-restore with: cache-name: ${{ matrix.cache-name }} continue-on-error: true @@ -128,6 +128,12 @@ jobs: target: ${{ matrix.target }} tests: ${{ matrix.tests }} + - name: Save Godot build cache + uses: ./.github/actions/godot-cache-save + with: + cache-name: ${{ matrix.cache-name }} + continue-on-error: true + - name: Generate C# glue if: ${{ matrix.build-mono }} run: | diff --git a/.github/workflows/macos_builds.yml b/.github/workflows/macos_builds.yml index 0c113a9f4d1..00a5b8f6812 100644 --- a/.github/workflows/macos_builds.yml +++ b/.github/workflows/macos_builds.yml @@ -35,8 +35,8 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Setup Godot build cache - uses: ./.github/actions/godot-cache + - name: Restore Godot build cache + uses: ./.github/actions/godot-cache-restore with: cache-name: ${{ matrix.cache-name }} continue-on-error: true @@ -64,6 +64,12 @@ jobs: target: ${{ matrix.target }} tests: ${{ matrix.tests }} + - name: Save Godot build cache + uses: ./.github/actions/godot-cache-save + with: + cache-name: ${{ matrix.cache-name }} + continue-on-error: true + - name: Prepare artifact run: | lipo -create ./bin/godot.macos.${{ matrix.target }}.x86_64 ./bin/godot.macos.${{ matrix.target }}.arm64 -output ./bin/godot.macos.${{ matrix.target }}.universal diff --git a/.github/workflows/web_builds.yml b/.github/workflows/web_builds.yml index 598ff3cf7c1..68a6879ddb4 100644 --- a/.github/workflows/web_builds.yml +++ b/.github/workflows/web_builds.yml @@ -33,8 +33,8 @@ jobs: run: | emcc -v - - name: Setup Godot build cache - uses: ./.github/actions/godot-cache + - name: Restore Godot build cache + uses: ./.github/actions/godot-cache-restore continue-on-error: true - name: Setup python and scons @@ -48,5 +48,9 @@ jobs: target: template_release tests: false + - name: Save Godot build cache + uses: ./.github/actions/godot-cache-save + continue-on-error: true + - name: Upload artifact uses: ./.github/actions/upload-artifact diff --git a/.github/workflows/windows_builds.yml b/.github/workflows/windows_builds.yml index fc03b6647d2..d1eb8db9ecf 100644 --- a/.github/workflows/windows_builds.yml +++ b/.github/workflows/windows_builds.yml @@ -40,8 +40,8 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Setup Godot build cache - uses: ./.github/actions/godot-cache + - name: Restore Godot build cache + uses: ./.github/actions/godot-cache-restore with: cache-name: ${{ matrix.cache-name }} continue-on-error: true @@ -60,6 +60,12 @@ jobs: target: ${{ matrix.target }} tests: ${{ matrix.tests }} + - name: Save Godot build cache + uses: ./.github/actions/godot-cache-save + with: + cache-name: ${{ matrix.cache-name }} + continue-on-error: true + - name: Prepare artifact run: | Remove-Item bin/* -Include *.exp,*.lib,*.pdb -Force