From 4fed88084efea43ae3852baef58bbbd15ba80304 Mon Sep 17 00:00:00 2001 From: GamesTrap Date: Thu, 7 Nov 2024 21:33:42 +0100 Subject: [PATCH] Updated save-cache and restore-cache actions 11/06/2024 | 24w45a3 --- .github/composite/restore-cache/action.yml | 27 ++++++++---- .github/composite/save-cache/action.yml | 27 +++++++----- .github/workflows/build.yml | 50 +++++++++++++++++++--- Dependencies/Box2D.lua | 2 +- SITREPS.txt | 3 ++ TRAP/src/Core/Base.h | 2 +- TRAP/src/Log/Log.h | 2 +- 7 files changed, 85 insertions(+), 28 deletions(-) diff --git a/.github/composite/restore-cache/action.yml b/.github/composite/restore-cache/action.yml index b481acf6d..e31527a94 100644 --- a/.github/composite/restore-cache/action.yml +++ b/.github/composite/restore-cache/action.yml @@ -28,24 +28,32 @@ runs: id: build-dest-path run: | echo "TARGET_PATH=${{ github.event.repository.name }}/cache/${{inputs.key}}.7z" >> "$GITHUB_OUTPUT" + echo "TARGET_FOLDER_PATH=${{ github.event.repository.name }}/cache" >> "$GITHUB_OUTPUT" - name: Check cache (Linux) shell: bash - id: check-cache + id: check-cache-linux if: runner.os == 'Linux' run: | + set +e sudo apt install -y smbclient - if smbclient //${{inputs.server-hostname}}/${{inputs.server-share}} -U ${{inputs.server-username}}%${{inputs.server-password}} -c 'ls "${{steps.build-dest-path.outputs.TARGET_PATH}}"' 2>/dev/null | grep -q "${{steps.build-dest-path.outputs.TARGET_PATH}}"; then - echo "CACHE_HIT=true" >> "$GITHUB_OUTPUT" + smbclient //${{inputs.server-hostname}}/${{inputs.server-share}} -U ${{inputs.server-username}}%${{inputs.server-password}} -c 'prompt; recurse; mkdir "${{steps.build-dest-path.outputs.TARGET_FOLDER_PATH}}"' + smbResult=$(smbclient //${{inputs.server-hostname}}/${{inputs.server-share}} -U ${{inputs.server-username}}%${{inputs.server-password}} -c 'ls "${{steps.build-dest-path.outputs.TARGET_PATH}}"') + if echo "$smbResult" | grep -q "NT_STATUS_NO_SUCH_FILE"; then + echo "CACHE_HIT=false" >> "$GITHUB_OUTPUT"; + elif echo "$smbResult" | grep -q "NT_STATUS_OBJECT_NAME_NOT_FOUND"; then + echo "CACHE_HIT=false" >> "$GITHUB_OUTPUT"; else - echo "CACHE_HIT=false" >> "$GITHUB_OUTPUT" + echo "Found matching cache"; + echo "CACHE_HIT=true" >> "$GITHUB_OUTPUT"; fi - name: Check cache (Windows) - id: check-cache + id: check-cache-windows shell: powershell if: runner.os == 'Windows' run: | New-PSDrive -Name "X" -PSProvider FileSystem -Root "\\${{inputs.server-hostname}}\${{inputs.server-share}}" -Persist -Credential (New-Object System.Management.Automation.PSCredential ("${{inputs.server-username}}", (ConvertTo-SecureString "${{inputs.server-password}}" -AsPlainText -Force))) if (Test-Path "X:\${{steps.build-dest-path.outputs.TARGET_PATH}}") { + echo "Found matching cache" echo "CACHE_HIT=true" >> $ENV:GITHUB_OUTPUT } else { echo "CACHE_HIT=false" >> $ENV:GITHUB_OUTPUT @@ -53,22 +61,23 @@ runs: Remove-PSDrive -Name "X" - name: Restore cache (Linux) shell: bash - if: runner.os == 'Linux' && ${{steps.check-cache.outputs.CACHE_HIT}} == "true" + if: runner.os == 'Linux' && steps.check-cache-linux.outputs.CACHE_HIT == 'true' run: | - sudo apt install -y smbclient smbclient //${{inputs.server-hostname}}/${{inputs.server-share}} -U ${{inputs.server-username}}%${{inputs.server-password}} -c 'prompt; recurse; get "${{steps.build-dest-path.outputs.TARGET_PATH}}" "${{inputs.key}}.7z"' - name: Restore cache (Windows) - shell: bash - if: runner.os == 'Windows' && ${{steps.check-cache.outputs.CACHE_HIT}} == "true" + shell: powershell + if: runner.os == 'Windows' && steps.check-cache-windows.outputs.CACHE_HIT == 'true' run: | New-PSDrive -Name "X" -PSProvider FileSystem -Root "\\${{inputs.server-hostname}}\${{inputs.server-share}}" -Persist -Credential (New-Object System.Management.Automation.PSCredential ("${{inputs.server-username}}", (ConvertTo-SecureString "${{inputs.server-password}}" -AsPlainText -Force))) Copy-Item -Path "X:\${{steps.build-dest-path.outputs.TARGET_PATH}}" -Destination ".\${{inputs.key}}.7z" Remove-PSDrive -Name "X" - name: Extract cache (7z) shell: bash + if: steps.check-cache-linux.outputs.CACHE_HIT == 'true' || steps.check-cache-windows.outputs.CACHE_HIT == 'true' run: | 7z x -aos -bb0 -bse0 -bsp2 -pdefault -sccUTF-8 -o${{inputs.folder-path}} '${{inputs.key}}.7z' - name: Cleanup cache shell: bash + if: steps.check-cache-linux.outputs.CACHE_HIT == 'true' || steps.check-cache-windows.outputs.CACHE_HIT == 'true' run: | rm '${{inputs.key}}.7z' diff --git a/.github/composite/save-cache/action.yml b/.github/composite/save-cache/action.yml index c434b2ccf..c7f13f64e 100644 --- a/.github/composite/save-cache/action.yml +++ b/.github/composite/save-cache/action.yml @@ -31,22 +31,29 @@ runs: echo "TARGET_FOLDER_PATH=${{ github.event.repository.name }}/cache" >> "$GITHUB_OUTPUT" - name: Check cache (Linux) shell: bash - id: check-cache + id: check-cache-linux if: runner.os == 'Linux' run: | + set +e sudo apt install -y smbclient - if smbclient //${{inputs.server-hostname}}/${{inputs.server-share}} -U ${{inputs.server-username}}%${{inputs.server-password}} -c 'ls "${{steps.build-dest-path.outputs.TARGET_PATH}}"' 2>/dev/null | grep -q "${{steps.build-dest-path.outputs.TARGET_PATH}}"; then - echo "CACHE_HIT=true" >> "$GITHUB_OUTPUT" + smbclient //${{inputs.server-hostname}}/${{inputs.server-share}} -U ${{inputs.server-username}}%${{inputs.server-password}} -c 'prompt; recurse; mkdir "${{steps.build-dest-path.outputs.TARGET_FOLDER_PATH}}"' + smbResult=$(smbclient //${{inputs.server-hostname}}/${{inputs.server-share}} -U ${{inputs.server-username}}%${{inputs.server-password}} -c 'ls "${{steps.build-dest-path.outputs.TARGET_PATH}}"') + if echo "$smbResult" | grep -q "NT_STATUS_NO_SUCH_FILE"; then + echo "CACHE_HIT=false" >> "$GITHUB_OUTPUT"; + elif echo "$smbResult" | grep -q "NT_STATUS_OBJECT_NAME_NOT_FOUND"; then + echo "CACHE_HIT=false" >> "$GITHUB_OUTPUT"; else - echo "CACHE_HIT=false" >> "$GITHUB_OUTPUT" + echo "Found matching cache"; + echo "CACHE_HIT=true" >> "$GITHUB_OUTPUT"; fi - name: Check cache (Windows) - id: check-cache + id: check-cache-windows shell: powershell if: runner.os == 'Windows' run: | New-PSDrive -Name "X" -PSProvider FileSystem -Root "\\${{inputs.server-hostname}}\${{inputs.server-share}}" -Persist -Credential (New-Object System.Management.Automation.PSCredential ("${{inputs.server-username}}", (ConvertTo-SecureString "${{inputs.server-password}}" -AsPlainText -Force))) if (Test-Path "X:\${{steps.build-dest-path.outputs.TARGET_PATH}}") { + echo "Found matching cache" echo "CACHE_HIT=true" >> $ENV:GITHUB_OUTPUT } else { echo "CACHE_HIT=false" >> $ENV:GITHUB_OUTPUT @@ -54,23 +61,23 @@ runs: Remove-PSDrive -Name "X" - name: Archive cache (7z) shell: bash - if: ${{steps.check-cache.outputs.CACHE_HIT}} == "false" + if: steps.check-cache-linux.outputs.CACHE_HIT == 'false' || steps.check-cache-windows.outputs.CACHE_HIT == 'false' run: | - 7z a -t7z -m0=LZMA2 -mmt=$(nproc) -mx9 -md=64m -mfb=64 -ms=16g -mqs=on -sccUTF-8 -bb0 -bse0 -bsp2 -w -mtc=on -mta=on '${{inputskey}}.7z' ${{inputs.folder-path}}/* + 7z a -t7z -m0=LZMA2 -mmt=$(nproc) -mx9 -md=64m -mfb=64 -ms=16g -mqs=on -sccUTF-8 -bb0 -bse0 -bsp2 -w -mtc=on -mta=on '${{inputs.key}}.7z' ${{inputs.folder-path}} - name: Upload cache (Windows) shell: powershell - if: runner.os == 'Windows' && ${{steps.check-cache.outputs.CACHE_HIT}} == "false" + if: runner.os == 'Windows' && steps.check-cache-windows.outputs.CACHE_HIT == 'false' run: | New-PSDrive -Name "X" -PSProvider FileSystem -Root "\\${{inputs.server-hostname}}\${{inputs.server-share}}" -Persist -Credential (New-Object System.Management.Automation.PSCredential ("${{inputs.server-username}}", (ConvertTo-SecureString "${{inputs.server-password}}" -AsPlainText -Force))) Copy-Item -Path "${{inputs.key}}.7z" -Destination (New-Item -type directory -force "X:\${{steps.build-dest-path.outputs.TARGET_FOLDER_PATH}}") -force -ea 0 Remove-PSDrive -Name "X" - name: Upload cache (Linux) shell: bash - if: runner.os == 'Linux' && ${{steps.check-cache.outputs.CACHE_HIT}} == "false" + if: runner.os == 'Linux' && steps.check-cache-linux.outputs.CACHE_HIT == 'false' run: | - sudo apt install -y smbclient smbclient //${{inputs.server-hostname}}/${{inputs.server-share}} -U ${{inputs.server-username}}%${{inputs.server-password}} -c 'prompt; recurse; mkdir "${{steps.build-dest-path.outputs.TARGET_FOLDER_PATH}}"; put "${{inputs.key}}.7z" "${{steps.build-dest-path.outputs.TARGET_PATH}}"' - name: Cleanup cache shell: bash + if: steps.check-cache-linux.outputs.CACHE_HIT == 'false' || steps.check-cache-windows.outputs.CACHE_HIT == 'false' run: | rm '${{inputs.key}}.7z' diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 96a57f50a..4266e696e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,6 +60,14 @@ jobs: git remote add origin ${{ secrets.GIT_NDA_DEPS }}/${{ secrets.GIT_NDA_DEPS_STEAMWORKSSDK }} git pull origin main cd ../.. + - name: Retrieve keys for cache + env: + artifact_hostname: ${{secrets.ARTIFACT_HOST}} + if: env.artifact_hostname != null + shell: bash + id: cache-keys + run: | + echo "Box2D=$(git -C Dependencies/Box2D rev-parse HEAD)_Linux_Release" >> "$GITHUB_OUTPUT" - name: Restore Box2D cache (TrappedGames) env: artifact_hostname: ${{secrets.ARTIFACT_HOST}} @@ -70,9 +78,8 @@ jobs: server-share: "artifacts" server-username: ${{ secrets.ARTIFACT_USERNAME }} server-password: ${{ secrets.ARTIFACT_PASSWORD }} - key: "$(git -C Dependencies/Box2D rev-parse HEAD)_Release" - folder-path: > - bin/Release-linux-x86_64/./Dependencies/Box2D + key: ${{steps.cache-keys.outputs.Box2D}} + folder-path: bin/Release-linux-x86_64/Dependencies/Box2D/ - name: Add toolchain ppa run: sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/ppa - name: Update package list @@ -110,9 +117,8 @@ jobs: server-share: "artifacts" server-username: ${{ secrets.ARTIFACT_USERNAME }} server-password: ${{ secrets.ARTIFACT_PASSWORD }} - key: "$(git -C Dependencies/Box2D rev-parse HEAD)_Release" - folder-path: > - bin/Release-linux-x86_64/Dependencies/Box2D + key: ${{steps.cache-keys.outputs.Box2D}} + folder-path: bin/Release-linux-x86_64/Dependencies/Box2D/./ - name: Finalize data for artifact run: | cp -r Games/Headless-Tests/Assets bin/Release-linux-x86_64/Games/Headless-Tests/ @@ -311,6 +317,26 @@ jobs: git remote add origin ${{ secrets.GIT_NDA_DEPS }}/${{ secrets.GIT_NDA_DEPS_STEAMWORKSSDK }} git pull origin main cd ../.. + - name: Retrieve keys for cache + env: + artifact_hostname: ${{secrets.ARTIFACT_HOST}} + if: env.artifact_hostname != null + shell: bash + id: cache-keys + run: | + echo "Box2D=$(git -C Dependencies/Box2D rev-parse HEAD)_Windows_Release" >> "$GITHUB_OUTPUT" + - name: Restore Box2D cache (TrappedGames) + env: + artifact_hostname: ${{secrets.ARTIFACT_HOST}} + if: env.artifact_hostname != null + uses: ./.github/composite/restore-cache + with: + server-hostname: ${{ secrets.ARTIFACT_HOST }} + server-share: "artifacts" + server-username: ${{ secrets.ARTIFACT_USERNAME }} + server-password: ${{ secrets.ARTIFACT_PASSWORD }} + key: ${{steps.cache-keys.outputs.Box2D}} + folder-path: bin/Release-windows-x86_64/Dependencies/Box2D/ - name: Setup developer console uses: ilammy/msvc-dev-cmd@v1 with: @@ -326,6 +352,18 @@ jobs: run: | $maxCPUCount = if($env:CONTAINER_MAX_CPUS) {$env:CONTAINER_MAX_CPUS} Else {$env:NUMBER_OF_PROCESSORS} ninja Release -j $maxCPUCount + - name: Save Box2D cache (TrappedGames) + env: + artifact_hostname: ${{secrets.ARTIFACT_HOST}} + if: env.artifact_hostname != null + uses: ./.github/composite/save-cache + with: + server-hostname: ${{ secrets.ARTIFACT_HOST }} + server-share: "artifacts" + server-username: ${{ secrets.ARTIFACT_USERNAME }} + server-password: ${{ secrets.ARTIFACT_PASSWORD }} + key: ${{steps.cache-keys.outputs.Box2D}} + folder-path: bin/Release-windows-x86_64/Dependencies/Box2D/./ - name: Finalize data for artifact run: | Xcopy Games\Headless-Tests\Assets bin\Release-windows-x86_64\Games\Headless-Tests\Assets /I /H /E /C diff --git a/Dependencies/Box2D.lua b/Dependencies/Box2D.lua index b0f539fd6..c59d50792 100644 --- a/Dependencies/Box2D.lua +++ b/Dependencies/Box2D.lua @@ -3,7 +3,7 @@ project "Box2D" language "C++" warnings "off" -if os.getenv("RUN_CICD_PIPELINE") ~= nil and os.matchfiles(_MAIN_SCRIPT_DIR .. "/bin/**/*Box2D.a") ~= nil then +if os.getenv("RUN_CICD_PIPELINE") ~= nil and not table.isempty(os.matchfiles(_MAIN_SCRIPT_DIR .. "/bin/**/*Box2D.a")) then -- Using CICD Pipeline cache else files diff --git a/SITREPS.txt b/SITREPS.txt index 30538295b..104455b67 100644 --- a/SITREPS.txt +++ b/SITREPS.txt @@ -5370,3 +5370,6 @@ SITREP 11/06/2024|24w45a3 - Changed TRAP Engine version to 24w45a3(0.11.38) - Code Coverage Changed generation script ~<10 mins - Build-CI Added experimental cache actions (only enabled on GCC for Box2D) ~<30 mins + +SITREP 11/07/2024|24w45a4 + - Changed TRAP Engine version to 24w45a4(0.11.39) diff --git a/TRAP/src/Core/Base.h b/TRAP/src/Core/Base.h index fb31062d4..619953ff4 100644 --- a/TRAP/src/Core/Base.h +++ b/TRAP/src/Core/Base.h @@ -77,7 +77,7 @@ //-------------------------------------------------------------------------------------------------------------------// /// @brief TRAP version number created with TRAP_MAKE_VERSION -inline constexpr TRAP::SemanticVersion<0, 11, 38> TRAP_VERSION{}; +inline constexpr TRAP::SemanticVersion<0, 11, 39> TRAP_VERSION{}; //-------------------------------------------------------------------------------------------------------------------// diff --git a/TRAP/src/Log/Log.h b/TRAP/src/Log/Log.h index ff29f74e0..1b0d8710f 100644 --- a/TRAP/src/Log/Log.h +++ b/TRAP/src/Log/Log.h @@ -155,7 +155,7 @@ namespace TRAP /// @threadsafe void Clear() noexcept; - static constexpr auto WindowVersion = "[24w45a3]"; + static constexpr auto WindowVersion = "[24w45a4]"; static constexpr auto WindowPrefix = "[Window] "; static constexpr auto WindowIconPrefix = "[Window][Icon] "; static constexpr auto ConfigPrefix = "[Config] ";