Skip to content

Commit

Permalink
Optimize script result caching
Browse files Browse the repository at this point in the history
  • Loading branch information
almirsarajcic committed Dec 6, 2024
1 parent cafb0d3 commit b70c2cf
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 13 deletions.
12 changes: 11 additions & 1 deletion .github/github_workflows.ex
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ defmodule GithubWorkflows do
checkout_step(),
[
name: "Restore script result cache",
uses: "actions/cache@v3",
uses: "actions/cache/restore@v4",
id: "result_cache",
with: [
key:
Expand Down Expand Up @@ -480,6 +480,16 @@ defmodule GithubWorkflows do
retry_wait_seconds: 5,
timeout_seconds: 1
]
],
[
name: "Save script result cache",
if: "steps.result_cache.outputs.cache-hit != 'true'",
uses: "actions/cache/save@v4",
with: [
key:
"${{ runner.os }}-#{shell}-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}",
path: "priv/script.sh"
]
]
]
]
Expand Down
48 changes: 42 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Restore script result cache
uses: actions/cache@v3
uses: actions/cache/restore@v4
id: result_cache
with:
key: ${{ runner.os }}-bash-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
Expand All @@ -324,6 +324,12 @@ jobs:
max_attempts: 7
retry_wait_seconds: 5
timeout_seconds: 1
- name: Save script result cache
if: steps.result_cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ runner.os }}-bash-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
path: priv/script.sh
test_macos_bash:
name: Test macOS script with bash shell
runs-on: macos-latest
Expand All @@ -334,7 +340,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Restore script result cache
uses: actions/cache@v3
uses: actions/cache/restore@v4
id: result_cache
with:
key: ${{ runner.os }}-bash-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
Expand Down Expand Up @@ -363,6 +369,12 @@ jobs:
max_attempts: 7
retry_wait_seconds: 5
timeout_seconds: 1
- name: Save script result cache
if: steps.result_cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ runner.os }}-bash-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
path: priv/script.sh
test_linux_fish:
name: Test Linux script with fish shell
runs-on: ubuntu-latest
Expand All @@ -373,7 +385,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Restore script result cache
uses: actions/cache@v3
uses: actions/cache/restore@v4
id: result_cache
with:
key: ${{ runner.os }}-fish-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
Expand Down Expand Up @@ -402,6 +414,12 @@ jobs:
max_attempts: 7
retry_wait_seconds: 5
timeout_seconds: 1
- name: Save script result cache
if: steps.result_cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ runner.os }}-fish-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
path: priv/script.sh
test_macos_fish:
name: Test macOS script with fish shell
runs-on: macos-latest
Expand All @@ -412,7 +430,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Restore script result cache
uses: actions/cache@v3
uses: actions/cache/restore@v4
id: result_cache
with:
key: ${{ runner.os }}-fish-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
Expand Down Expand Up @@ -444,6 +462,12 @@ jobs:
max_attempts: 7
retry_wait_seconds: 5
timeout_seconds: 1
- name: Save script result cache
if: steps.result_cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ runner.os }}-fish-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
path: priv/script.sh
test_linux_zsh:
name: Test Linux script with zsh shell
runs-on: ubuntu-latest
Expand All @@ -454,7 +478,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Restore script result cache
uses: actions/cache@v3
uses: actions/cache/restore@v4
id: result_cache
with:
key: ${{ runner.os }}-zsh-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
Expand Down Expand Up @@ -483,6 +507,12 @@ jobs:
max_attempts: 7
retry_wait_seconds: 5
timeout_seconds: 1
- name: Save script result cache
if: steps.result_cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ runner.os }}-zsh-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
path: priv/script.sh
test_macos_zsh:
name: Test macOS script with zsh shell
runs-on: macos-latest
Expand All @@ -493,7 +523,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Restore script result cache
uses: actions/cache@v3
uses: actions/cache/restore@v4
id: result_cache
with:
key: ${{ runner.os }}-zsh-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
Expand Down Expand Up @@ -525,6 +555,12 @@ jobs:
max_attempts: 7
retry_wait_seconds: 5
timeout_seconds: 1
- name: Save script result cache
if: steps.result_cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ runner.os }}-zsh-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
path: priv/script.sh
deploy_production_app:
name: Deploy production app
needs:
Expand Down
48 changes: 42 additions & 6 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Restore script result cache
uses: actions/cache@v3
uses: actions/cache/restore@v4
id: result_cache
with:
key: ${{ runner.os }}-bash-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
Expand All @@ -328,6 +328,12 @@ jobs:
max_attempts: 7
retry_wait_seconds: 5
timeout_seconds: 1
- name: Save script result cache
if: steps.result_cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ runner.os }}-bash-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
path: priv/script.sh
test_macos_bash:
name: Test macOS script with bash shell
runs-on: macos-latest
Expand All @@ -338,7 +344,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Restore script result cache
uses: actions/cache@v3
uses: actions/cache/restore@v4
id: result_cache
with:
key: ${{ runner.os }}-bash-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
Expand Down Expand Up @@ -367,6 +373,12 @@ jobs:
max_attempts: 7
retry_wait_seconds: 5
timeout_seconds: 1
- name: Save script result cache
if: steps.result_cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ runner.os }}-bash-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
path: priv/script.sh
test_linux_fish:
name: Test Linux script with fish shell
runs-on: ubuntu-latest
Expand All @@ -377,7 +389,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Restore script result cache
uses: actions/cache@v3
uses: actions/cache/restore@v4
id: result_cache
with:
key: ${{ runner.os }}-fish-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
Expand Down Expand Up @@ -406,6 +418,12 @@ jobs:
max_attempts: 7
retry_wait_seconds: 5
timeout_seconds: 1
- name: Save script result cache
if: steps.result_cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ runner.os }}-fish-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
path: priv/script.sh
test_macos_fish:
name: Test macOS script with fish shell
runs-on: macos-latest
Expand All @@ -416,7 +434,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Restore script result cache
uses: actions/cache@v3
uses: actions/cache/restore@v4
id: result_cache
with:
key: ${{ runner.os }}-fish-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
Expand Down Expand Up @@ -448,6 +466,12 @@ jobs:
max_attempts: 7
retry_wait_seconds: 5
timeout_seconds: 1
- name: Save script result cache
if: steps.result_cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ runner.os }}-fish-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
path: priv/script.sh
test_linux_zsh:
name: Test Linux script with zsh shell
runs-on: ubuntu-latest
Expand All @@ -458,7 +482,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Restore script result cache
uses: actions/cache@v3
uses: actions/cache/restore@v4
id: result_cache
with:
key: ${{ runner.os }}-zsh-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
Expand Down Expand Up @@ -487,6 +511,12 @@ jobs:
max_attempts: 7
retry_wait_seconds: 5
timeout_seconds: 1
- name: Save script result cache
if: steps.result_cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ runner.os }}-zsh-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
path: priv/script.sh
test_macos_zsh:
name: Test macOS script with zsh shell
runs-on: macos-latest
Expand All @@ -497,7 +527,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Restore script result cache
uses: actions/cache@v3
uses: actions/cache/restore@v4
id: result_cache
with:
key: ${{ runner.os }}-zsh-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
Expand Down Expand Up @@ -529,6 +559,12 @@ jobs:
max_attempts: 7
retry_wait_seconds: 5
timeout_seconds: 1
- name: Save script result cache
if: steps.result_cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ runner.os }}-zsh-script-${{ hashFiles('test/scripts/script.exp') }}-${{ hashFiles('priv/script.sh') }}
path: priv/script.sh
deploy_preview_app:
name: Deploy preview app
needs:
Expand Down

0 comments on commit b70c2cf

Please sign in to comment.