-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add composite actions from poetry
- Loading branch information
1 parent
1a41415
commit 94b865c
Showing
2 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Bootstrap Poetry | ||
description: Configure the environment with the specified Python and Poetry version. | ||
|
||
inputs: | ||
python-version: | ||
description: Desired node-semver compatible Python version expression (or 'default') | ||
default: 'default' | ||
python-latest: | ||
description: Use an uncached Python if a newer match is available | ||
default: 'false' | ||
python-prereleases: | ||
description: Allow usage of pre-release Python versions | ||
default: 'false' | ||
poetry-spec: | ||
description: pip-compatible installation specification to use for Poetry | ||
default: 'poetry' | ||
|
||
outputs: | ||
python-path: | ||
description: Path to the installed Python interpreter | ||
value: ${{ steps.setup-python.outputs.python-path }} | ||
python-version: | ||
description: Version of the installed Python interpreter | ||
value: ${{ steps.setup-python.outputs.python-version }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5 | ||
id: setup-python | ||
if: inputs.python-version != 'default' | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
check-latest: ${{ inputs.python-latest == 'true' }} | ||
allow-prereleases: ${{ inputs.python-prereleases == 'true' }} | ||
update-environment: false | ||
|
||
- run: > | ||
pipx install \ | ||
${{ inputs.python-version != 'default' && format('--python "{0}"', steps.setup-python.outputs.python-path) || '' }} \ | ||
'${{ inputs.poetry-spec }}' | ||
shell: bash | ||
# Enable handling long path names (+260 char) on the Windows platform | ||
# https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#maximum-path-length-limitation | ||
- run: git config --system core.longpaths true | ||
if: runner.os == 'Windows' | ||
shell: pwsh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Poetry Install | ||
description: Run `poetry install` with optional artifact and metadata caching | ||
|
||
inputs: | ||
args: | ||
description: Arguments for `poetry install` | ||
cache: | ||
description: Enable transparent Poetry artifact and metadata caching | ||
default: 'true' | ||
path: | ||
description: Path to Poetry project | ||
default: '.' | ||
|
||
outputs: | ||
cache-hit: | ||
description: Whether an exact cache hit occured | ||
value: ${{ steps.cache.outputs.cache-hit }} | ||
|
||
defaults: | ||
run: | ||
working-directory: ${{ inputs.path }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- run: printf 'cache-dir=%s\n' "$(poetry config cache-dir)" >> $GITHUB_OUTPUT | ||
id: poetry-config | ||
shell: bash | ||
|
||
# Bust the cache every 24 hours to prevent it from expanding over time. | ||
- run: printf 'date=%s\n' "$(date -I)" >> $GITHUB_OUTPUT | ||
id: get-date | ||
if: inputs.cache == 'true' | ||
shell: bash | ||
|
||
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4 | ||
id: cache | ||
if: inputs.cache == 'true' | ||
with: | ||
path: | | ||
${{ steps.poetry-config.outputs.cache-dir }}/artifacts | ||
${{ steps.poetry-config.outputs.cache-dir }}/cache | ||
key: poetry-${{ steps.get-date.outputs.date }}-${{ runner.os }}-${{ hashFiles(format('{0}/pyproject.toml', inputs.path), format('{0}/poetry.lock', inputs.path)) }} | ||
# The cache is cross-platform, and other platforms are used to seed cache misses. | ||
restore-keys: | | ||
poetry-${{ steps.get-date.outputs.date }}-${{ runner.os }}- | ||
poetry-${{ steps.get-date.outputs.date }}- | ||
enableCrossOsArchive: true | ||
|
||
- run: poetry install ${{ inputs.args }} | ||
shell: bash | ||
|
||
- run: poetry env info | ||
shell: bash | ||
|
||
- run: poetry show | ||
shell: bash |