Skip to content

🔧 chore(ci): Add disable-cache option to GitHub Actions workflow #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,17 @@ jobs:
with: {commit_message: Automatic distributive rebuild}

run-this-action: # non-existing files will not generate an error
name: 🚀 Run (${{ matrix.runs-on }}, ${{ matrix.version }})
name: 🚀 Run (${{ matrix.runs-on }}, ${{ matrix.version }}, !cache ${{ matrix.disable-cache }})
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
runs-on: [ubuntu-latest, macos-latest, windows-latest]
version: [4.0.0, 4.1.0, 4.3.0, 5.0.1, 6.0.0, 6.1.0, latest]
version: [4.0.0, 4.1.0, 4.3.0, 5.0.1, 6.0.0, latest]
disable-cache: [true, false]
steps:
- uses: actions/checkout@v4
- name: Run this action
uses: ./
with: {version: '${{ matrix.version }}'}
with: {version: '${{ matrix.version }}', disable-cache: '${{ matrix.disable-cache }}'}
- run: hurl --version
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
steps:
- uses: gacts/install-hurl@v1
#with:
# disable-cache: true # disable cache usage
# version: 1.2.0 # `latest` by default, but you can set a specific version to install

- run: hurl version # any hurl command can be executed
Expand All @@ -35,10 +36,11 @@ jobs:

The following inputs can be used as `step.with` keys:

| Name | Type | Default | Required | Description |
|----------------|:--------:|:---------------------:|:--------:|------------------------------------------------------------|
| `version` | `string` | `latest` | no | Hurl version to install |
| `github-token` | `string` | `${{ github.token }}` | no | GitHub token (for requesting the latest hurl version info) |
| Name | Type | Default | Required | Description |
|-----------------|:---------:|:---------------------:|:--------:|------------------------------------------------------------|
| `version` | `string` | `latest` | no | Hurl version to install |
| `disable-cache` | `boolean` | `false` | no | Disable cache usage |
| `github-token` | `string` | `${{ github.token }}` | no | GitHub token (for requesting the latest hurl version info) |

### Outputs

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ inputs:
description: Hurl version
required: true
default: latest
disable-cache:
description: Disable cache usage
required: false
default: false
github-token:
description: GitHub auth token. Since there's a default, this is typically not supplied by the user
required: false
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

21 changes: 13 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const os = require('os')
// read action inputs
const input = {
version: core.getInput('version', {required: true}).replace(/^[vV]/, ''), // strip the 'v' prefix
cacheDisabled: core.getBooleanInput('disable-cache'),
githubToken: core.getInput('github-token'),
}

Expand Down Expand Up @@ -51,10 +52,12 @@ async function doInstall(version) {
/** @type {string|undefined} */
let restoredFromCache = undefined

try {
restoredFromCache = await cache.restoreCache([pathToInstall], cacheKey)
} catch (e) {
core.warning(e)
if (!input.cacheDisabled) {
try {
restoredFromCache = await cache.restoreCache([pathToInstall], cacheKey)
} catch (e) {
core.warning(e)
}
}

if (restoredFromCache) { // cache HIT
Expand Down Expand Up @@ -101,10 +104,12 @@ async function doInstall(version) {
throw new Error('Unsupported distributive format')
}

try {
await cache.saveCache([pathToInstall], cacheKey)
} catch (e) {
core.warning(e)
if (!input.cacheDisabled) {
try {
await cache.saveCache([pathToInstall], cacheKey)
} catch (e) {
core.warning(e)
}
}
}

Expand Down