From f3b0578a5e4b873c8d9f561033fdba534f568d6e Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 13 Sep 2023 13:00:21 +0200 Subject: [PATCH 01/33] init --- .github/workflows/cleanup_cache.yml | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/cleanup_cache.yml diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml new file mode 100644 index 00000000000000..7c7c0f8bb08e5b --- /dev/null +++ b/.github/workflows/cleanup_cache.yml @@ -0,0 +1,33 @@ +name: cleanup caches +on: + pull_request: + types: + - closed + +jobs: + cleanup: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Cleanup + run: | + gh extension install actions/gh-actions-cache + + REPO=${{ github.repository }} + BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge" + + echo "Fetching list of cache key" + cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) + + ## Setting this to not fail the workflow while deleting cache keys. + set +e + echo "Deleting caches..." + for cacheKey in $cacheKeysForPR + do + gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm + done + echo "Done" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From abefbb4e10b645f3aeca259ea51851cb33456c87 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 13 Sep 2023 13:18:44 +0200 Subject: [PATCH 02/33] master caches --- .github/workflows/cleanup_cache.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index 7c7c0f8bb08e5b..fa96d49dc644bd 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -18,7 +18,7 @@ jobs: REPO=${{ github.repository }} BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge" - echo "Fetching list of cache key" + echo "Fetching list of cache key for ${BRANCH}" cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) ## Setting this to not fail the workflow while deleting cache keys. @@ -28,6 +28,18 @@ jobs: do gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm done + + BRANCH="master" + echo "Fetching list of cache key for ${BRANCH}" + cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) + + ## Setting this to not fail the workflow while deleting cache keys. + set +e + echo "Deleting caches..." + for cacheKey in "${cacheKeysForPR[@]::${#cacheKeysForPR[@]}-1}" + do + gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm + done echo "Done" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 37a773bc37960b930cfce41234a56fac72c883cb Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 13 Sep 2023 13:36:30 +0200 Subject: [PATCH 03/33] update caches --- .github/workflows/linux.yml | 6 +++--- src/plugins/intel_cpu/thirdparty/mlas | 2 +- src/plugins/intel_cpu/thirdparty/onednn | 2 +- thirdparty/ade | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 2accc92cd1e293..f811a859cd13a2 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -130,9 +130,9 @@ jobs: max-size: "2000M" # Should save cache only if run in the master branch of the base repo # github.ref_name is 'ref/PR_#' in case of the PR, and 'branch_name' when executed on push - save: ${{ github.ref_name == 'master' && 'true' || 'false' }} + # save: ${{ github.ref_name == 'master' && 'true' || 'false' }} verbose: 2 - key: linux-ubuntu + key: linux-ubuntu-${{ github.ref_name == 'master' && github.sha || github.ref_name }} restore-keys: | linux-ubuntu @@ -780,7 +780,7 @@ jobs: uses: actions/cache@v3 with: path: ${{ env.PARALLEL_TEST_CACHE }} - key: ${{ runner.os }}-tests-functional-cpu-cache + key: ${{ runner.os }}-tests-functional-cpu-stamp-${{ github.ref_name == 'master' && github.sha || github.ref_name }} - name: Intel CPU plugin func tests (parallel) run: | diff --git a/src/plugins/intel_cpu/thirdparty/mlas b/src/plugins/intel_cpu/thirdparty/mlas index c7c8a631315000..8ed1c80deb0607 160000 --- a/src/plugins/intel_cpu/thirdparty/mlas +++ b/src/plugins/intel_cpu/thirdparty/mlas @@ -1 +1 @@ -Subproject commit c7c8a631315000f17c650af34431009d2f22129c +Subproject commit 8ed1c80deb0607530b3bef23a797335c09cebe1b diff --git a/src/plugins/intel_cpu/thirdparty/onednn b/src/plugins/intel_cpu/thirdparty/onednn index 3110963434d866..ae825539bd850d 160000 --- a/src/plugins/intel_cpu/thirdparty/onednn +++ b/src/plugins/intel_cpu/thirdparty/onednn @@ -1 +1 @@ -Subproject commit 3110963434d8662e93b3cdafc9bf6b41235aa602 +Subproject commit ae825539bd850d1ad5c83d4bb0d56c65d46d5842 diff --git a/thirdparty/ade b/thirdparty/ade index 50ff2423e234d8..58b2595a1a95cc 160000 --- a/thirdparty/ade +++ b/thirdparty/ade @@ -1 +1 @@ -Subproject commit 50ff2423e234d8e340de7ce959b920f6c8c7fe79 +Subproject commit 58b2595a1a95cc807be8bf6222f266a9a1f393a9 From b701eae266cbd962b9c2fc3040082ab69a512597 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 13 Sep 2023 13:39:44 +0200 Subject: [PATCH 04/33] fixed pr --- src/plugins/intel_cpu/thirdparty/mlas | 2 +- src/plugins/intel_cpu/thirdparty/onednn | 2 +- thirdparty/ade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/intel_cpu/thirdparty/mlas b/src/plugins/intel_cpu/thirdparty/mlas index 8ed1c80deb0607..c7c8a631315000 160000 --- a/src/plugins/intel_cpu/thirdparty/mlas +++ b/src/plugins/intel_cpu/thirdparty/mlas @@ -1 +1 @@ -Subproject commit 8ed1c80deb0607530b3bef23a797335c09cebe1b +Subproject commit c7c8a631315000f17c650af34431009d2f22129c diff --git a/src/plugins/intel_cpu/thirdparty/onednn b/src/plugins/intel_cpu/thirdparty/onednn index ae825539bd850d..3110963434d866 160000 --- a/src/plugins/intel_cpu/thirdparty/onednn +++ b/src/plugins/intel_cpu/thirdparty/onednn @@ -1 +1 @@ -Subproject commit ae825539bd850d1ad5c83d4bb0d56c65d46d5842 +Subproject commit 3110963434d8662e93b3cdafc9bf6b41235aa602 diff --git a/thirdparty/ade b/thirdparty/ade index 58b2595a1a95cc..50ff2423e234d8 160000 --- a/thirdparty/ade +++ b/thirdparty/ade @@ -1 +1 @@ -Subproject commit 58b2595a1a95cc807be8bf6222f266a9a1f393a9 +Subproject commit 50ff2423e234d8e340de7ce959b920f6c8c7fe79 From baaaa968f81c08b0b777dd64ac47ec7f2d3f9deb Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 13 Sep 2023 14:21:18 +0200 Subject: [PATCH 05/33] changed permissions --- .github/workflows/cleanup_cache.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index fa96d49dc644bd..76a58ad69bbcc9 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -4,6 +4,9 @@ on: types: - closed +permissions: + actions: write + jobs: cleanup: runs-on: ubuntu-latest From 5cd3391563b431f298d87825644b63057bc2c5cf Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 13 Sep 2023 15:22:04 +0200 Subject: [PATCH 06/33] all permissions --- .github/workflows/cleanup_cache.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index 76a58ad69bbcc9..800f460a509e21 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -4,8 +4,8 @@ on: types: - closed -permissions: - actions: write + permissions: + actions: write-all jobs: cleanup: From 35c6a9005330e3eb7da690a2c1df6f54d0de490e Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 13 Sep 2023 18:18:55 +0200 Subject: [PATCH 07/33] changed perms --- .github/workflows/cleanup_cache.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index 800f460a509e21..18430f12bb0631 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -4,12 +4,13 @@ on: types: - closed - permissions: - actions: write-all - jobs: cleanup: runs-on: ubuntu-latest + + permissions: + actions: write-all + steps: - name: Check out code uses: actions/checkout@v3 From ad03019049820603673ec775881ae3bc0a33f48d Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 13 Sep 2023 18:32:20 +0200 Subject: [PATCH 08/33] fixed perms --- .github/workflows/cleanup_cache.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index 18430f12bb0631..f257c244793280 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -8,8 +8,7 @@ jobs: cleanup: runs-on: ubuntu-latest - permissions: - actions: write-all + permissions: write-all steps: - name: Check out code From 8b10af5f897d260d5acc464f78ee5ea17c24edbc Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 13 Sep 2023 18:41:02 +0200 Subject: [PATCH 09/33] removed token --- .github/workflows/cleanup_cache.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index f257c244793280..26d3a898e462f4 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -44,5 +44,5 @@ jobs: gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm done echo "Done" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + # env: + # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From c8a65ccceee1cedd789e7ef7cbfe4a7935f1aaf0 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 13 Sep 2023 18:57:25 +0200 Subject: [PATCH 10/33] minimize permissions --- .github/workflows/cleanup_cache.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index 26d3a898e462f4..06a0b4db577cee 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -8,7 +8,10 @@ jobs: cleanup: runs-on: ubuntu-latest - permissions: write-all + permissions: + # `actions:write` permission is required to delete caches + actions: write + contents: read steps: - name: Check out code @@ -44,5 +47,5 @@ jobs: gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm done echo "Done" - # env: - # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From b15766e69957abd15bd6f99e0d990c8bffbd7ec9 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 13 Sep 2023 19:06:03 +0200 Subject: [PATCH 11/33] disable timestamp --- .github/workflows/linux.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index f811a859cd13a2..84882563381885 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -132,6 +132,7 @@ jobs: # github.ref_name is 'ref/PR_#' in case of the PR, and 'branch_name' when executed on push # save: ${{ github.ref_name == 'master' && 'true' || 'false' }} verbose: 2 + append-timestamp: false key: linux-ubuntu-${{ github.ref_name == 'master' && github.sha || github.ref_name }} restore-keys: | linux-ubuntu From 2528d9b942c3158d28fca37e25fdeacd05d09c4a Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 14 Sep 2023 09:39:15 +0200 Subject: [PATCH 12/33] debug --- .github/workflows/cleanup_cache.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index 06a0b4db577cee..b744dbf94e1184 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -38,14 +38,14 @@ jobs: BRANCH="master" echo "Fetching list of cache key for ${BRANCH}" cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) - + echo "${cacheKeysForPR[*]}" ## Setting this to not fail the workflow while deleting cache keys. set +e - echo "Deleting caches..." - for cacheKey in "${cacheKeysForPR[@]::${#cacheKeysForPR[@]}-1}" - do - gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm - done + # echo "Deleting caches..." + # for cacheKey in "${cacheKeysForPR[@]::${#cacheKeysForPR[@]}-1}" + # do + # gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm + # done echo "Done" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 1b9f0810e3886dce02a06465f8bcb15aa71873d9 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 14 Sep 2023 10:02:56 +0200 Subject: [PATCH 13/33] debug --- .github/workflows/cleanup_cache.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index b744dbf94e1184..7a77e227bdb5a1 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -41,11 +41,12 @@ jobs: echo "${cacheKeysForPR[*]}" ## Setting this to not fail the workflow while deleting cache keys. set +e - # echo "Deleting caches..." - # for cacheKey in "${cacheKeysForPR[@]::${#cacheKeysForPR[@]}-1}" - # do - # gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm - # done + echo "Deleting caches..." + for cacheKey in ${cacheKeysForPR[@]::${#cacheKeysForPR[@]}-1} + do + # gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm + echo ";{cacheKey}" + done echo "Done" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 428ae06222e44147c28939511dedcf9636957a73 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 14 Sep 2023 10:05:23 +0200 Subject: [PATCH 14/33] typo --- .github/workflows/cleanup_cache.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index 7a77e227bdb5a1..99c45c6beed378 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -45,7 +45,7 @@ jobs: for cacheKey in ${cacheKeysForPR[@]::${#cacheKeysForPR[@]}-1} do # gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm - echo ";{cacheKey}" + echo "${cacheKey}" done echo "Done" env: From 2704bf8b0438b8a78145ae04438864fe1d2a634a Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 14 Sep 2023 10:09:23 +0200 Subject: [PATCH 15/33] sliced --- .github/workflows/cleanup_cache.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index 99c45c6beed378..b37aee3f849a9e 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -42,7 +42,7 @@ jobs: ## Setting this to not fail the workflow while deleting cache keys. set +e echo "Deleting caches..." - for cacheKey in ${cacheKeysForPR[@]::${#cacheKeysForPR[@]}-1} + for cacheKey in ${cacheKeysForPR[@]:1} do # gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm echo "${cacheKey}" From 92a4a127bbf5bfb45b269c913aebb78cfa76cf6d Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 14 Sep 2023 10:17:27 +0200 Subject: [PATCH 16/33] fix --- .github/workflows/cleanup_cache.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index b37aee3f849a9e..cb4fd7d89eaa0e 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -39,10 +39,12 @@ jobs: echo "Fetching list of cache key for ${BRANCH}" cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) echo "${cacheKeysForPR[*]}" + cacheKeysForPRSliced = ("${cacheKeysForPR[@]:1}") + echo "${cacheKeysForPRSliced[*]}" ## Setting this to not fail the workflow while deleting cache keys. set +e echo "Deleting caches..." - for cacheKey in ${cacheKeysForPR[@]:1} + for cacheKey in cacheKeysForPRSliced do # gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm echo "${cacheKey}" From 296e8421976169112d4bc218c757df714c68cb8f Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 14 Sep 2023 10:20:57 +0200 Subject: [PATCH 17/33] typo --- .github/workflows/cleanup_cache.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index cb4fd7d89eaa0e..cd2d38f403a290 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -39,7 +39,7 @@ jobs: echo "Fetching list of cache key for ${BRANCH}" cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) echo "${cacheKeysForPR[*]}" - cacheKeysForPRSliced = ("${cacheKeysForPR[@]:1}") + cacheKeysForPRSliced=("${cacheKeysForPR[@]:1}") echo "${cacheKeysForPRSliced[*]}" ## Setting this to not fail the workflow while deleting cache keys. set +e From a7e474f7d5ab30032888e60f9dd4e94b422185e5 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 14 Sep 2023 10:23:58 +0200 Subject: [PATCH 18/33] debug --- .github/workflows/cleanup_cache.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index cd2d38f403a290..6d099e2469839a 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -39,12 +39,12 @@ jobs: echo "Fetching list of cache key for ${BRANCH}" cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) echo "${cacheKeysForPR[*]}" - cacheKeysForPRSliced=("${cacheKeysForPR[@]:1}") + cacheKeysForPRSliced=("${cacheKeysForPR[*]:1}") echo "${cacheKeysForPRSliced[*]}" ## Setting this to not fail the workflow while deleting cache keys. set +e echo "Deleting caches..." - for cacheKey in cacheKeysForPRSliced + for cacheKey in $cacheKeysForPRSliced do # gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm echo "${cacheKey}" From db7bfe75a6c2f381ffcb3f2104af273d99f5e26c Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 14 Sep 2023 10:27:45 +0200 Subject: [PATCH 19/33] debug --- .github/workflows/cleanup_cache.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index 6d099e2469839a..ede7fbb3ca3730 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -38,9 +38,9 @@ jobs: BRANCH="master" echo "Fetching list of cache key for ${BRANCH}" cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) - echo "${cacheKeysForPR[*]}" - cacheKeysForPRSliced=("${cacheKeysForPR[*]:1}") - echo "${cacheKeysForPRSliced[*]}" + echo "${cacheKeysForPR[@]}" + cacheKeysForPRSliced=("${cacheKeysForPR[@]:1}") + echo "${cacheKeysForPRSliced[@]}" ## Setting this to not fail the workflow while deleting cache keys. set +e echo "Deleting caches..." From 461ce4b46ec9139a520b815068bd2387e67438b0 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 14 Sep 2023 13:45:47 +0200 Subject: [PATCH 20/33] test --- .github/workflows/cleanup_cache.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index ede7fbb3ca3730..7bc11dab1d67b4 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -37,7 +37,7 @@ jobs: BRANCH="master" echo "Fetching list of cache key for ${BRANCH}" - cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) + cacheKeysForPR=( $(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1) ) echo "${cacheKeysForPR[@]}" cacheKeysForPRSliced=("${cacheKeysForPR[@]:1}") echo "${cacheKeysForPRSliced[@]}" From 08e6e36288d7e17cf901967828c7328025204394 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 14 Sep 2023 13:52:09 +0200 Subject: [PATCH 21/33] test --- .github/workflows/cleanup_cache.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index 7bc11dab1d67b4..e12142391dc6ab 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -36,15 +36,16 @@ jobs: done BRANCH="master" + KEY="ccache-linux-ubuntu" echo "Fetching list of cache key for ${BRANCH}" - cacheKeysForPR=( $(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1) ) + cacheKeysForPR=( $(gh actions-cache list -R $REPO -B $BRANCH -L 100 --key $KEY--sort created-at --order desc | cut -f 1) ) echo "${cacheKeysForPR[@]}" cacheKeysForPRSliced=("${cacheKeysForPR[@]:1}") echo "${cacheKeysForPRSliced[@]}" ## Setting this to not fail the workflow while deleting cache keys. set +e echo "Deleting caches..." - for cacheKey in $cacheKeysForPRSliced + for cacheKey in ${cacheKeysForPRSliced[@]} do # gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm echo "${cacheKey}" From 1b93ef094ea313c3a3a66c6550fde458de77cac9 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 14 Sep 2023 13:54:47 +0200 Subject: [PATCH 22/33] fixed command --- .github/workflows/cleanup_cache.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index e12142391dc6ab..5ef0be3618f73c 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -38,7 +38,7 @@ jobs: BRANCH="master" KEY="ccache-linux-ubuntu" echo "Fetching list of cache key for ${BRANCH}" - cacheKeysForPR=( $(gh actions-cache list -R $REPO -B $BRANCH -L 100 --key $KEY--sort created-at --order desc | cut -f 1) ) + cacheKeysForPR=( $(gh actions-cache list -R $REPO -B $BRANCH -L 100 --key $KEY --sort created-at --order desc | cut -f 1) ) echo "${cacheKeysForPR[@]}" cacheKeysForPRSliced=("${cacheKeysForPR[@]:1}") echo "${cacheKeysForPRSliced[@]}" From 7e930ba86b23328f2caa8e8b5ee50f6e36f006cd Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 14 Sep 2023 14:00:01 +0200 Subject: [PATCH 23/33] test --- .github/workflows/cleanup_cache.yml | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index 5ef0be3618f73c..1b8f4505729f4f 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -36,20 +36,24 @@ jobs: done BRANCH="master" - KEY="ccache-linux-ubuntu" - echo "Fetching list of cache key for ${BRANCH}" - cacheKeysForPR=( $(gh actions-cache list -R $REPO -B $BRANCH -L 100 --key $KEY --sort created-at --order desc | cut -f 1) ) - echo "${cacheKeysForPR[@]}" - cacheKeysForPRSliced=("${cacheKeysForPR[@]:1}") - echo "${cacheKeysForPRSliced[@]}" - ## Setting this to not fail the workflow while deleting cache keys. - set +e - echo "Deleting caches..." - for cacheKey in ${cacheKeysForPRSliced[@]} + KEYS=( "ccache-linux-ubuntu", "ccache-Build-linux-debian", "ccache-Build-linux-android") + for cache_key in ${KEYS[@]} do - # gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm - echo "${cacheKey}" + echo "Fetching list of cache key for ${BRANCH}" + cacheKeysForPR=( $(gh actions-cache list -R $REPO -B $BRANCH -L 100 --key $cache_key --sort created-at --order desc | cut -f 1) ) + echo "${cacheKeysForPR[@]}" + cacheKeysForPRSliced=("${cacheKeysForPR[@]:1}") + echo "${cacheKeysForPRSliced[@]}" + ## Setting this to not fail the workflow while deleting cache keys. + set +e + echo "Deleting caches..." + for cacheKey in ${cacheKeysForPRSliced[@]} + do + # gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm + echo "${cacheKey}" + done done + echo "Done" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 00bd66e39f0e96020d075b986fcbe3d465f8958b Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 14 Sep 2023 14:04:12 +0200 Subject: [PATCH 24/33] fixed array --- .github/workflows/cleanup_cache.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index 1b8f4505729f4f..40adb34e5dc5e2 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -36,10 +36,10 @@ jobs: done BRANCH="master" - KEYS=( "ccache-linux-ubuntu", "ccache-Build-linux-debian", "ccache-Build-linux-android") + KEYS=( "ccache-linux-ubuntu" "ccache-Build-linux-debian" "ccache-Build-linux-android") for cache_key in ${KEYS[@]} do - echo "Fetching list of cache key for ${BRANCH}" + echo "Fetching list of cache key ${cache_key} for ${BRANCH}" cacheKeysForPR=( $(gh actions-cache list -R $REPO -B $BRANCH -L 100 --key $cache_key --sort created-at --order desc | cut -f 1) ) echo "${cacheKeysForPR[@]}" cacheKeysForPRSliced=("${cacheKeysForPR[@]:1}") From 3b403a3c6e8601fe67a0d95d2e2fe3e40a0b6477 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 14 Sep 2023 14:11:14 +0200 Subject: [PATCH 25/33] exclude empty --- .github/workflows/cleanup_cache.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index 40adb34e5dc5e2..bc06759639a50d 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -46,12 +46,14 @@ jobs: echo "${cacheKeysForPRSliced[@]}" ## Setting this to not fail the workflow while deleting cache keys. set +e - echo "Deleting caches..." - for cacheKey in ${cacheKeysForPRSliced[@]} - do - # gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm - echo "${cacheKey}" - done + if "${#ArrayName[@]}" -gt "0"; then + echo "Deleting caches..." + for cacheKey in ${cacheKeysForPRSliced[@]} + do + # gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm + echo "${cacheKey}" + done + fi done echo "Done" From 23fced0e082c92b3bdcad620b7bc4c28ad495e1b Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 14 Sep 2023 14:13:59 +0200 Subject: [PATCH 26/33] fixed if --- .github/workflows/cleanup_cache.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index bc06759639a50d..2116e1df015a4a 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -46,7 +46,8 @@ jobs: echo "${cacheKeysForPRSliced[@]}" ## Setting this to not fail the workflow while deleting cache keys. set +e - if "${#ArrayName[@]}" -gt "0"; then + if [[ ${#ArrayName[@]} -gt 0 ]] + then echo "Deleting caches..." for cacheKey in ${cacheKeysForPRSliced[@]} do From 042b85256c574a1448e5116ba85f96085a8bf0ed Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 14 Sep 2023 14:23:17 +0200 Subject: [PATCH 27/33] test --- .github/workflows/cleanup_cache.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index 2116e1df015a4a..4e6c3c1ca37524 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -14,9 +14,6 @@ jobs: contents: read steps: - - name: Check out code - uses: actions/checkout@v3 - - name: Cleanup run: | gh extension install actions/gh-actions-cache @@ -36,7 +33,7 @@ jobs: done BRANCH="master" - KEYS=( "ccache-linux-ubuntu" "ccache-Build-linux-debian" "ccache-Build-linux-android") + KEYS=( "ccache-linux-ubuntu" "ccache-Build-linux-debian" "ccache-Build-linux-android" "ccache-Build-linux-arm64") for cache_key in ${KEYS[@]} do echo "Fetching list of cache key ${cache_key} for ${BRANCH}" From df225765155bc9843f5264298fa24f7a5085cf55 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 14 Sep 2023 14:41:16 +0200 Subject: [PATCH 28/33] one more case --- .github/workflows/cleanup_cache.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index 4e6c3c1ca37524..3d2cc0db2ac222 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -48,8 +48,11 @@ jobs: echo "Deleting caches..." for cacheKey in ${cacheKeysForPRSliced[@]} do + if [[ ! -z "$cacheKey" ]] + then # gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm echo "${cacheKey}" + fi done fi done From f74b2974e3c7c020a299bf4512d009b46d311e90 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 14 Sep 2023 14:45:13 +0200 Subject: [PATCH 29/33] fix --- .github/workflows/cleanup_cache.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index 3d2cc0db2ac222..2df67613354181 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -40,10 +40,10 @@ jobs: cacheKeysForPR=( $(gh actions-cache list -R $REPO -B $BRANCH -L 100 --key $cache_key --sort created-at --order desc | cut -f 1) ) echo "${cacheKeysForPR[@]}" cacheKeysForPRSliced=("${cacheKeysForPR[@]:1}") - echo "${cacheKeysForPRSliced[@]}" + ## echo "${cacheKeysForPRSliced[@]}" ## Setting this to not fail the workflow while deleting cache keys. set +e - if [[ ${#ArrayName[@]} -gt 0 ]] + if [[ ${#cacheKeysForPRSliced[@]} -gt 0 ]] then echo "Deleting caches..." for cacheKey in ${cacheKeysForPRSliced[@]} From 9698eeb12133c02bd03a8d9a6f288ed576788089 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 14 Sep 2023 15:04:57 +0200 Subject: [PATCH 30/33] split steps --- .github/workflows/cleanup_cache.yml | 54 ++++++++++++++++------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index 2df67613354181..0a72aba83dd3a4 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -9,54 +9,58 @@ jobs: runs-on: ubuntu-latest permissions: - # `actions:write` permission is required to delete caches actions: write contents: read + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository }} + BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge + steps: - - name: Cleanup + - name: Preconditions (Install gh-actions-cache) run: | gh extension install actions/gh-actions-cache - REPO=${{ github.repository }} - BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge" - - echo "Fetching list of cache key for ${BRANCH}" - cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) + - name: Cleanup PR's caches + run: | + echo "Fetching list of cache keys for ${BRANCH}" + CACHE_KEYS_FOR_PR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) - ## Setting this to not fail the workflow while deleting cache keys. set +e echo "Deleting caches..." - for cacheKey in $cacheKeysForPR + for CACHE_KEY in $CACHE_KEYS_FOR_PR do - gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm + gh actions-cache delete $CACHE_KEY -R $REPO -B $BRANCH --confirm done + echo "Done" - BRANCH="master" - KEYS=( "ccache-linux-ubuntu" "ccache-Build-linux-debian" "ccache-Build-linux-android" "ccache-Build-linux-arm64") - for cache_key in ${KEYS[@]} + - name: Cleanup master's caches + env: + BRANCH: master + KEYS: ( "ccache-linux-ubuntu" "ccache-Build-linux-debian" "ccache-Build-linux-android" "ccache-Build-linux-arm64") + run: | + for KEY in ${KEYS[@]} do - echo "Fetching list of cache key ${cache_key} for ${BRANCH}" - cacheKeysForPR=( $(gh actions-cache list -R $REPO -B $BRANCH -L 100 --key $cache_key --sort created-at --order desc | cut -f 1) ) - echo "${cacheKeysForPR[@]}" - cacheKeysForPRSliced=("${cacheKeysForPR[@]:1}") - ## echo "${cacheKeysForPRSliced[@]}" + echo "Fetching list of cache with key ${KEY} for ${BRANCH}" + CACHE_KEYS=( $(gh actions-cache list -R $REPO -B $BRANCH -L 100 --key $KEY --sort created-at --order desc | cut -f 1) ) + echo "${CACHE_KEYS[@]}" + CACHE_KEYS_OLD=("${CACHE_KEYS[@]:1}") + ## echo "${CACHE_KEYS_OLD[@]}" ## Setting this to not fail the workflow while deleting cache keys. set +e - if [[ ${#cacheKeysForPRSliced[@]} -gt 0 ]] + if [[ ${#CACHE_KEYS_OLD[@]} -gt 0 ]] then echo "Deleting caches..." - for cacheKey in ${cacheKeysForPRSliced[@]} + for CACHE_KEY in ${CACHE_KEYS_OLD[@]} do - if [[ ! -z "$cacheKey" ]] + if [[ ! -z "$CACHE_KEY" ]] then - # gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm - echo "${cacheKey}" + # gh actions-cache delete $CACHE_KEY -R $REPO -B $BRANCH --confirm + echo "${CACHE_KEY}" fi done fi done echo "Done" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 18822667b4097da59bd2a56ac0953990689f210f Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 14 Sep 2023 15:10:50 +0200 Subject: [PATCH 31/33] fix --- .github/workflows/cleanup_cache.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index 0a72aba83dd3a4..f06de01b6e1c70 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -38,7 +38,7 @@ jobs: - name: Cleanup master's caches env: BRANCH: master - KEYS: ( "ccache-linux-ubuntu" "ccache-Build-linux-debian" "ccache-Build-linux-android" "ccache-Build-linux-arm64") + KEYS: "ccache-linux-ubuntu" "ccache-Build-linux-debian" "ccache-Build-linux-android" "ccache-Build-linux-arm64" run: | for KEY in ${KEYS[@]} do From a9b922c88e5f4b7f4bf35c154c5b6bdbe92b371c Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 14 Sep 2023 15:13:11 +0200 Subject: [PATCH 32/33] test --- .github/workflows/cleanup_cache.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index f06de01b6e1c70..33d6bd77f4de31 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -38,7 +38,7 @@ jobs: - name: Cleanup master's caches env: BRANCH: master - KEYS: "ccache-linux-ubuntu" "ccache-Build-linux-debian" "ccache-Build-linux-android" "ccache-Build-linux-arm64" + KEYS: "ccache-linux-ubuntu ccache-Build-linux-debian ccache-Build-linux-android ccache-Build-linux-arm64" run: | for KEY in ${KEYS[@]} do From 95058d1b02c1d8683e37de33405ec1894e252f42 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 14 Sep 2023 16:07:02 +0200 Subject: [PATCH 33/33] small renaming --- .github/workflows/cleanup_cache.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cleanup_cache.yml b/.github/workflows/cleanup_cache.yml index 33d6bd77f4de31..f608d8a3ece4d5 100644 --- a/.github/workflows/cleanup_cache.yml +++ b/.github/workflows/cleanup_cache.yml @@ -1,4 +1,4 @@ -name: cleanup caches +name: Cleanup cache on: pull_request: types: @@ -44,10 +44,8 @@ jobs: do echo "Fetching list of cache with key ${KEY} for ${BRANCH}" CACHE_KEYS=( $(gh actions-cache list -R $REPO -B $BRANCH -L 100 --key $KEY --sort created-at --order desc | cut -f 1) ) - echo "${CACHE_KEYS[@]}" CACHE_KEYS_OLD=("${CACHE_KEYS[@]:1}") - ## echo "${CACHE_KEYS_OLD[@]}" - ## Setting this to not fail the workflow while deleting cache keys. + echo "${CACHE_KEYS_OLD[@]}" set +e if [[ ${#CACHE_KEYS_OLD[@]} -gt 0 ]] then @@ -56,11 +54,9 @@ jobs: do if [[ ! -z "$CACHE_KEY" ]] then - # gh actions-cache delete $CACHE_KEY -R $REPO -B $BRANCH --confirm - echo "${CACHE_KEY}" + gh actions-cache delete $CACHE_KEY -R $REPO -B $BRANCH --confirm fi done fi done - echo "Done"