Skip to content

Latest commit

 

History

History
77 lines (53 loc) · 2.62 KB

README.md

File metadata and controls

77 lines (53 loc) · 2.62 KB

GitHub Action - Setup and Cache Python Poetry

This GitHub action simplifies the setup and caching of Poetry dependencies for Python projects.

When a job using this action runs for the first time, this action will download Poetry and the required project dependencies, then save it to the cache.

For the following runs (whether it's on a different workflow/job with the same cached commit) this action will restore the cache, which is much faster than downloading everything again.

Basic Usage

  • Make sure you have pyproject.toml, poetry.lock.
name: ci

on:
  push:
    branches: [ master ]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      # Deal with environment setup and caching      
      - name: Check out the repository
        uses: actions/checkout@v4
      - name: "Setup Python, Poetry and Dependencies"
        uses: dsoftwareinc/setup-python-poetry-action@v1
        with:
          python-version: 3.11
          poetry-version: 1.7.1
          poetry-install-additional-args: '-E flag' # Optional

      # Run what you want in the poetry environment
      - name: Run tests
        run: |
          poetry run python manage.py test

Input variables:

Name Description Required Default value
python-version Python version to use. Yes n/a
poetry-version Poetry version to use. Yes n/a
poetry-install-additional-args Additional arguments to pass to poetry install. No ""

Notes

Dependencies

License

The scripts and documentation in this project are released under the MIT License.