[CONAN] cache build directory too

This commit is contained in:
Nicholas Dudfield
2025-03-25 14:03:09 +07:00
parent 643cd9fef1
commit 314fb6c9e0
3 changed files with 56 additions and 1 deletions

View File

@@ -111,6 +111,20 @@ jobs:
~/.conan2
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
# After your cache restore for Conan but before the build step
- name: Restore build directory cache
id: build-cache-restore
uses: actions/cache/restore@v4
with:
path: ${{ env.build_dir }}
# Primary key without SHA - much higher hit probability
key: ${{ runner.os }}-build-${{ matrix.configuration }}-${{ github.ref_name }}-${{ hashFiles('**/conanfile.txt', '**/conanfile.py') }}
restore-keys: |
# Same branch, different dependencies
${{ runner.os }}-build-${{ matrix.configuration }}-${{ github.ref_name }}-
# Same configuration, any branch
${{ runner.os }}-build-${{ matrix.configuration }}-
# Build still calls the install dependency installation every time
# but it should be fast if the ~/.conan folder is primed with pre-build deps
- name: Build
@@ -119,6 +133,15 @@ jobs:
generator: ${{ matrix.generator }}
configuration: ${{ matrix.configuration }}
# After your build step but before tests or artifact uploads
- name: Save build directory cache
if: success()
uses: actions/cache/save@v4
with:
path: ${{ env.build_dir }}
# Reference the primary key from the restore step
key: ${{ steps.build-cache-restore.outputs.cache-primary-key }}
- name: Test
run: |
${build_dir}/rippled --unittest --unittest-jobs $(nproc)

View File

@@ -109,11 +109,38 @@ jobs:
${{ matrix.cc }} --version
${{ matrix.cxx }} --version
# After your Conan cache restore but before the build step
- name: Restore build directory cache
id: build-cache-restore
uses: actions/cache/restore@v4
with:
path: ${{ env.build_dir }}
# Primary key without SHA - much higher hit probability
key: ${{ runner.os }}-build-${{ matrix.compiler }}-${{ matrix.configuration }}-${{ github.ref_name }}-${{ hashFiles('**/conanfile.txt', '**/conanfile.py') }}
restore-keys: |
# Same branch, different dependencies
${{ runner.os }}-build-${{ matrix.compiler }}-${{ matrix.configuration }}-${{ github.ref_name }}-
# Same compiler/config, any branch
${{ runner.os }}-build-${{ matrix.compiler }}-${{ matrix.configuration }}-
- name: Build
uses: ./.github/actions/build
with:
generator: Ninja
configuration: ${{ matrix.configuration }}
env:
# Make sure the build action receives the build_dir explicitly
build_dir: ${{ env.build_dir }}
# After your build step but before tests or artifact uploads
- name: Save build directory cache
if: success()
uses: actions/cache/save@v4
with:
path: ${{ env.build_dir }}
# Reference the primary key from the restore step
key: ${{ steps.build-cache-restore.outputs.cache-primary-key }}
- name: Set artifact name
id: set-artifact-name
@@ -122,6 +149,11 @@ jobs:
echo "artifact_name=${ARTIFACT_NAME}" >> "$GITHUB_OUTPUT"
echo "Using artifact name: ${ARTIFACT_NAME}"
- name: Debug build directory
run: |
echo "Checking build directory contents..."
ls -la ${{ env.build_dir }} || echo "Build directory not found"
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with: