Skip to content

Commit

Permalink
feat: add support for caching
Browse files Browse the repository at this point in the history
```yaml
  - uses: cashapp/activate-hermit@v1
    with:
      cache: true
```

This necessitated switching to a composite action, and I couldn't figure
out a way to keep the existing JS action when using it. TBH I think the
script approach is a bit neater anyway.

Also introduced a CI test for the action, and verified it with `act`.
  • Loading branch information
alecthomas committed Dec 21, 2023
1 parent 94aa5ac commit 79cd3a9
Show file tree
Hide file tree
Showing 16 changed files with 45 additions and 3,028 deletions.
32 changes: 0 additions & 32 deletions .github/workflows/build.yml

This file was deleted.

17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: CI

on:
push:
branches:
- main
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: ./
with:
cache: true
3 changes: 3 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Test the action using act
test:
act --container-architecture linux/amd64
24 changes: 22 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ inputs:
description: 'The directory with the Hermit environment (contains `bin/hermit`)'
required: false
default: './'
cache:
description: 'If "true", installed Hermit packages will be cached.'
required: false
default: 'false'
runs:
using: 'node16'
main: 'dist/index.js'
using: composite
steps:
- if: ${{ inputs.cache == 'true' }}
uses: theowenyoung/folder-hash@v3
id: bin-hash
working-directory: ${{ inputs.working-directory }}
with:
path: ./bin
- if: ${{ inputs.cache == 'true' }}
uses: actions/cache@v3
with:
path: ${{ runner.os == 'macOS' && '~/Library/Caches/hermit/pkg' || '~/.cache/hermit/pkg' }}
key: ${{ runner.os }}-hermit-cache-${{ steps.bin-hash.outputs.hash }}
restore-keys: |
${{ runner.os }}-hermit-cache-
- shell: bash
working-directory: ${{ inputs.working-directory }}
run: ./bin/hermit env --raw >> "$GITHUB_ENV"
File renamed without changes.
1 change: 1 addition & 0 deletions bin/.just-1.16.0.pkg
1 change: 1 addition & 0 deletions bin/act
1 change: 0 additions & 1 deletion bin/corepack

This file was deleted.

1 change: 1 addition & 0 deletions bin/just
1 change: 0 additions & 1 deletion bin/node

This file was deleted.

1 change: 0 additions & 1 deletion bin/npm

This file was deleted.

1 change: 0 additions & 1 deletion bin/npx

This file was deleted.

Loading

0 comments on commit 79cd3a9

Please sign in to comment.