Skip to content

Commit

Permalink
Test with no cache hit
Browse files Browse the repository at this point in the history
  • Loading branch information
AnimMouse committed Oct 24, 2023
1 parent 7b021aa commit 6e09f5a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
27 changes: 23 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,34 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
cache: [cache, no-cache]
cache-hit: [cache-hit, no-cache-hit]

steps:
- name: Restore Hello World cache
if: matrix.cache == cache && matrix.cache-hit == cache-hit
id: restore-cache
uses: actions/cache/restore@v3
with:
path: ${{ runner.tool_cache }}/hello-world-program
key: cache-hit-hello-world-program

- name: Checkout Linux Hello World binary
if: matrix.os == 'ubuntu-latest'
uses: actions/checkout@v3
if: matrix.os == 'ubuntu-latest' && steps.restore-cache.outputs.cache-hit != true
uses: actions/checkout@v4
with:
ref: hello-world-linux
persist-credentials: false

- name: Checkout macOS Hello World binary
if: matrix.os == 'macos-latest'
uses: actions/checkout@v3
if: matrix.os == 'macos-latest' && steps.restore-cache.outputs.cache-hit != true
uses: actions/checkout@v4
with:
ref: hello-world-macos
persist-credentials: false

- name: Move the binary to runner temp folder
if: steps.restore-cache.outputs.cache-hit != true
run: |
mkdir $RUNNER_TEMP/hello-world-program
mv hello $RUNNER_TEMP/hello-world-program
Expand All @@ -38,10 +49,18 @@ jobs:
uses: AnimMouse/tool-cache@main
with:
folder_name: hello-world-program
cache_hit: ${{ steps.restore-cache.outputs.cache-hit }}

- name: Test if the Hello World binary is installed by tool-cache
run: hello

- name: Save Hello World cache
if: matrix.cache == cache
uses: actions/cache/save@v3
with:
path: ${{ runner.tool_cache }}/hello-world-program
key: ${{ matrix.cache-hit }}-hello-world-program

test-windows:
runs-on: windows-latest
steps:
Expand Down
8 changes: 4 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ inputs:
folder_name:
description: Folder name of the software inside runner temp
required: true
cache-hit:
cache_hit:
description: Boolean value if cache was found
required: false
default: false

runs:
using: composite
steps:
- name: Install software to tool cache (Unix-like)
if: (runner.os == 'Linux' || runner.os == 'macOS') && inputs.cache-hit != 'true'
if: (runner.os == 'Linux' || runner.os == 'macOS') && inputs.cache_hit != true
shell: bash
run: $GITHUB_ACTION_PATH/scripts/install/Unix-like.sh
env:
Expand All @@ -29,7 +29,7 @@ runs:
folder_name: ${{ inputs.folder_name }}

- name: Install software to tool cache (Windows)
if: runner.os == 'Windows' && inputs.cache-hit != 'true'
if: runner.os == 'Windows' && inputs.cache_hit != true
shell: pwsh
run: '& $env:GITHUB_ACTION_PATH\scripts\install\Windows.ps1'
env:
Expand Down

0 comments on commit 6e09f5a

Please sign in to comment.