-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaction.yml
139 lines (133 loc) · 5.65 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Setup Python and Poetry
description: Setup a specific version of Python & Poetry with virtual environment caching.
author: Kyle Finley
branding:
color: purple
icon: cloud-lightning
inputs:
architecture:
description: The target architecture (x86, x64) of the Python interpreter.
poetry-check:
description: Whether validate the content of the `pyproject.toml` file and its consistency with the `poetry.lock` file.
required: false
default: false
poetry-check-cmd:
description: |
The poetry command to run when checking the lock file (e.g. `check`).
This command was changed in poetry 1.6 (default used by this action).
To support older versions of poetry, provide a value for this input.
default: check
required: false
poetry-install:
description: Whether to run `poetry install`.
required: false
default: true
poetry-install-args:
description: Additional args to pass to `poetry install`.
default: '-v --sync'
required: false
poetry-install-cmd:
description: |
Command for installing poetry project.
Can be used to provide a custom install command.
The value of `poetry-install-args` is appended after this.
default: poetry install
required: false
poetry-plugins:
description: |
A whitespace seperated list of poetry plugins to be installed (e.g. `plugin0 plugin1`).
Note that [poetry-plugin-export](https://github.com/python-poetry/poetry-plugin-export) is installed by default and can be left out of this list.
required: false
poetry-preview:
description: Allow install of prerelease versions of Poetry.
default: false
required: false
poetry-version:
description: |
Poetry version to use. If version is not provided then latest stable version will be used.
Should be provided as a version specifier that can be passed to [pipx](https://github.com/pypa/pipx) or `latest`.
default: latest
required: false
python-version:
description: Version range or exact version of a Python version to use, using semver version range syntax. Reads from pyproject.toml if unset.
default: ${{ null }}
required: false
python-version-file:
description: File containing the Python version to use.
default: pyproject.toml
required: false
token:
description: Used to pull python distributions from actions/python-versions. Since there's a default, this is typically not supplied by the user.
default: ${{ github.token }}
outputs:
cache-hit:
description: Whether there was a cache hit for the Python virtual environment.
value: ${{ steps.composite-setup-python.outputs.cache-hit }}
python-path:
description: The absolute path to the Python or PyPy executable.
value: ${{ steps.composite-setup-python.outputs.cache-hit }}
python-version:
description: The installed Python version. Useful when given a version range as input.
value: ${{ steps.composite-setup-python.outputs.python-version }}
runs:
using: composite
steps:
- name: Install poetry
env:
INPUT_POETRY_PLUGINS: ${{ inputs.poetry-plugins }}
INPUT_POETRY_PREVIEW: ${{ inputs.poetry-preview }}
INPUT_POETRY_VERSION: ${{ inputs.poetry-version }}
id: composit-install-poetry
run: ${GITHUB_ACTION_PATH}/scripts/install-poetry.sh
shell: bash
- name: List pipx apps
run: pipx list --include-injected
shell: bash
- name: Setup python (explicit)
id: composite-setup-python-explicit
if: inputs.python-version != ''
uses: actions/setup-python@v5
with:
architecture: ${{ inputs.architecture }}
cache: poetry
python-version: ${{ inputs.python-version }}
token: ${{ inputs.token }}
- name: Setup python (implicit / file)
id: composite-setup-python-file
if: inputs.python-version == ''
uses: actions/setup-python@v5
with:
architecture: ${{ inputs.architecture }}
cache: poetry
python-version-file: ${{ inputs.python-version-file }}
token: ${{ inputs.token }}
- name: Extract python outputs
env:
OUTPUT_CACHE_HIT: ${{ steps.composite-setup-python-explicit.outputs.cache-hit != '' && steps.composite-setup-python-explicit.outputs.cache-hit || steps.composite-setup-python-file.outputs.cache-hit }}
OUTPUT_PYTHON_PATH: ${{ steps.composite-setup-python-explicit.outputs.python-path != '' && steps.composite-setup-python-explicit.outputs.python-path || steps.composite-setup-python-file.outputs.python-path }}
OUTPUT_PYTHON_VERSION: ${{ steps.composite-setup-python-explicit.outputs.python-version != '' && steps.composite-setup-python-explicit.outputs.python-version || steps.composite-setup-python-file.outputs.python-version }}
id: composite-setup-python
run: |
echo "cache-hit=${OUTPUT_CACHE_HIT}" >> $GITHUB_OUTPUT;
echo "python-path=${OUTPUT_PYTHON_PATH}" >> $GITHUB_OUTPUT;
echo "python-version=${OUTPUT_PYTHON_VERSION}" >> $GITHUB_OUTPUT;
shell: bash
- name: Check pyproject.toml & poetry.lock
if: inputs.poetry-check == 'true'
env:
POETRY_CHECK_CMD: ${{ inputs.poetry-check-cmd }}
run: poetry ${POETRY_CHECK_CMD}
shell: bash
- name: Install dependencies
if: inputs.poetry-install == 'true'
env:
POETRY_INSTALL_ARGS: ${{ inputs.poetry-install-args }}
POETRY_INSTALL_CMD: ${{ inputs.poetry-install-cmd }}
run: |
if [[ -f "Makefile" ]] && grep -q 'setup-poetry:' Makefile; then
echo "installing project using Makefile...";
make setup-poetry;
else
${POETRY_INSTALL_CMD} ${POETRY_INSTALL_ARGS};
fi
shell: bash