From fd6d09caaa2dc2ba7a27e6b5bbffcd5e854754eb Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Fri, 15 Apr 2022 11:21:06 +0400 Subject: [PATCH] Fix cache update for the actions The caching action doesn't update the cache when cache hit is happenned. This could be fixed by having unique keys for every cache change and using restore-keys to find these caches. --- .github/workflows/mac.yml | 7 +++++-- .github/workflows/win.yml | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 2de4b19de..fd435494f 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -51,6 +51,7 @@ jobs: env: UPLOAD_ARTIFACT: "false" ONLY_CACHE: "false" + PREPARE_PATH: "Telegram/build/prepare/prepare.py" steps: - name: Get repository name. @@ -78,14 +79,16 @@ jobs: uses: actions/cache@v2 with: path: ThirdParty - key: ${{ runner.OS }}-third-party + key: ${{ runner.OS }}-third-party-${{ hashFiles(format('{0}/{1}', env.REPO_NAME, env.PREPARE_PATH)) }} + restore-keys: ${{ runner.OS }}-third-party- - name: Libraries cache. id: cache-libs uses: actions/cache@v2 with: path: Libraries - key: ${{ runner.OS }}-libs + key: ${{ runner.OS }}-libs-${{ hashFiles(format('{0}/{1}', env.REPO_NAME, env.PREPARE_PATH)) }} + restore-keys: ${{ runner.OS }}-libs- - name: Libraries. run: | diff --git a/.github/workflows/win.yml b/.github/workflows/win.yml index d65db1c36..7490ae0ad 100644 --- a/.github/workflows/win.yml +++ b/.github/workflows/win.yml @@ -58,7 +58,6 @@ jobs: defaults: run: shell: cmd - working-directory: ${{ github.workspace }} steps: - name: Prepare directories. @@ -98,6 +97,8 @@ jobs: echo "C:\\Program Files\\NASM\\" >> $GITHUB_PATH echo "C:\\ProgramData\\chocolatey\\lib\\ninja\\tools\\" >> $GITHUB_PATH + echo "CACHE_KEY=$(sha256sum $TBUILD/$REPO_NAME/$PREPARE_PATH | awk '{ print $1 }')" >> $GITHUB_ENV + echo "Configurate git for cherry-picks." git config --global user.email "you@example.com" git config --global user.name "Sample" @@ -112,7 +113,8 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.TBUILD }}/Libraries - key: ${{ runner.OS }}-libs + key: ${{ runner.OS }}-libs-${{ env.CACHE_KEY }} + restore-keys: ${{ runner.OS }}-libs- - name: Libraries. env: