2023-05-10 13:35:07 +00:00
|
|
|
# An action for setting up poetry install with caching.
|
|
|
|
# Using a custom action since the default action does not
|
|
|
|
# take poetry install groups into account.
|
|
|
|
# Action code from:
|
|
|
|
# https://github.com/actions/setup-python/issues/505#issuecomment-1273013236
|
|
|
|
name: poetry-install-with-caching
|
|
|
|
description: Poetry install with support for caching of dependency groups.
|
|
|
|
|
|
|
|
inputs:
|
|
|
|
python-version:
|
|
|
|
description: Python version, supporting MAJOR.MINOR only
|
|
|
|
required: true
|
|
|
|
|
|
|
|
poetry-version:
|
|
|
|
description: Poetry version
|
|
|
|
required: true
|
|
|
|
|
|
|
|
install-command:
|
|
|
|
description: Command run for installing dependencies
|
|
|
|
required: false
|
|
|
|
default: poetry install
|
|
|
|
|
|
|
|
cache-key:
|
|
|
|
description: Cache key to use for manual handling of caching
|
|
|
|
required: true
|
|
|
|
|
|
|
|
working-directory:
|
|
|
|
description: Directory to run install-command in
|
|
|
|
required: false
|
|
|
|
default: ""
|
|
|
|
|
|
|
|
runs:
|
|
|
|
using: composite
|
|
|
|
steps:
|
|
|
|
- uses: actions/setup-python@v4
|
2023-05-16 15:40:28 +00:00
|
|
|
name: Setup python $${ inputs.python-version }}
|
2023-05-10 13:35:07 +00:00
|
|
|
with:
|
|
|
|
python-version: ${{ inputs.python-version }}
|
|
|
|
|
|
|
|
- uses: actions/cache@v3
|
|
|
|
id: cache-pip
|
2023-05-16 15:40:28 +00:00
|
|
|
name: Cache Pip ${{ inputs.python-version }}
|
2023-05-10 13:35:07 +00:00
|
|
|
env:
|
2023-08-22 16:11:38 +00:00
|
|
|
SEGMENT_DOWNLOAD_TIMEOUT_MIN: "4"
|
2023-05-10 13:35:07 +00:00
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.cache/pip
|
|
|
|
key: pip-${{ runner.os }}-${{ runner.arch }}-py-${{ inputs.python-version }}
|
|
|
|
|
2023-08-21 21:59:10 +00:00
|
|
|
- name: Install poetry
|
2023-05-10 13:35:07 +00:00
|
|
|
shell: bash
|
2023-08-21 21:59:10 +00:00
|
|
|
env:
|
|
|
|
POETRY_VERSION: ${{ inputs.poetry-version }}
|
|
|
|
PYTHON_VERSION: ${{ inputs.python-version }}
|
|
|
|
run: pipx install "poetry==$POETRY_VERSION" --python "python$PYTHON_VERSION" --verbose
|
2023-05-10 13:35:07 +00:00
|
|
|
|
2023-05-16 15:53:06 +00:00
|
|
|
- name: Check Poetry File
|
|
|
|
shell: bash
|
2023-07-21 16:20:24 +00:00
|
|
|
working-directory: ${{ inputs.working-directory }}
|
2023-05-16 15:53:06 +00:00
|
|
|
run: |
|
|
|
|
poetry check
|
|
|
|
|
2023-05-16 15:40:28 +00:00
|
|
|
- name: Check lock file
|
|
|
|
shell: bash
|
2023-07-21 16:20:24 +00:00
|
|
|
working-directory: ${{ inputs.working-directory }}
|
2023-05-16 15:40:28 +00:00
|
|
|
run: |
|
|
|
|
poetry lock --check
|
|
|
|
|
2023-05-10 13:35:07 +00:00
|
|
|
- uses: actions/cache@v3
|
|
|
|
id: cache-poetry
|
|
|
|
env:
|
2023-08-22 16:11:38 +00:00
|
|
|
SEGMENT_DOWNLOAD_TIMEOUT_MIN: "4"
|
2023-08-18 16:55:33 +00:00
|
|
|
WORKDIR: ${{ inputs.working-directory == '' && '.' || inputs.working-directory }}
|
2023-05-10 13:35:07 +00:00
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.cache/pypoetry/virtualenvs
|
|
|
|
~/.cache/pypoetry/cache
|
|
|
|
~/.cache/pypoetry/artifacts
|
2023-08-18 16:55:33 +00:00
|
|
|
${{ env.WORKDIR }}/.venv
|
|
|
|
key: poetry-${{ runner.os }}-${{ runner.arch }}-py-${{ inputs.python-version }}-poetry-${{ inputs.poetry-version }}-${{ inputs.cache-key }}-${{ hashFiles(format('{0}/poetry.lock', env.WORKDIR)) }}
|
2023-05-10 13:35:07 +00:00
|
|
|
|
|
|
|
- run: ${{ inputs.install-command }}
|
|
|
|
working-directory: ${{ inputs.working-directory }}
|
|
|
|
shell: bash
|