Improved Rust caching for the build pipeline (#136)

This commit is contained in:
Thorsten Sommer 2024-09-09 12:39:53 +02:00 committed by GitHub
parent 0d1164c0eb
commit 7a5f2d4aec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -249,18 +249,6 @@ jobs:
cd publish/dotnet cd publish/dotnet
mv mindworkAIStudio.exe "../../app/MindWork AI Studio/bin/dist/mindworkAIStudioServer${{ matrix.dotnet_name_postfix }}" mv mindworkAIStudio.exe "../../app/MindWork AI Studio/bin/dist/mindworkAIStudioServer${{ matrix.dotnet_name_postfix }}"
- name: Create parts for the Rust cache key (Unix)
if: matrix.platform != 'windows-latest'
run: |
cd runtime
echo "CARGO_LOCK_HASH=${{ hashFiles('**/Cargo.lock') }}" >> $GITHUB_ENV
- name: Create parts for the Rust cache key (Windows)
if: matrix.platform == 'windows-latest'
run: |
cd runtime
echo "CARGO_LOCK_HASH=${{ hashFiles('**/Cargo.lock') }}" >> $env:GITHUB_ENV
- name: Cache Rust - name: Cache Rust
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
@ -272,17 +260,7 @@ jobs:
~/.rustup/toolchains ~/.rustup/toolchains
runtime/target runtime/target
# When the entire key matches, Rust might just create the bundles using the current .NET build: key: target-${{ matrix.dotnet_runtime }}-rust-${{ env.RUST_VERSION }}
key: target-${{ matrix.dotnet_runtime }}-rust-${{ env.RUST_VERSION }}-dependencies-${{ env.CARGO_LOCK_HASH }}
# - 1st key: the Rust runtime dependencies changed. Anyway, we might be able to re-use many previously built packages.
#
# - No match: alright, a new Rust version was released. Sadly, we cannot re-use anything now. Why?
# The updated Rust compiler might mitigate some bugs or vulnerabilities. In order to apply
# these changes to our app, we have to re-compile everything. That's the reason why it makes
# no sense to use more parts for the cache key, like Tauri or Tauri build versions.
restore-keys: |
target-${{ matrix.dotnet_runtime }}-rust-${{ env.RUST_VERSION }}-dependencies-
- name: Setup Rust (stable) - name: Setup Rust (stable)
uses: dtolnay/rust-toolchain@master uses: dtolnay/rust-toolchain@master
@ -478,30 +456,13 @@ jobs:
cd publish/dotnet cd publish/dotnet
mv mindworkAIStudio "../../app/MindWork AI Studio/bin/dist/mindworkAIStudioServer-aarch64-unknown-linux-gnu" mv mindworkAIStudio "../../app/MindWork AI Studio/bin/dist/mindworkAIStudioServer-aarch64-unknown-linux-gnu"
- name: Create parts for the Rust cache key
if: ${{ env.SKIP != 'true' }}
run: |
cd runtime
echo "CARGO_LOCK_HASH=${{ hashFiles('**/Cargo.lock') }}" >> $GITHUB_ENV
- name: Cache linux arm64 runner image - name: Cache linux arm64 runner image
if: ${{ env.SKIP != 'true' }} if: ${{ env.SKIP != 'true' }}
uses: actions/cache@v4 uses: actions/cache@v4
id: linux_arm_cache id: linux_arm_cache
with: with:
path: ${{ runner.temp }}/linux_arm_qemu_cache.img path: ${{ runner.temp }}/linux_arm_qemu_cache.img
key: target-linux-arm64-rust-${{ env.RUST_VERSION }}
# When the entire key matches, Rust might just create the bundles using the current .NET build:
key: target-linux-arm64-rust-${{ env.RUST_VERSION }}-dependencies-${{ env.CARGO_LOCK_HASH }}
# - 1st key: the Rust runtime dependencies changed. Anyway, we might be able to re-use many previously built packages.
#
# - No match: alright, a new Rust version was released. Sadly, we cannot re-use anything now. Why?
# The updated Rust compiler might mitigate some bugs or vulnerabilities. In order to apply
# these changes to our app, we have to re-compile everything. That's the reason why it makes
# no sense to use more parts for the cache key, like Tauri or Tauri build versions.
restore-keys: |
target-linux-arm64-rust-${{ env.RUST_VERSION }}-dependencies-
- name: Build linux arm runner image - name: Build linux arm runner image
uses: pguyot/arm-runner-action@v2 uses: pguyot/arm-runner-action@v2
@ -586,18 +547,6 @@ jobs:
rm -fr /rust-cache/target rm -fr /rust-cache/target
cp -Rp target /rust-cache cp -Rp target /rust-cache
- name: Debug
if: ${{ env.SKIP != 'true' }}
run: |
echo "Current directory: $(pwd)"
ls -lhat
echo "Searching for linux_arm_qemu_cache.img"
find $RUNNER_TEMP -name 'linux_arm_qemu_cache.img' -print 2>/dev/null
echo "Searching for mind-work-ai-studio_*.deb"
find . -name 'mind-work-ai-studio_*.deb' -print 2>/dev/null
- name: Update the runner image to cache the Rust runtime build - name: Update the runner image to cache the Rust runtime build
if: ${{ env.SKIP != 'true' }} if: ${{ env.SKIP != 'true' }}
run: | run: |