From 314fb6c9e02907e378cb515216ebe34cd959f2db Mon Sep 17 00:00:00 2001 From: Nicholas Dudfield Date: Tue, 25 Mar 2025 14:03:09 +0700 Subject: [PATCH] [CONAN] cache build directory too --- .github/actions/dependencies/action.yml | 2 +- .github/workflows/macos-ga.yml | 23 ++++++++++++++++++ .github/workflows/nix-ga.yml | 32 +++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/.github/actions/dependencies/action.yml b/.github/actions/dependencies/action.yml index af570f21b..b62cb8a89 100644 --- a/.github/actions/dependencies/action.yml +++ b/.github/actions/dependencies/action.yml @@ -14,7 +14,7 @@ runs: - name: install dependencies shell: bash run: | - mkdir ${build_dir} + mkdir -p ${build_dir} # TODO:CONAN cd ${build_dir} conan install \ --output-folder . \ diff --git a/.github/workflows/macos-ga.yml b/.github/workflows/macos-ga.yml index 15674eee8..350b4b5a4 100644 --- a/.github/workflows/macos-ga.yml +++ b/.github/workflows/macos-ga.yml @@ -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) \ No newline at end of file diff --git a/.github/workflows/nix-ga.yml b/.github/workflows/nix-ga.yml index 3669321d4..1769c2101 100644 --- a/.github/workflows/nix-ga.yml +++ b/.github/workflows/nix-ga.yml @@ -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: