diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 348c4e9..e4f4847 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -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 @@ -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: diff --git a/action.yml b/action.yml index 95e40ac..9d8b4ea 100644 --- a/action.yml +++ b/action.yml @@ -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: @@ -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: