Skip to content

A GitHub Action to install Python, Poetry, dependencies and pre-commit.

License

Notifications You must be signed in to change notification settings

Qwerty-133/python-setup

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

License Release

Python Environment Setup Action

A Github action for installing and configuring

This action caches heavily, to speed up your workflow. It is a composite action which can be viewed at action.yml.

Usage

- name: Setup the Python Environment
  uses: Qwerty-133/python-setup@v1
  with:
    python-version: '3.11'

The python-version input is required, however the action automatically chooses the latest Poetry version.

Poetry will be added to Path, and the venv will be created in the project directory. Scripts can be run using poetry run <script>. For example, to run pytest, use poetry run pytest.

To source the venv, add this to your workflow:

- name: Source the venv
  run: source $VENV

Also see #windows if you are using Windows runners.

Cache

This action caches the Poetry installation, it's venv, and pre-commit hooks.

To disable the cache entirely, the use-cache input can be set to false.

- name: Setup the Python Environment
  uses: Qwerty-133/python-setup@v1
  with:
    python-version: '3.11'
    use-cache: false

pre-commit

To use pre-commit, it must be added to Poetry's dev-dependencies.

poetry add --group dev pre-commit

To skip installing pre-commit, the skip-precommit input can be set to true.

- name: Setup the Python Environment
  uses: Qwerty-133/python-setup@v1
  with:
    python-version: '3.11'
    skip-precommit: true

Windows

You must set the default shell to be bash, by adding the following in your workflow.

defaults:
  run:
    shell: bash

On Windows runners, only pre-commit hooks are cached, since caching the Poetry installation and venv is problematic.

Credits

The snok/install-poetry action is used to install Poetry.

About

A GitHub Action to install Python, Poetry, dependencies and pre-commit.

Resources

License

Stars

Watchers

Forks

Packages

No packages published