fix: Don't run save when cache hit and update README.md #36
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test Tool Cache | |
on: | |
push: | |
paths: | |
- action.yml | |
- scripts/** | |
- .github/workflows/test.yaml | |
jobs: | |
test-unix-like: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
cache: [cache, no-cache] | |
cache-hit: [cache-hit, no-cache-hit] | |
exclude: | |
- cache: no-cache | |
cache-hit: 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: ${{ runner.os }}-cache-hit-hello-world-program | |
- name: Checkout Linux Hello World binary | |
if: matrix.os == 'ubuntu-latest' && ! steps.restore-cache.outputs.cache-hit | |
uses: actions/checkout@v4 | |
with: | |
ref: hello-world-linux | |
persist-credentials: false | |
- name: Checkout macOS Hello World binary | |
if: matrix.os == 'macos-latest' && ! steps.restore-cache.outputs.cache-hit | |
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' | |
run: | | |
mkdir $RUNNER_TEMP/hello-world-program | |
mv hello $RUNNER_TEMP/hello-world-program | |
- name: Install the Hello World binary using tool-cache | |
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' && ! steps.restore-cache.outputs.cache-hit | |
uses: actions/cache/save@v3 | |
with: | |
path: ${{ runner.tool_cache }}/hello-world-program | |
key: ${{ runner.os }}-${{ matrix.cache-hit }}-hello-world-program | |
test-windows: | |
runs-on: windows-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
cache: [cache, no-cache] | |
cache-hit: [cache-hit, no-cache-hit] | |
exclude: | |
- cache: no-cache | |
cache-hit: 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: ${{ runner.os }}-cache-hit-hello-world-program | |
- name: Checkout Windows Hello World binary | |
if: '! steps.restore-cache.outputs.cache-hit' | |
uses: actions/checkout@v4 | |
with: | |
ref: hello-world-windows | |
persist-credentials: false | |
- name: Move the binary to runner temp folder | |
if: '! steps.restore-cache.outputs.cache-hit' | |
run: | | |
New-Item $env:RUNNER_TEMP\hello-world-program -ItemType Directory | |
Move-Item hh2.golden.exe $env:RUNNER_TEMP\hello-world-program | |
- name: Install the Windows Hello World binary using tool-cache | |
uses: AnimMouse/tool-cache@main | |
with: | |
folder_name: hello-world-program | |
cache_hit: ${{ steps.restore-cache.outputs.cache-hit }} | |
- name: Test if the Windows Hello World binary is installed by tool-cache | |
run: hh2.golden | |
- name: Save Hello World cache | |
if: matrix.cache == 'cache' && ! steps.restore-cache.outputs.cache-hit | |
uses: actions/cache/save@v3 | |
with: | |
path: ${{ runner.tool_cache }}/hello-world-program | |
key: ${{ runner.os }}-${{ matrix.cache-hit }}-hello-world-program |