-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathaction.yml
62 lines (59 loc) · 2.28 KB
/
action.yml
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
61
62
name: "Setup Python and Poetry"
description: "setup Python and Poetry with caches"
inputs:
os:
description: "Operating system to use"
required: false
default: "ubuntu-latest"
python-version:
description: "Python version to use"
required: true
venv-id:
description: "ID to identify cached environment (should be unique from other steps)"
required: true
poetry-dependency-install-flags:
description: "Flags to pass to poetry when running `poetry install --no-interaction --no-root`"
required: true
run-poetry-install:
description: "Should we run the poetry install steps"
required: false
default: true
runs:
using: "composite"
steps:
- name: Install poetry
shell: bash
run: |
pipx install poetry
which poetry
poetry --version # Check poetry installation
- name: Set up Python ${{ inputs.python-version }}
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
cache: poetry
- name: Set Poetry environment
shell: bash
run: |
# This line used to be needed, but seems to have been
# sorted with newer poetry versions. We can still check whether
# the right version of python is used by looking at the output of
# `poetry run which python` below and whether the right version
# of python is used in the tests (or whatever step is being done)
# poetry env use "python${{ inputs.python-version }}"
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
- name: Install dependencies
if: ${{ (inputs.run-poetry-install == 'true') && (steps.setup-python.outputs.cache-hit != 'true') }}
shell: bash
run: |
poetry install --no-interaction --no-root ${{ inputs.poetry-dependency-install-flags }}
# Now run same command but let the package install too
- name: Install package
# To ensure that the package is always installed, this step is run even if the cache was hit
if: ${{ inputs.run-poetry-install == 'true' }}
shell: bash
run: |
poetry install --no-interaction ${{ inputs.poetry-dependency-install-flags }}
poetry run python --version # Check python version just in case