-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.yml
More file actions
59 lines (53 loc) · 1.93 KB
/
action.yml
File metadata and controls
59 lines (53 loc) · 1.93 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
name: "Setup Python Poetry with Cache"
description: "Setup Python & Poetry, using cache for dependencies and Poetry installation."
branding:
icon: "play"
color: "purple"
inputs:
python-version:
description: Python Version
required: true
poetry-version:
description: Poetry Version
required: true
poetry-install-additional-args:
description: Additional arguments for poetry install (e.g., "-E flag")
required: false
default: ""
runs:
using: "composite"
steps:
- name: Set up python ${{ inputs.python-version }}
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
# Install Poetry
- name: Load cached Poetry Binary
id: cached-poetry-binary
uses: actions/cache@v4
with:
path: ~/.local
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ inputs.poetry-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: ${{ inputs.poetry-version }}
virtualenvs-create: true
virtualenvs-in-project: true
# Load cached venv if cache exists
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
# If the exact match is not found, the cache will be restored from the key with the prefix.
# Note cache-hit returns false in this case, so the below step will run
restore-keys: |
venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-
# Install dependencies on cache miss
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
shell: sh
run: poetry install --no-interaction --no-root ${{ inputs.poetry-install-additional-args }}