From 8f9dae83509df01163003cdedd26f413a803a44e Mon Sep 17 00:00:00 2001 From: otavepto <153766569+otavepto@users.noreply.github.com> Date: Tue, 26 Dec 2023 20:16:21 +0200 Subject: [PATCH] attempt to cache deps in non tag/PR actions for CI --- .github/workflows/build-linux.yml | 47 +++++++++++++++++++++++++-- .github/workflows/build-win.yml | 53 +++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 42a1a25a..0a35bf82 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -25,8 +25,52 @@ env: THIRD_PARTY_BASE_DIR: 'third-party' jobs: + # this helps in manual runs, if build fails, then deps are saved + dependencies: + runs-on: ubuntu-22.04 + # cache but not for tags or PRs + # !tag && !pull_request + # also you could use this: github.event_name != 'pull_request' + if: | + !startsWith(github.ref, 'refs/tags/') && + !startsWith(github.ref, 'refs/pull/') + + steps: + # we need branch because it has build scripts + - name: Checkout branch + uses: actions/checkout@v4 + + - name: Lookup cache for deps + id: emu-deps-cache-step + uses: actions/cache@v3 + with: + key: ${{ env.DEPS_CACHE_KEY }} + path: ${{ env.DEPS_CACHE_DIR }} + lookup-only: true # don't restore cache if found + + - name: Clone third-party deps (deps/linux) + if: steps.emu-deps-cache-step.outputs.cache-hit != 'true' + uses: actions/checkout@v4 + with: + ref: 'third-party/deps/linux' + path: "${{env.THIRD_PARTY_BASE_DIR}}/deps/linux" + + - name: Clone third-party deps (deps/common) + if: steps.emu-deps-cache-step.outputs.cache-hit != 'true' + uses: actions/checkout@v4 + with: + ref: 'third-party/deps/common' + path: "${{env.THIRD_PARTY_BASE_DIR}}/deps/common" + + - name: Build deps + if: steps.emu-deps-cache-step.outputs.cache-hit != 'true' + shell: bash + run: sudo chmod 777 build_linux_deps.sh && sudo ./build_linux_deps.sh + + build: runs-on: ubuntu-22.04 + needs: [ dependencies ] steps: - name: Checkout branch @@ -40,13 +84,12 @@ jobs: if: | !startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/pull/') - uses: actions/cache@v3 with: key: ${{ env.DEPS_CACHE_KEY }} path: ${{ env.DEPS_CACHE_DIR }} - lookup-only: true + # attempt to download again because in tags/PRs no cache is created - name: Clone third-party deps (deps/linux) if: steps.emu-deps-cache-step.outputs.cache-hit != 'true' uses: actions/checkout@v4 diff --git a/.github/workflows/build-win.yml b/.github/workflows/build-win.yml index 6abfef76..43e5e8b6 100644 --- a/.github/workflows/build-win.yml +++ b/.github/workflows/build-win.yml @@ -24,8 +24,60 @@ env: THIRD_PARTY_BASE_DIR: 'third-party' jobs: + # this helps in manual runs, if build fails, then deps are saved + dependencies: + runs-on: windows-2022 + # cache but not for tags or PRs + # !tag && !pull_request + # also you could use this: github.event_name != 'pull_request' + if: | + !startsWith(github.ref, 'refs/tags/') && + !startsWith(github.ref, 'refs/pull/') + + steps: + # we need branch because it has build scripts + - name: Checkout branch + uses: actions/checkout@v4 + + - name: Lookup cache for deps + id: emu-deps-cache-step + uses: actions/cache@v3 + with: + key: ${{ env.DEPS_CACHE_KEY }} + path: ${{ env.DEPS_CACHE_DIR }} + lookup-only: true # don't restore cache if found + + - name: Clone third-party deps (deps/win) + if: steps.emu-deps-cache-step.outputs.cache-hit != 'true' + uses: actions/checkout@v4 + with: + ref: 'third-party/deps/win' + path: "${{env.THIRD_PARTY_BASE_DIR}}/deps/win" + + - name: Clone third-party deps (deps/common) + if: steps.emu-deps-cache-step.outputs.cache-hit != 'true' + uses: actions/checkout@v4 + with: + ref: 'third-party/deps/common' + path: "${{env.THIRD_PARTY_BASE_DIR}}/deps/common" + + - name: Clone third-party deps (common/win) + if: steps.emu-deps-cache-step.outputs.cache-hit != 'true' + uses: actions/checkout@v4 + with: + ref: 'third-party/common/win' + path: "${{env.THIRD_PARTY_BASE_DIR}}/common/win" + + - name: Build deps + if: steps.emu-deps-cache-step.outputs.cache-hit != 'true' + shell: cmd + working-directory: ${{ github.workspace }} + run: build_win_deps.bat + + build: runs-on: windows-2022 + needs: [ dependencies ] steps: - name: Checkout branch @@ -44,6 +96,7 @@ jobs: key: ${{ env.DEPS_CACHE_KEY }} path: ${{ env.DEPS_CACHE_DIR }} + # attempt to download again because in tags/PRs no cache is created - name: Clone third-party deps (deps/win) if: steps.emu-deps-cache-step.outputs.cache-hit != 'true' uses: actions/checkout@v4