Giter Site home page Giter Site logo

actions-poetry's Introduction

actions-poetry

GitHub Actions for Python projects using poetry

license release GitHub release date

Getting started

Breaking changes for v2

We've drastically simplified this GitHub Action for v2. This is no longer a Docker action that runs as its own container, it's just a simplified way for you to install poetry. This action now makes an assumption that you've already setup Python via setup-python or some other way. Since we're installing poetry directly to your environment, this also means that you can cache your dependencies more easily since everything is running on the host runner instead of an isolated container environment.

Create your workflow

name: CI
on: pull_request

jobs:
  ci:
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.8", "3.9", "3.10", "3.11"]
        poetry-version: ["1.2.2", "1.7.1"]
        os: [ubuntu-22.04, macos-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}
      - name: Run image
        uses: abatilo/actions-poetry@v2
        with:
          poetry-version: ${{ matrix.poetry-version }}
      - name: View poetry --help
        run: poetry --help

Workflow example: cache the virtual environment

It is possible to combine actions/poetry with actions/cache to speed up the installation of dependencies. The recipe is:

  1. to ask poetry to create a virtual environment inside the project: it creates a local .venv/ folder that can be cached
  2. to create a cache key that involves the contents of the poetry.lock file: if the contents change (meaning that dependencies have changed), then the cache needs to be invalidated and recreated

For the 1st step, you either need:

  • to have a poetry.toml file at the root of your project with these 2 settings:
[virtualenvs]
create = true
in-project = true
  • or to run the following commands in the github actions to create the poetry.toml file:
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local

Here is an example of how the steps must be declared:

jobs:
  ci:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install Python
        uses: actions/setup-python@v4
        # see details (matrix, python-version, python-version-file, etc.)
        # https://github.com/actions/setup-python
      - name: Install poetry
        uses: abatilo/actions-poetry@v2
      - name: Setup a local virtual environment (if no poetry.toml file)
        run: |
          poetry config virtualenvs.create true --local
          poetry config virtualenvs.in-project true --local
      - uses: actions/cache@v3
        name: Define a cache for the virtual environment based on the dependencies lock file
        with:
          path: ./.venv
          key: venv-${{ hashFiles('poetry.lock') }}
      - name: Install the project dependencies
        run: poetry install
      - name: Run the automated tests (for example)
        run: poetry run pytest -v

License

MIT License - abatilo/actions-poetry

About the author

actions-poetry's People

Contributors

515hikaru avatar abatilo avatar aisensiy avatar browniebroke avatar cclauss avatar dependabot-preview[bot] avatar duarte-pompeu avatar jennydaman avatar lucsorel avatar mammo0 avatar mrflynn avatar nargit avatar noritada avatar rockymm avatar siddhantgoel avatar xsavikx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

actions-poetry's Issues

Cache poetry installation itself

When using this action, it seems that poetry itself is installed through pip every time.

I wonder if it wouldn't be much faster and better if you just install it using the official method with curl, that stores all poetry installation in $HOME/.poetry, and then set up cache automatically for that folder.

Next time you want to install it, it will be way faster because it is already installed from cache.

Support macos and windows os

Poetry can be installed on both Mac and Windows operating systems.

image

Could this GitHub action also support these operating systems as well?

Mount ssh agent socket to docker container

Hi, my project includes a private github repo as dependency and I use SSH protocol to authenticate with github.

my_package = {git = "ssh://[email protected]/username/MyPackage.git", rev = "latest"}

In the github workflow I use ssh-agent action to setup the ssh agent before running poetry action.
However I found that the ssh-agent socket is not mount to the actions-poetry docker container which caused the installation of the private github repo dependency failed.
Do you have any plan to add this feature? Thanks

V2 only usable via branchname specification instead of versioned action

Example workflow from my project:

name: Poetry build and test
on: push
jobs:
  execute:
    name: Execute
    runs-on: ubuntu-18.04
    strategy:
      matrix:
        python-version: [3.6, 3.7, 3.8]
      fail-fast: true
    steps:
      - name: Checkout current branch
        uses: actions/[email protected]
      - name: Install required version of Python
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}
          architecture: x64
      - name: Install Poetry
        uses: abatilo/actions-poetry@master                  <--------------------------------------
        with:
          poetry-version: 1.1.2
      - name: Set up Poetry virtual environment
        run: poetry env use python${{ matrix.python-version }}
      - name: Install project dependencies
        run: poetry install
      - name: Run tests with Poetry
        run: poetry run pytest

