Skip to content

Commit

Permalink
*: initial scaffolding for the stickydisk action
Browse files Browse the repository at this point in the history
  • Loading branch information
adityamaru committed Dec 11, 2024
1 parent c27f005 commit 11386bb
Show file tree
Hide file tree
Showing 12 changed files with 64,608 additions and 23,044 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Basic Sticky Disk Test
on:
workflow_dispatch:
push:
pull_request:

jobs:
test-sticky-disk:
name: Test Sticky Disk
runs-on: blacksmith-staging
steps:
- name: Mount First Sticky Disk
uses: useblacksmith/stickydisk@initial-commit
with:
key: foo
path: /shouldseethis

- name: List first directory if exists
run: |
if [ -d "/shouldseethis" ]; then
ls -la /shouldseethis
fi
- name: Write test file to first disk
run: sudo sh -c 'echo "Hello from first sticky disk" > /shouldseethis/test.txt'

- name: Mount Second Sticky Disk
uses: useblacksmith/stickydisk@initial-commit
with:
key: bar
path: /seconddisk

- name: List second directory if exists
run: |
if [ -d "/seconddisk" ]; then
ls -la /seconddisk
fi
- name: Write test file to second disk
run: sudo sh -c 'echo "Hello from second sticky disk" > /seconddisk/test.txt'

# - name: Mount Third Sticky Disk
# uses: useblacksmith/stickydisk@initial-commit
# with:
# key: baz
# path: /thirddisk

# - name: List third directory if exists
# run: |
# if [ -d "/thirddisk" ]; then
# ls -la /thirddisk
# fi

# - name: Write test file to third disk
# run: sudo sh -c 'echo "Hello from third sticky disk" > /thirddisk/test.txt'

# - name: Mount First Sticky Disk Again
# uses: useblacksmith/stickydisk@initial-commit
# with:
# key: foo
# path: /shouldseethis_again

# - name: List first directory again if exists
# run: |
# if [ -d "/shouldseethis_again" ]; then
# ls -la /shouldseethis_again
# fi

# - name: Write test file to first disk again
# run: sudo sh -c 'echo "Hello again from first sticky disk" > /shouldseethis_again/test2.txt'
86 changes: 18 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,76 +1,26 @@
# Blacksmith Cache Delete Action
# Blacksmith Sticky Disk Action

A GitHub Action to delete caches from Blacksmith's cache storage. This action allows you to delete either a specific cache version or all versions of a cache key. This action only works Blacksmith runners.
A GitHub Action that helps persist state written to disk across jobs. Each sticky disk is backed by local NVMe storage and is formmatted as an ext4 filesystem.

## Usage

```yaml
- name: Delete Cache
uses: useblacksmith/cache-delete@v1
with:
key: Linux-composer-ecf6e2e236589e4d34ba89662b6bc2afe8e15237cd19a13df9dc0cb599ff4826
version: v213asda2cf # Optional: specific version to delete
```
## Inputs
| Input | Description | Required | Default |
| --------- | --------------------------------------- | -------- | ------- |
| `key` | The cache key to delete | No\* | - |
| `version` | Specific version of the cache to delete | No | - |
| `prefix` | Treat key as a prefix for bulk deletion | No | false |

\* Required unless `prefix` is true, in which case it can be empty to match all cache keys

## Examples

### Delete All Versions of a Cache

```yaml
- name: Delete All Cache Versions
uses: useblacksmith/cache-delete@v1
with:
key: npm-cache
```
Some common use cases of this action include:

### Delete a Specific Cache Version
- Caching Docker images to minimize pull and extract times
- Caching build artifacts such as NPM packages (egs: node_modules, yarn.lock, etc)
- Caching Bazel build artifacts
- Caching large GitHub repositories to minimize checkout times

```yaml
- name: Delete Specific Cache Version
uses: useblacksmith/cache-delete@v1
with:
key: npm-cache
version: v1.0
```

### Delete All Caches with a Prefix

```yaml
- name: Delete All npm Caches
uses: useblacksmith/cache-delete@v1
with:
key: npm-
prefix: true
```

### Delete All Caches
## Usage

```yaml
- name: Delete All Caches
uses: useblacksmith/cache-delete@v1
with:
key: ""
prefix: true
jobs:
build:
runs-on: blacksmith
steps:
- name: Cache NPM packages
uses: useblacksmith/stickydisk-action@master
with:
key: ${{ github.repository }}-npm-cache
path: ~/.node_modules
```
## Error Handling

The action will:

- Fail if the cache deletion request fails (non-404 error)
- Log a message if the cache is not found (404)
- Successfully complete if the cache is deleted

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
Each sticky disk is uniquely identified by a key. The sticky disk will be mounted at the specified path. Once the job completes, the sticky disk will be unmounted and committed for future invocations. At the moment, customers can use up to 5 sticky disks in a single GitHub Action job.
21 changes: 9 additions & 12 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
name: "Delete Blacksmith Cache"
author: Aayush Shah
description: "Deletes a cache or specific cache version from Blacksmith"
name: "Blacksmith Sticky Disk"
author: Aditya Maru
description: "Creates a sticky disk on Blacksmith"
branding:
icon: folder-plus
color: black
inputs:
key:
description: "The cache key to delete"
required: false
version:
description: "Specific version of the cache to delete (optional)"
required: false
prefix:
description: "Treat key as a prefix for bulk deletion"
required: false
default: "false"
description: "A unique key to identify the sticky disk"
required: true
path:
description: "The path at which to mount the sticky disk"
required: true
runs:
using: "node20"
main: "dist/index.js"
post: "dist/post/index.js"
Loading

0 comments on commit 11386bb

Please sign in to comment.