From 53dd59a4a1aa67c38afe1375140a58c2c9c87346 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon, 6 Jul 2026 15:38:03 +0200 Subject: [PATCH] Remove cleanup caches workflows --- .github/workflows/cache_ci.yaml | 122 -------------------------------- .github/workflows/cache_pr.yaml | 53 -------------- .github/workflows/ci.yaml | 11 --- 3 files changed, 186 deletions(-) delete mode 100644 .github/workflows/cache_ci.yaml delete mode 100644 .github/workflows/cache_pr.yaml diff --git a/.github/workflows/cache_ci.yaml b/.github/workflows/cache_ci.yaml deleted file mode 100644 index 55c8c52a..00000000 --- a/.github/workflows/cache_ci.yaml +++ /dev/null @@ -1,122 +0,0 @@ -name: Delete Caches (CI) - -on: - workflow_run: - workflows: - - CI - types: - - completed - -jobs: - delete: - name: Delete caches - runs-on: ubuntu-latest - permissions: - actions: write - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ARTIFACT_NAME: cleanup_cache - ALL_VENV_PREFIXES: venv, venv-base, pre-commit - ALL_PYTHON_VERSIONS: 3.10, 3.11, 3.12, 3.13, 3.14 - steps: - - name: Download workflow artifact - id: download-artifact - run: | - all_artifacts=$(gh api \ - -H "Accept: application/vnd.github+json" \ - /repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}/artifacts) - - ids=$(echo "$all_artifacts" | jq \ - --arg key "$ARTIFACT_NAME" \ - '.artifacts[] | select(.name == $key) | [.id]') - - count=$(echo "$ids" | jq 'length') - if [[ "$count" -eq 0 ]]; then - echo "result=skip" >> $GITHUB_OUTPUT - exit - fi - - id=$(echo "$ids" | jq '.[0]') - echo "Download artifact with id: $id ..." - gh api \ - -H "Accept: application/vnd.github+json" \ - /repos/${{ github.repository }}/actions/artifacts/$id/zip >> "$ARTIFACT_NAME.zip" - - unzip "$ARTIFACT_NAME.zip" - - name: Identify caches to delete - id: identify-caches - if: steps.download-artifact.outputs.result != 'skip' - run: | - sort="last_accessed_at" - cache_count=0 - - all_versions=$(echo $ALL_PYTHON_VERSIONS | tr -d ",") - venv_prefixes=$(echo $ALL_VENV_PREFIXES | tr -d ",") - - inputs=($(cat "$ARTIFACT_NAME")) - ref="${inputs[0]}" - echo "ref: $ref" - - res=$(gh api --paginate \ - -H "Accept: application/vnd.github+json" \ - /repos/${{ github.repository }}/actions/caches?sort=$sort) - - res_count=$(echo "$res" | jq '.actions_caches | length') - if [[ "$res_count" -eq 0 ]]; then exit; fi - - for prefix in $venv_prefixes; do - index=1 - version_count=0 - - for version in $all_versions; do - # Only check all versions for prefix 'venv' - if [[ "$version_count" -eq 1 && "$prefix" != "venv" ]]; then - break - fi - (( version_count += 1 )) - - key=".+-$version.+-$prefix-\d" - echo "Check key regex: $key ..." - if [[ "$index" -eq 1 ]]; then - echo "..Keep last cache entry" - fi - - # Select all cache keys which match the ref and key regex - targets=$(echo "$res" | jq \ - --arg ref "$ref" --arg key "$key" --arg index $index \ - '[.actions_caches[] - | select(.ref == $ref) - | select(.key | test($key))][$index | fromjson:][] - | del(.created_at, .size_in_bytes, .version)') - - num_ids=$(echo "$targets" | jq -s 'length') - if [[ "$num_ids" -eq 0 ]]; then continue; fi - echo "$targets" - - echo "$targets" | jq '.id' >> cache_ids - cache_count=$(( cache_count + num_ids )) - done - done - - echo - echo "Found $cache_count caches to delete" - echo "cache_count=$cache_count" >> $GITHUB_OUTPUT - - name: Delete caches - if: steps.identify-caches.outputs.cache_count != '0' - run: | - del_count=0 - - num_ids=$(cat cache_ids | jq -s 'length') - echo "Found $num_ids caches to delete" - if [[ "$num_ids" -eq 0 ]]; then exit; fi - - for id in $(cat cache_ids); do - echo "Delete cache with id: $id ..." - gh api \ - --method DELETE \ - -H "Accept: application/vnd.github+json" \ - /repos/${{ github.repository }}/actions/caches/$id - (( del_count += 1 )) - done - - echo "Deleted $del_count caches" diff --git a/.github/workflows/cache_pr.yaml b/.github/workflows/cache_pr.yaml deleted file mode 100644 index d86b542b..00000000 --- a/.github/workflows/cache_pr.yaml +++ /dev/null @@ -1,53 +0,0 @@ -name: Delete Caches (PR) - -on: - pull_request_target: - types: [closed] - workflow_dispatch: - inputs: - pr-number: - description: "Closed PR number" - type: string - required: true - -jobs: - delete: - name: Delete caches - runs-on: ubuntu-latest - permissions: - actions: write - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - name: Delete caches - run: | - ref="refs/pull/${{ github.event.inputs.pr-number || github.event.number }}/merge" - sort="last_accessed_at" - del_count=0 - - res=$(gh api --paginate \ - -H "Accept: application/vnd.github+json" \ - /repos/${{ github.repository }}/actions/caches?sort=$sort) - - res_count=$(echo "$res" | jq '.actions_caches | length') - if [[ "$res_count" -eq 0 ]]; then exit; fi - - targets=$(echo "$res" | jq \ - --arg ref "$ref" \ - '.actions_caches[] | select(.ref == $ref) - | del(.created_at, .size_in_bytes, .version)') - targets_count=$(echo "$targets" | jq -s 'length') - if [[ "$targets_count" -eq 0 ]]; then exit; fi - echo "Found $targets_count caches" - echo "$targets" - - for id in $(echo "$targets" | jq '.id'); do - echo "Delete cache with id: $id ..." - gh api \ - --method DELETE \ - -H "Accept: application/vnd.github+json" \ - /repos/${{ github.repository }}/actions/caches/$id - (( del_count += 1 )) - done - - echo "Deleted $del_count caches" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9a01ccf5..86cd7e76 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -73,17 +73,6 @@ jobs: run: | . venv/bin/activate pre-commit install --install-hooks - - name: Prepare cleanup-cache artifact - run: | - ref="${{ github.ref }}" - - echo "ref: $ref" - echo "$ref" >> cleanup_cache - - name: Upload cleanup-cache artifact - uses: actions/upload-artifact@v7.0.1 - with: - name: cleanup_cache - path: cleanup_cache formatting: name: Run pre-commit checks