Skip to content

Commit d4ca86e

Browse files
committed
Rework cache init
1 parent 6f2c609 commit d4ca86e

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

.github/actions/restore-venv/action.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
name: "Restore venv and pre-commit from cache"
22
description: "Restores the venv and pre-commit cache or fails"
33

4+
inputs:
5+
python-version:
6+
required: true
7+
cache-key:
8+
required: true
9+
venv-directory:
10+
required: true
11+
precommit-home:
12+
required: true
13+
fail-on-miss:
14+
required: false
15+
default: "true" # DefauLt fail if not available
16+
417
runs:
518
using: "composite"
619
steps:
@@ -13,18 +26,9 @@ runs:
1326
${{ inputs.precommit-home }}
1427
key: ${{ inputs.cache-key }}
1528
- name: Fail job if Python cache restore failed
16-
if: steps.cache-create.outputs.cache-hit != 'true'
29+
if: ${{ inputs.fail-on-miss == 'true' && steps.cache-create.outputs.cache-hit != 'true' }}
1730
shell: bash
1831
run: |
1932
echo "Failed to restore cache for {{ inputs.python-version}} virtual environment from cache"
2033
exit 1
2134
22-
inputs:
23-
python-version:
24-
required: true
25-
cache-key:
26-
required: true
27-
venv-directory:
28-
required: true
29-
precommit-home:
30-
required: true

.github/workflows/verify.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
cache-key: ${{ runner.os }}-venv-cache-${{ env.CACHE_VERSION }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml', 'requirements_test.txt', '.pre-commit-config.yaml') }}
3838
venv-directory: ${{ env.VENV }}
3939
precommit-home: ${{ env.PRE_COMMIT_HOME }}
40+
fail-on-miss: false # First time create cache (if not already exists)
4041
- name: Create Python virtual environment
4142
run: |
4243
pip install virtualenv --upgrade

0 commit comments

Comments
 (0)