Skip to content

Commit

Permalink
Hoist GH cache clearing into reusable action
Browse files Browse the repository at this point in the history
Signed-off-by: Hanno Becker <[email protected]>
  • Loading branch information
hanno-becker committed Sep 9, 2024
1 parent a2a9ead commit 0fce70e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 14 deletions.
31 changes: 31 additions & 0 deletions .github/actions/clear-cache/action.yml
Original file line number Diff line number Diff line change
@@ -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 }}
20 changes: 6 additions & 14 deletions .github/workflows/bench_ec2_reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0fce70e

Please sign in to comment.