-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathaction.yml
More file actions
60 lines (57 loc) · 2.2 KB
/
action.yml
File metadata and controls
60 lines (57 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: "Restore venv and pre-commit from cache"
description: "Restores the venv and pre-commit cache or fails"
inputs:
python-version:
required: true
venv-dir:
required: true
precommit-home:
required: true
cache-key:
required: true
fail-on-miss:
required: false
default: "true" # DefauLt fail if not available
runs:
using: "composite"
steps:
- name: Create or reuse cache
id: cache-create
uses: actions/cache@v4
with:
path: |
${{ inputs.venv-dir }}
${{ inputs.precommit-home }}
key: ${{ inputs.cache-key }}
- name: Create Python virtual environment
if: ${{ steps.cache-create.outputs.cache-hit != 'true' }}
shell: bash
run: |
pip install virtualenv --upgrade
python -m venv venv
. venv/bin/activate
pip install uv
uv pip install -U pip setuptools wheel
# 20220124 Mimic setup_test.sh
uv pip install --upgrade -r requirements_commit.txt -r requirements_test.txt -c https://raw.githubusercontent.com/home-assistant/core/dev/homeassistant/package_constraints.txt -r https://raw.githubusercontent.com/home-assistant/core/dev/requirements_test.txt -r https://raw.githubusercontent.com/home-assistant/core/dev/requirements_test_pre_commit.txt
uv pip install --upgrade pytest-asyncio
- name: Install pre-commit dependencies
if: ${{ steps.cache-create.outputs.cache-hit != 'true' }}
shell: bash
run: |
. venv/bin/activate
pre-commit install-hooks
- name: Save cache if (purposely) created
if: ${{ inputs.fail-on-miss == 'false' && steps.cache-create.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
key: ${{ inputs.cache-key }}
path: |
${{ inputs.venv-dir }}
${{ inputs.precommit-home }}
- name: Fail job if Python cache restore failed
if: ${{ inputs.fail-on-miss == 'true' && steps.cache-create.outputs.cache-hit != 'true' }}
shell: bash
run: |
echo "Failed to restore cache for ${{ inputs.python-version}} virtual environment from cache"
exit 1