Skip to content

Commit

Permalink
Updated save-cache and restore-cache actions 11/06/2024 | 24w45a3
Browse files Browse the repository at this point in the history
  • Loading branch information
GamesTrap committed Nov 7, 2024
1 parent 3b82bfd commit 4fed880
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 28 deletions.
27 changes: 18 additions & 9 deletions .github/composite/restore-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,47 +28,56 @@ 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
}
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'
27 changes: 17 additions & 10 deletions .github/composite/save-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,46 +31,53 @@ 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
}
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'
50 changes: 44 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand All @@ -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
Expand Down Expand Up @@ -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/
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Dependencies/Box2D.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions SITREPS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion TRAP/src/Core/Base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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{};

//-------------------------------------------------------------------------------------------------------------------//

Expand Down
2 changes: 1 addition & 1 deletion TRAP/src/Log/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -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] ";
Expand Down

0 comments on commit 4fed880

Please sign in to comment.