From 3664c54e93acd1311b0156805dd271826ec89913 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Mon, 9 Sep 2024 04:53:07 +0100 Subject: [PATCH] Hoist GH cache clearing into reusable action Signed-off-by: Hanno Becker --- .github/actions/clear-cache/action.yml | 31 ++++++++++++++++++++++++ .github/workflows/bench_ec2_reusable.yml | 20 +++++---------- 2 files changed, 37 insertions(+), 14 deletions(-) create mode 100644 .github/actions/clear-cache/action.yml diff --git a/.github/actions/clear-cache/action.yml b/.github/actions/clear-cache/action.yml new file mode 100644 index 000000000..63ac4b07a --- /dev/null +++ b/.github/actions/clear-cache/action.yml @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 + +name: Clear GitHub cache entries +description: Removes entries from GitHub cache by key + +inputs: + key_prefix: + description: Fixed prefix of ID of Github cache entries that should be removed. + required: true + repository: + description: Name of the repository + required: true + gh_token: + description: Github access token to use + required: true + +runs: + using: composite + steps: + - name: List and remove cache entries + shell: bash + run: | + cache_keys=$(gh cache list -R ${{ env.REPO }} -k ${{ inputs.key_prefix }} | cut -f 1) + echo "Deleting nix-installer caches..." + for key in $cache_keys + do + gh cache -R ${{ env.REPO }} delete $key || echo "Could not remove $key" + done + env: + GH_TOKEN: ${{ inputs.gh_token }} + REPO: ${{ inputs.repository }} diff --git a/.github/workflows/bench_ec2_reusable.yml b/.github/workflows/bench_ec2_reusable.yml index 8bdf596d7..2ea231c0a 100644 --- a/.github/workflows/bench_ec2_reusable.yml +++ b/.github/workflows/bench_ec2_reusable.yml @@ -44,17 +44,13 @@ jobs: label: ${{ steps.start-ec2-runner.outputs.label }} ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }} steps: + - uses: actions/checkout@v4 - name: Clear nix-installer action cache - run: | - cache_keys=$(gh cache list -R ${{ env.REPO }} -k determinatesystem-nix-installer-aarch64-linux | cut -f 1) - echo "Deleting nix-installer caches..." - for key in $cache_keys - do - gh cache -R ${{ env.REPO }} delete $key - done - env: - GH_TOKEN: ${{ secrets.AWS_GITHUB_TOKEN }} - REPO: ${{ github.repository }} + uses: ./.github/actions/clear-cache + with: + key_prefix: determinatesystem-nix-installer- + repository: ${{ github.repository }} + token: ${{ secrets.AWS_GITHUB_TOKEN }} - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 with: @@ -98,10 +94,6 @@ jobs: shell: nix develop .#ci -c bash -e {0} run: | tests bench -c PERF --cflags "${{ inputs.cflags }}" --arch-flags "${{ inputs.archflags }}" -v --output output.json - - name: Dump benchmark - if: ${{ inputs.store_results != 'true' }} - run: | - cat output.json - name: Store benchmark result if: ${{ inputs.store_results == 'true' }} uses: benchmark-action/github-action-benchmark@v1