The marketplace only has V1 available.

windows self hosted runner - Windows Subsystem for Linux has no installed distributions.

note that I can open bash on my windows runner and have ubuntu WSL installed.

Run abatilo/actions-poetry@v2
  with:
    poetry-version: 1.[2](https://github.com/tzvet5/UI/actions/runs/3939816093/jobs/6740227933#step:6:2).2
  env:
    IS_GITHUB_ACTION: 1
    SSH_AUTH_SOCK: /tmp/ssh-De[3](https://github.com/tzvet5/UI/actions/runs/3939816093/jobs/6740227933#step:6:3)MvLcRNH9c/agent.77
    SSH_AGENT_PID: 78
    pythonLocation: C:\actions-runner\_work\_tool\Python\3.10.9\x6[4](https://github.com/tzvet5/UI/actions/runs/3939816093/jobs/6740227933#step:6:4)
    PKG_CONFIG_PATH: C:\actions-runner\_work\_tool\Python\3.10.9\x64/lib/pkgconfig
    Python_ROOT_DIR: C:\actions-runner\_work\_tool\Python\3.10.9\x64
    Python2_ROOT_DIR: C:\actions-runner\_work\_tool\Python\3.10.9\x64
    Python3_ROOT_DIR: C:\actions-runner\_work\_tool\Python\3.10.9\x64
    MSYS: winsymlinks:nativestrict
Run pip install poetry==1.2.2
  pip install poetry==1.2.2
  shell: C:\WINDOWS\system32\bash.EXE --noprofile --norc -e -o pipefail {0}
  env:
    IS_GITHUB_ACTION: 1
    SSH_AUTH_SOCK: /tmp/ssh-De3MvLcRNH9c/agent.77
    SSH_AGENT_PID: 78
    pythonLocation: C:\actions-runner\_work\_tool\Python\3.10.9\x[6](https://github.com/tzvet5/UI/actions/runs/3939816093/jobs/6740227933#step:6:6)4
    PKG_CONFIG_PATH: C:\actions-runner\_work\_tool\Python\3.10.[9](https://github.com/tzvet5/UI/actions/runs/3939816093/jobs/6740227933#step:6:9)\x64/lib/pkgconfig
    Python_ROOT_DIR: C:\actions-runner\_work\_tool\Python\3.[10](https://github.com/tzvet5/UI/actions/runs/3939816093/jobs/6740227933#step:6:10).9\x64
    Python2_ROOT_DIR: C:\actions-runner\_work\_tool\Python\3.10.9\x64
    Python3_ROOT_DIR: C:\actions-runner\_work\_tool\Python\3.10.9\x64
    MSYS: winsymlinks:nativestrict
Windows Subsystem for Linux has no installed distributions.

Distributions can be installed by visiting the Microsoft Store:

https://aka.ms/wslstore

image

It does not seem to work with python 3.10

I have workflow that tests my application from python 3.6 to 3.10. After I added abatilo/actions-poetry it's now failing for 3.10:

2021-12-25T11:01:46.9378939Z ##[group]Run poetry add openbabel-wheel
2021-12-25T11:01:46.9379598Z �[36;1mpoetry add openbabel-wheel�[0m
2021-12-25T11:01:46.9380092Z �[36;1mpoetry install�[0m
2021-12-25T11:01:46.9418234Z shell: /usr/bin/bash -e {0}
2021-12-25T11:01:46.9418605Z env:
2021-12-25T11:01:46.9419154Z   pythonLocation: /opt/hostedtoolcache/Python/3.10.1/x64
2021-12-25T11:01:46.9419889Z   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.10.1/x64/lib
2021-12-25T11:01:46.9420509Z   DEBIAN_FRONTEND: noninteractive
2021-12-25T11:01:46.9421174Z   AMBERHOME: /home/runner/work/acpype/acpype/acpype/amber21-11_linux
2021-12-25T11:01:46.9421745Z ##[endgroup]
2021-12-25T11:01:47.4876049Z Creating virtualenv acpype-njN5mZWO-py3.10 in /home/runner/.cache/pypoetry/virtualenvs
2021-12-25T11:01:47.9105964Z Using version ^3.1.1 for openbabel-wheel
2021-12-25T11:01:47.9113729Z 
2021-12-25T11:01:48.2214491Z Updating dependencies
2021-12-25T11:01:48.2215106Z Resolving dependencies...
2021-12-25T11:02:26.2535589Z 
2021-12-25T11:02:26.2536905Z Writing lock file
2021-12-25T11:02:26.4063825Z 
2021-12-25T11:02:26.4065399Z Package operations: 45 installs, 0 updates, 0 removals
2021-12-25T11:02:26.4065852Z 
2021-12-25T11:02:26.4107789Z   • Installing decorator (5.1.0)
2021-12-25T11:02:26.4109229Z   • Installing ipython-genutils (0.2.0)
2021-12-25T11:02:26.4148246Z   • Installing parso (0.8.3)
2021-12-25T11:02:26.4177880Z   • Installing ptyprocess (0.7.0)
2021-12-25T11:02:26.4212846Z   • Installing pyparsing (3.0.6)
2021-12-25T11:02:26.4274567Z   • Installing six (1.16.0)
2021-12-25T11:02:26.6911603Z 
2021-12-25T11:02:26.6912804Z   JSONDecodeError
2021-12-25T11:02:26.6913409Z 
2021-12-25T11:02:26.6914124Z   Expecting value: line 1 column 1 (char 0)
2021-12-25T11:02:26.6914701Z 
2021-12-25T11:02:26.6915792Z   at /opt/hostedtoolcache/Python/3.10.1/x64/lib/python3.10/json/decoder.py:355 in raw_decode
2021-12-25T11:02:26.7062304Z       351│         """
2021-12-25T11:02:26.7063408Z       352│         try:
2021-12-25T11:02:26.7064379Z       353│             obj, end = self.scan_once(s, idx)
2021-12-25T11:02:26.7065437Z       354│         except StopIteration as err:
2021-12-25T11:02:26.7066865Z     → 355│             raise JSONDecodeError("Expecting value", s, err.value) from None
2021-12-25T11:02:26.7068247Z       356│         return obj, end
2021-12-25T11:02:26.7069205Z       357│ 
2021-12-25T11:02:26.7069656Z 
2021-12-25T11:02:26.7070685Z   • Installing wcwidth (0.2.5)
2021-12-25T11:02:26.7156007Z 
2021-12-25T11:02:26.7157082Z   JSONDecodeError
2021-12-25T11:02:26.7157476Z 
2021-12-25T11:02:26.7157966Z   Expecting value: line 1 column 1 (char 0)
2021-12-25T11:02:26.7158379Z 
2021-12-25T11:02:26.7159064Z   at /opt/hostedtoolcache/Python/3.10.1/x64/lib/python3.10/json/decoder.py:355 in raw_decode
2021-12-25T11:02:26.7232494Z       351│         """
2021-12-25T11:02:26.7234398Z       352│         try:
2021-12-25T11:02:26.7237327Z       353│             obj, end = self.scan_once(s, idx)
2021-12-25T11:02:26.7241467Z       354│         except StopIteration as err:
2021-12-25T11:02:26.7248529Z     → 355│             raise JSONDecodeError("Expecting value", s, err.value) from None
2021-12-25T11:02:26.7253214Z       356│         return obj, end
2021-12-25T11:02:26.7255788Z       357│ 
2021-12-25T11:02:26.7256538Z 
2021-12-25T11:02:26.7316067Z 
2021-12-25T11:02:26.7316858Z   JSONDecodeError
2021-12-25T11:02:26.7317281Z 
2021-12-25T11:02:26.7317813Z   Expecting value: line 1 column 1 (char 0)
2021-12-25T11:02:26.7318256Z 
2021-12-25T11:02:26.7318974Z   at /opt/hostedtoolcache/Python/3.10.1/x64/lib/python3.10/json/decoder.py:355 in raw_decode
2021-12-25T11:02:26.7373806Z       351│         """
2021-12-25T11:02:26.7376513Z       352│         try:
2021-12-25T11:02:26.7380170Z       353│             obj, end = self.scan_once(s, idx)
2021-12-25T11:02:26.7383296Z       354│         except StopIteration as err:
2021-12-25T11:02:26.7387544Z     → 355│             raise JSONDecodeError("Expecting value", s, err.value) from None
2021-12-25T11:02:26.7390829Z       356│         return obj, end
2021-12-25T11:02:26.7393084Z       357│ 
2021-12-25T11:02:26.7394552Z 
2021-12-25T11:02:26.7436207Z 
2021-12-25T11:02:26.7436980Z   JSONDecodeError
2021-12-25T11:02:26.7437480Z 
2021-12-25T11:02:26.7438086Z   Expecting value: line 1 column 1 (char 0)
2021-12-25T11:02:26.7438585Z 
2021-12-25T11:02:26.7439355Z   at /opt/hostedtoolcache/Python/3.10.1/x64/lib/python3.10/json/decoder.py:355 in raw_decode
2021-12-25T11:02:26.7521146Z       351│         """
2021-12-25T11:02:26.7523858Z       352│         try:
2021-12-25T11:02:26.7527562Z       353│             obj, end = self.scan_once(s, idx)
2021-12-25T11:02:26.7530669Z       354│         except StopIteration as err:
2021-12-25T11:02:26.7534833Z     → 355│             raise JSONDecodeError("Expecting value", s, err.value) from None
2021-12-25T11:02:26.7537971Z       356│         return obj, end
2021-12-25T11:02:26.7540052Z       357│ 
2021-12-25T11:02:26.7541494Z 
2021-12-25T11:02:26.7556289Z 
2021-12-25T11:02:26.7557095Z   JSONDecodeError
2021-12-25T11:02:26.7557585Z 
2021-12-25T11:02:26.7558199Z   Expecting value: line 1 column 1 (char 0)
2021-12-25T11:02:26.7558699Z 
2021-12-25T11:02:26.7559487Z   at /opt/hostedtoolcache/Python/3.10.1/x64/lib/python3.10/json/decoder.py:355 in raw_decode
2021-12-25T11:02:26.7658949Z       351│         """
2021-12-25T11:02:26.7661635Z       352│         try:
2021-12-25T11:02:26.7665290Z       353│             obj, end = self.scan_once(s, idx)
2021-12-25T11:02:26.7668404Z       354│         except StopIteration as err:
2021-12-25T11:02:26.7672539Z     → 355│             raise JSONDecodeError("Expecting value", s, err.value) from None
2021-12-25T11:02:26.7675870Z       356│         return obj, end
2021-12-25T11:02:26.7678156Z       357│ 
2021-12-25T11:02:26.7679618Z 
2021-12-25T11:02:26.7756114Z 
2021-12-25T11:02:26.7756867Z   JSONDecodeError
2021-12-25T11:02:26.7757415Z 
2021-12-25T11:02:26.7758011Z   Expecting value: line 1 column 1 (char 0)
2021-12-25T11:02:26.7758511Z 
2021-12-25T11:02:26.7759319Z   at /opt/hostedtoolcache/Python/3.10.1/x64/lib/python3.10/json/decoder.py:355 in raw_decode
2021-12-25T11:02:26.7796564Z       351│         """
2021-12-25T11:02:26.7799338Z       352│         try:
2021-12-25T11:02:26.7802991Z       353│             obj, end = self.scan_once(s, idx)
2021-12-25T11:02:26.7806052Z       354│         except StopIteration as err:
2021-12-25T11:02:26.7810202Z     → 355│             raise JSONDecodeError("Expecting value", s, err.value) from None
2021-12-25T11:02:26.7813206Z       356│         return obj, end
2021-12-25T11:02:26.7815245Z       357│ 
2021-12-25T11:02:26.7816673Z 
2021-12-25T11:02:26.7939398Z 
2021-12-25T11:02:26.7940390Z   JSONDecodeError
2021-12-25T11:02:26.7940897Z 
2021-12-25T11:02:26.7941504Z   Expecting value: line 1 column 1 (char 0)
2021-12-25T11:02:26.7942009Z 
2021-12-25T11:02:26.7943086Z   at /opt/hostedtoolcache/Python/3.10.1/x64/lib/python3.10/json/decoder.py:355 in raw_decode
2021-12-25T11:02:26.8045637Z       351│         """
2021-12-25T11:02:26.8046657Z       352│         try:
2021-12-25T11:02:26.8048287Z       353│             obj, end = self.scan_once(s, idx)
2021-12-25T11:02:26.8049704Z       354│         except StopIteration as err:
2021-12-25T11:02:26.8051447Z     → 355│             raise JSONDecodeError("Expecting value", s, err.value) from None
2021-12-25T11:02:26.8052618Z       356│         return obj, end
2021-12-25T11:02:26.8053888Z       357│ 
2021-12-25T11:02:26.8054968Z 
2021-12-25T11:02:26.8081034Z 
2021-12-25T11:02:26.8081959Z Failed to add packages, reverting the pyproject.toml file to its original content.
2021-12-25T11:02:26.8972793Z ##[error]Process completed with exit code 1.
2021-12-25T11:02:26.9081242Z Post job cleanup.
2021-12-25T11:02:27.0222069Z [command]/usr/bin/git version
2021-12-25T11:02:27.0268150Z git version 2.34.1
2021-12-25T11:02:27.0299758Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
2021-12-25T11:02:27.0336983Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :
2021-12-25T11:02:27.0569444Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2021-12-25T11:02:27.0598125Z http.https://github.com/.extraheader
2021-12-25T11:02:27.0607516Z [command]/usr/bin/git config --local --unset-all http.https://github.com/.extraheader
2021-12-25T11:02:27.0644778Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :
2021-12-25T11:02:27.0926556Z Cleaning up orphan processes

If I remove:

         - name: Python Poetry Action
           uses: abatilo/[email protected]

and put back:

         - name: Install Poetry
           run: |
              pip3 install poetry # <-- put this line back
              poetry add openbabel-wheel
              poetry install

It works for 3.10. I must say that I'm adding openbabel-wheel which does have binaries ready for python 3.6-9 while for 3.10 it has to build one.

I was hoping abatilo/actions-poetry could help me to save time buy caching the 3.10 built wheel for openbabel-wheel.

Addition of major version tags

Thank you very much for this nice Action.

It would be great if you could add major version tags so that major releases always refer to the latest patch release. That way users would be able to keep using uses: abatilo/actions-poetry@v2 for the latest version of this Action, instead of rewriting uses: abatilo/[email protected] to uses: abatilo/[email protected] for example. Since this Action employs semantic versioning, users would not be inconvenienced by the use of major version tags.

Concerns

Major version tag replacement may need to be a manual operation documented in action-versioning.md for the time being.

It seems that actions/setup-python and other GitHub official Actions are using a workflow release-new-action-version.yml to replace a major version tag when adding a patch version tag to make a patch release. However, that workflow is implemented using actions/publish-action, which is still in an alpha version and is only used internally on GitHub, so it does not seem possible at this time for a third party to use it to implement the major version tag replacement.

Add caching

Good job on a very simple api for this action.

Is it possible to add some caching though? In your example python is being installed twice even. It would be nice if the environment would be cached between pushes so only the testing would be run on pushes (unless there is a dependency or similar change of course)

name: Run Tests
on: push

jobs:
  pytest:
    name: pytest
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: Install
      uses: abatilo/[email protected]
      with:
        python_version: 3.8.0
        poetry_version: 1.0
        working_directory: ./working_dir # Optional, defaults to '.'
        args: install
    - name: Run pytest
      uses: abatilo/[email protected]
      with:
        python_version: 3.8.0
        poetry_version: 1.0
        working_directory: ./working_dir
        args: run python -m pytest --cov=src --cov-branch --cov-fail-under=100 tests/

Install Failure Bug

Is this reportable here? This was seen while using the plugin.

Run poetry install
  poetry install
  shell: /usr/bin/bash -e {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.7.14/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.7.14/x64/lib

  RuntimeError

  The Poetry configuration is invalid:
    - Additional properties are not allowed ('group' was unexpected)
  

  at /opt/hostedtoolcache/Python/3.7.14/x64/lib/python3.7/site-packages/poetry/core/factory.py:43 in create_poetry
       39│             message = ""
       40│             for error in check_result["errors"]:
       41│                 message += "  - {}\n".format(error)
       42│ 
    →  43│             raise RuntimeError("The Poetry configuration is invalid:\n" + message)
       44│ 
       45│         # Load package
       46│         name = local_config["name"]
       47│         version = local_config["version"]
Error: Process completed with exit code 1.

I think the GH Actions links are ephemeral, but here is one to the failing job in case that helps.

Support under-specified Python versions

I tried to use your action with a matrix-specifed Python version. I set it like:

...
jobs:
  unit-tests:
    runs-on: ubuntu-latest
    strategy:
      max-parallel: 4
      matrix:
        python-version: [3.6, 3.7, 3.8]
    steps:
    - uses: actions/checkout@master
    - name: Install
      uses: abatilo/[email protected]
      with:
        python_version:  ${{ matrix.python-version }}
        args: install
...

and I expected that [3.6, 3.7, 3.8] would choose the latest release of each version (so 3.6.9, 3.7.5 and 3.8.0).

Instead I get an error:

python-build: definition not found: 3.6

The following versions contain `3.6' in the name:
  3.3.6
  3.6.0
  3.6-dev
  3.6.1
  3.6.2
  3.6.3
  3.6.4
  3.6.5
  3.6.6
  3.6.7
  3.6.8
  3.6.9
  activepython-3.6.0
  pypy3.6-7.0.0-src
  pypy3.6-7.0.0
  pypy3.6-7.1.0-src
  pypy3.6-7.1.0
  pypy3.6-7.1.1-src
  pypy3.6-7.1.1
  pypy3.6-7.2.0-src
  pypy3.6-7.2.0

See all available versions with `pyenv install --list'.

If the version you need is missing, try upgrading pyenv.
pyenv: version `3.6' not installed

Perhaps https://github.com/momo-lab/xxenv-latest could be used? Otherwise, is it possible to use the logic from https://github.com/actions/setup-python to do this?

please document how the cache should be configured using this action

thank you @abatilo for this github action 🙏

Before using your action, I:

  • installed poetry
  • then installed python defining a cache
    steps:
      - uses: actions/checkout@v3
      - name: Install poetry
        run: pipx install poetry
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version-file: '.python-version'
          cache: 'poetry' # <- this is where a cache was defined for poetry
      - name: Install dependencies
        run: poetry install

I tried using the actions-poetry action like this:

    steps:
      - uses: actions/checkout@v3
      - name: Install Python
        uses: actions/setup-python@v4
        with:
          python-version-file: '.python-version'
          cache: 'poetry' # <- this cause the installation to fail
      - name: Install poetry
        uses: abatilo/actions-poetry@v2
        with:
          poetry-version: 1.5.1
      - name: Install project dependencies
        run: poetry install

The cache 'poetry' line in the actions/setup-python@v4 action causes the job to fail:

Error: Unable to locate executable file: poetry. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.

Can you please tell me (and add in the README file) how one should set up a cache for poetry to speed up the download of dependencies? 🙏

Installation error with Python 3.5 and `ubuntu-latest`

Using:

jobs:
  pr:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Check Poetry Metadata
        uses: abatilo/[email protected]
        with:
          python_version: 3.5.0
          poetry_version: 1.0
          args: check

I see:

Latest version is '3.5.0'
Downloading Python-3.5.0.tar.xz...
-> https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tar.xz
Installing Python-3.5.0...
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems

Here's the relevant part of the link: https://github.com/pyenv/pyenv/wiki/Common-build-problems#error-the-python-ssl-extension-was-not-compiled-missing-the-openssl-lib

Publish to Docker hub

Thanks for creating this action!

Would be great if you could publish it to Docker hub so it doesn't have get rebuilt on every run.

PermissionError Installing pycparser

Seeing PermissionError when install poetry-plugin-export with python 3.10 and poetry 1.7.1

Snippet from the job:

...
  jobs:
    deploy-development:
      name: deploy (development)
      runs-on: ubuntu-latest
      steps:
        - name: Install Poetry
          uses: abatilo/actions-poetry@v2
          with:
            poetry-version: "1.7.1"
            poetry-plugins: "poetry-plugin-export"

Error in the log:

  ...
  Run ALL_PLUGINS=$(echo "poetry-plugin-export")
  ALL_PLUGINS=$(echo "poetry-plugin-export")
  for PLUGIN in $ALL_PLUGINS; do
    poetry self add $PLUGIN
  done
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    POETRY_VERSION: 1.7.1
  
Using version ^1.6.0 for poetry-plugin-export
Updating dependencies
Resolving dependencies...
Package operations: 2 installs, 36 updates, 0 removals
  • Installing pycparser (2.21)
  PermissionError
  [Errno 13] Permission denied: '/usr/local/lib/python3.10/dist-packages/pycparser'
at /usr/lib/python3.10/pathlib.py:1175 in mkdir
      1171│         """
      1172│         Create a new directory at this given path.
      1173│         """
      1174│         try:
      1175│             self._accessor.mkdir(self, mode)
      1176│         except FileNotFoundError:
      1177│             if not parents or self.parent == self:
      1178│                 raise
      1179│             self.parent.mkdir(parents=True, exist_ok=True)
Cannot install pycparser.
Error: Process completed with exit code 1.

pipx: command not found in v3 action

v3 action fails because pipx is not on PATH

name: Upload Python Package

on:
  pull_request:
    branches:
      - main
    types: [opened, synchronize]
  release:
    types: [created, published]
  workflow_dispatch:

jobs:
  publish:
    runs-on: ubuntu-20.04
    permissions:
      contents: "read"
      id-token: "write"
      pull-requests: "write"
    env:
      POETRY_VERSION: 1.5.0
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version-file: ".python-version"
          cache-dependency-path: "poetry.lock"
      - name: Setup poetry
        uses: abatilo/actions-poetry@v3
        with:
          poetry-version: ${{ env.POETRY_VERSION }}
Run abatilo/actions-poetry@v3
Run pip install --user pipx
Collecting pipx
  Downloading pipx-1.4.3-py3-none-any.whl.metadata (17 kB)
Collecting argcomplete>=1.9.4 (from pipx)
  Downloading argcomplete-3.2.1-py3-none-any.whl.metadata (16 kB)
Requirement already satisfied: packaging>=20 in /tmp/_tool/Python/3.10.13/x64/lib/python3.10/site-packages (from pipx) (23.2)
Requirement already satisfied: platformdirs>=2.1 in /tmp/_tool/Python/3.10.13/x64/lib/python3.10/site-packages (from pipx) (3.[11](https://github.com/digestaid/ai-classifier/actions/runs/7598094134/job/20693690876?pr=366#step:4:12).0)
Requirement already satisfied: tomli in /tmp/_tool/Python/3.10.13/x64/lib/python3.10/site-packages (from pipx) (2.0.1)
Collecting userpath!=1.9.0,>=1.6 (from pipx)
  Downloading userpath-1.9.1-py3-none-any.whl.metadata (3.0 kB)
Collecting click (from userpath!=1.9.0,>=1.6->pipx)
  Downloading click-8.1.7-py3-none-any.whl.metadata (3.0 kB)
Downloading pipx-1.4.3-py3-none-any.whl (65 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 65.1/65.1 kB 3.6 MB/s eta 0:00:00
Downloading argcomplete-3.2.1-py3-none-any.whl (42 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42.3/42.3 kB 4.1 MB/s eta 0:00:00
Downloading userpath-1.9.1-py3-none-any.whl (9.1 kB)
Downloading click-8.1.7-py3-none-any.whl (97 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.9/97.9 kB 6.2 MB/s eta 0:00:00
Installing collected packages: click, argcomplete, userpath, pipx
  WARNING: The script userpath is installed in '/root/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script pipx is installed in '/root/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed argcomplete-3.2.1 click-8.1.7 pipx-1.4.3 userpath-1.9.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

Notice:  A new release of pip is available: [23](https://github.com/digestaid/ai-classifier/actions/runs/7598094134/job/20693690876?pr=366#step:4:25).0.1 -> 23.3.2
Notice:  To update, run: pip install --upgrade pip
/tmp/_temp/9ce4d60b-ea35-4dc7-b344-c0[26](https://github.com/digestaid/ai-classifier/actions/runs/7598094134/job/20693690876?pr=366#step:4:28)0ba88c0f.sh: line 2: pipx: command not found

dependabot upgrades to version 3.7.4 of this GH-action

Hi-

This morning we received a notification to upgrade to version 3.7.4 of this action. I thought the numbering was weird, but the commits seemed to be legit.

However, our deploy failed because we use the poetry-version parameter. On closer inspection, it seems that dependabot is trying to upgrade to a previous version of poetry, since that version seems to have fewer commits (and is from 2019).

As no official release has been made, I'm not sure why the github-actions package-ecosystem dependabot is doing this.
See:
Selection_719
And:
Selection_720

Switch to python-buster for manylinux wheel (mypy -> typed_ast) support?

The choice to use alpine in the build image makes using mypy somewhere between difficult to impossible.

$ docker run --rm -it python:3.8.0-alpine3.10 pip install mypy
Collecting mypy
  Downloading https://files.pythonhosted.org/packages/f8/11/9b81379e84b066ee6f1b906b00a35220f15e0fcd87307c50768382d9e831/mypy-0.740-py3-none-any.whl (1.7MB)
     |████████████████████████████████| 1.7MB 919kB/s 
Collecting typing-extensions>=3.7.4
  Downloading https://files.pythonhosted.org/packages/03/92/705fe8aca27678e01bbdd7738173b8e7df0088a2202c80352f664630d638/typing_extensions-3.7.4.1-py3-none-any.whl
Collecting mypy-extensions<0.5.0,>=0.4.0
  Downloading https://files.pythonhosted.org/packages/5c/eb/975c7c080f3223a5cdaff09612f3a5221e4ba534f7039db34c35d95fa6a5/mypy_extensions-0.4.3-py2.py3-none-any.whl
Collecting typed-ast<1.5.0,>=1.4.0
  Downloading https://files.pythonhosted.org/packages/34/de/d0cfe2ea7ddfd8b2b8374ed2e04eeb08b6ee6e1e84081d151341bba596e5/typed_ast-1.4.0.tar.gz (206kB)
     |████████████████████████████████| 215kB 1.9MB/s 
Building wheels for collected packages: typed-ast
  Building wheel for typed-ast (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-no1222u2/typed-ast/setup.py'"'"'; __file__='"'"'/tmp/pip-install-no1222u2/typed-ast/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-_59ecc5c --python-tag cp38
       cwd: /tmp/pip-install-no1222u2/typed-ast/
  Complete output (23 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.8
  creating build/lib.linux-x86_64-3.8/typed_ast
  copying typed_ast/ast3.py -> build/lib.linux-x86_64-3.8/typed_ast
  copying typed_ast/conversions.py -> build/lib.linux-x86_64-3.8/typed_ast
  copying typed_ast/ast27.py -> build/lib.linux-x86_64-3.8/typed_ast
  copying typed_ast/__init__.py -> build/lib.linux-x86_64-3.8/typed_ast
  package init file 'ast3/tests/__init__.py' not found (or not a regular file)
  creating build/lib.linux-x86_64-3.8/typed_ast/tests
  copying ast3/tests/test_basics.py -> build/lib.linux-x86_64-3.8/typed_ast/tests
  running build_ext
  building '_ast27' extension
  creating build/temp.linux-x86_64-3.8
  creating build/temp.linux-x86_64-3.8/ast27
  creating build/temp.linux-x86_64-3.8/ast27/Parser
  creating build/temp.linux-x86_64-3.8/ast27/Python
  creating build/temp.linux-x86_64-3.8/ast27/Custom
  gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -Iast27/Include -I/usr/local/include/python3.8 -c ast27/Parser/acceler.c -o build/temp.linux-x86_64-3.8/ast27/Parser/acceler.o
  unable to execute 'gcc': No such file or directory
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for typed-ast

vs a simple python(-buster) where the wheels work:

$ docker run --rm -it python pip install mypy
Collecting mypy
  Downloading https://files.pythonhosted.org/packages/77/96/6de3a8bb7441550361fedf9b43c45557e10246cff23ca3fac65e4acf20c1/mypy-0.740-cp38-cp38-manylinux1_x86_64.whl (23.9MB)
     |████████████████████████████████| 23.9MB 1.1MB/s 
Collecting typed-ast<1.5.0,>=1.4.0
  Downloading https://files.pythonhosted.org/packages/f2/4f/2f98f0c6929a725ba22c750838a4424be5053d8fc76f0f018424ebecc62e/typed_ast-1.4.0-cp38-cp38-manylinux1_x86_64.whl (768kB)
     |████████████████████████████████| 778kB 1.5MB/s 
Collecting mypy-extensions<0.5.0,>=0.4.0
  Downloading https://files.pythonhosted.org/packages/5c/eb/975c7c080f3223a5cdaff09612f3a5221e4ba534f7039db34c35d95fa6a5/mypy_extensions-0.4.3-py2.py3-none-any.whl
Collecting typing-extensions>=3.7.4
  Downloading https://files.pythonhosted.org/packages/03/92/705fe8aca27678e01bbdd7738173b8e7df0088a2202c80352f664630d638/typing_extensions-3.7.4.1-py3-none-any.whl
Installing collected packages: typed-ast, mypy-extensions, typing-extensions, mypy
Successfully installed mypy-0.740 mypy-extensions-0.4.3 typed-ast-1.4.0 typing-extensions-3.7.4.1

Would you consider a switch to the standard python image?

Recommend to give the python version

As is, your action is unusable because you are using a fixed version of python FROM python:3.8.0-alpine3.10. I'd suggest, either, have the python version setup by the user using the action or specify that you are only supporting the last version of python.

Support Python 3.8

Could you please consider supporting official 3.8 python version?
Would be great to be possible to use this useful github action for projects that moved to newest version.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.