Giter Site home page Giter Site logo

install-poetry's People

Contributors

cclauss avatar connortann avatar dependabot[bot] avatar eifinger avatar jennydaman avatar jonasks avatar macbre avatar mahmoudhossam avatar mario-bermonti avatar marvinxu avatar mattkram avatar miigotu avatar philippwillms avatar rackreaver avatar raffclar avatar rgerum avatar rlam3 avatar ruohola avatar sondrelg avatar tmakruck avatar vladdoster avatar willfrey 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  avatar

install-poetry's Issues

Question: Can it install poetry from a specific commit?

There is currently an error with poetry on Windows and the fix has not been integrated into released version.

The current recommendation is to install using:
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python - --git https://github.com/serverwentdown/[email protected]

Would something like this be possible with this action?

Why is `poetry install` executed two times in the examples?

I'm referring to this section in the examples:

#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
  if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
  run: poetry install --no-interaction --no-root
#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install library
  run: poetry install --no-interaction

Why is it necessary to additionally call poetry install --no-interaction --no-root when a cache has been restored? Why is a single poetry install not enough in this case?

Thanks in advance for helping me and maybe other people understand this a bit better

urllib.error.URLError: <urlopen error unknown url type: https>

When running the install poetry action with Python 3.11, I am getting the following error:

File "/opt/actions-runner/_work/_tool/Python/3.11.3/x64/lib/python3.11/urllib/request.py", line 1419, in unknown_open
raise URLError('unknown url type: %s' % type)
urllib.error.URLError:

The configured steps are:

steps:
      - name: Check out repository
        uses: actions/checkout@v3
      - name: Set up python
        id: setup-python
        uses: actions/setup-python@v4
        with:
            python-version: '3.11'
      - name: Install Poetry
        uses: snok/install-poetry@v1
        with:
            virtualenvs-create: true
            virtualenvs-in-project: true
            installer-parallel: true

poetry: command not found - When running multiple self-hosted runners on the same machine.

We use the snok action to install poetry in a GitHub action:

    - name: Install Poetry
      uses: snok/install-poetry@v1

We randomly get errors like this one:

Setting Poetry installation path as /home/lightly/.local
Installing Poetry 👷
Retrieving Poetry metadata
The latest version (1.4.2) is already installed.
/home/lightly/actions-runner/runner_01/_work/_actions/snok/install-poetry/v1/main.sh: line 36: poetry: command not found
Error: Process completed with exit code 127.

Then retriggering exactly the same job sometimes lets it run through:

Run snok/install-poetry@v1
Run $GITHUB_ACTION_PATH/main.sh
Setting Poetry installation path as /home/lightly/.local
Installing Poetry 👷
Retrieving Poetry metadata
# Welcome to Poetry!
This will download and install the latest version of Poetry,
...
Installing Poetry (1.4.2): Done
Poetry (1.4.2) is installed now. Great!
You can test that everything is set up by executing:
`poetry --version`
Installation completed. Configuring settings 🛠
Done ✅

The big difference is that the first (failing) run found an already installed version.

Error cause suspicion

The runs are executed by self-hosted runners on a custom machine with ubuntu 20.04. As the machine has multiple runners, it can happen that multiple runners install and use poetry at the same time. They might even install different versions, as they might run for different branches. This can be the reason for the error, e.g. one runner cleaning up a poetry install that another runner relies on.

Runner-specific poetry installation

How can we install poetry using the snok action in a runner specific directory? Currently, it always uses the home directory, see INSTALL_PATH="$HOME/.local"

Our machine:

lightly@lightly-gpu-01:~$ ls /home/lightly/.local
bin  lib  share  venv  VERSION
lightly@lightly-gpu-01:~$ ls ~/actions-runner
cpu_runner_01  cpu_runner_03  cpu_runner_05  cpu_runner_02  cpu_runner_04  cpu_runner_06
lightly@lightly-gpu-01:~$ 

settings.virtualenvs.in-project does not exist

see https://stackoverflow.com/questions/62029371/python-poetry-error-setting-settings-virtualenvs-in-project-does-not-exist

The config has changed with the release of poetry 1.0. The prefix settings is no longer needed. So just type poetry config virtualenvs.in-project true.

2022-03-24T16:30:08.7329832Z 
2022-03-24T16:30:08.7330388Z   ValueError
2022-03-24T16:30:08.7330944Z 
2022-03-24T16:30:08.7331540Z   Setting settings.virtualenvs.in-project does not exist
2022-03-24T16:30:08.7331786Z 
2022-03-24T16:30:08.7335001Z   at /opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/site-packages/poetry/console/commands/config.py:248 in handle
2022-03-24T16:30:08.7517620Z       244│                 raise ValueError("You must pass exactly 1 value")
2022-03-24T16:30:08.7518169Z       245│ 
2022-03-24T16:30:08.7518704Z       246│             return 0
2022-03-24T16:30:08.7519935Z       247│ 
2022-03-24T16:30:08.7522236Z     → 248│         raise ValueError("Setting {} does not exist".format(self.argument("key")))
2022-03-24T16:30:08.7522703Z       249│ 
2022-03-24T16:30:08.7524603Z       250│     def _handle_single_value(self, source, key, callbacks, values):
2022-03-24T16:30:08.7525812Z       251│         validator, normalizer, _ = callbacks
2022-03-24T16:30:08.7526171Z       252│ 
2022-03-24T16:30:08.7958082Z ##[error]Process completed with exit code 1.

Cache not found

Caching the poetry install works fine but seem to be having issues with caching the virtualenv, see:

Screenshot 2023-07-05 at 12 39 54 PM

Here is the workflow definition:

  lint:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Set up python
        id: setup-python
        uses: actions/setup-python@v4
        with:
          python-version: '3.10.9'
      
      - name: Install and configure poetry
        uses: snok/install-poetry@v1
        with:
          virtualenvs-create: true
      
      - name: Load cached Poetry installation
        id: cached-poetry
        uses: actions/cache@v3
        with:
          path: ~/.local  # the path depends on the OS
          key: poetry-0  # increment to reset cache

      - name: Load cached venv
        id: cached-poetry-dependencies
        uses: actions/cache@v3
        with:
          path: .venv
          key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

      - name: Install dependencies
        if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
        run: poetry install --no-interaction --no-root
      
      - name: Lint
        run: |
          poetry run ruff . --format github
          poetry run black --skip-string-normalization .
          poetry run isort .

syntax error near unexpected token `newline'

Run snok/[email protected]
with:
virtualenvs-create: true
virtualenvs-in-project: true
version: 1.1.6
virtualenvs-path: {cache-dir}/virtualenvs
env:
pythonLocation: /opt/hostedtoolcache/Python/3.8.10/x64
LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.8.10/x64/lib
/tmp/tmp.TEydkfsscF9p: line 2: syntax error near unexpected token newline' /tmp/tmp.TEydkfsscF9p: line 2: '
Error: Process completed with exit code 2.

Error with cache on windows

Hello, after restoring the cache of poetry installation on windows, this error occurs:
image

But poetry definitely exists in that folder:
image

v1.1.3 broken caching of virtualenv

Our use case is as follows:

      - name: Install Python
        uses: actions/setup-python@v2
        with:
          python-version: "3.8"

      - name: Install Python poetry
        uses: snok/[email protected]
        with:
          virtualenvs-create: true
          virtualenvs-in-project: true

      - name: Load cached venv
        id: cached-poetry-dependencies
        uses: actions/cache@v2
        with:
          path: yari/deployer/.venv
          key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}

      - name: Install deployer
        if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
        run: |
          cd yari/deployer
          poetry install

But when we got upgraded to version v1.1.3 it broke things.

The virtual environment found in /home/runner/work/content/content/yari/deployer/.venv seems to be broken.
Recreating virtualenv deployer in /home/runner/work/content/content/yari/deployer/.venv
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/hostedtoolcache/Python/3.8.9/x64/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'deployer'

Full run here: https://github.com/mdn/content/runs/2359767214?check_suite_focus=true

We've never had this problem with v1.1.2 before.

The poetry install takes 10 seconds so it was nice to be able to cache it.

Venv procedure Windows in README

The Venv procedure outlined in the README for using a matrix that includes windows is incorrect.
For windows it would be ".venv/scripts/activate", if you precede that with "source" it will throw an error that there's no command named source. This makes using source $venv with a windows workflow impossible unfortunately. Maybe just include "source" in the $venv variable and exclude it for windows version?

PyTest not recognized in Github Action Workflow with poetry 1.2.0b3

Hello,

I upgraded my local dev environment from peotry 1.1.14 to poetry 1.2.0b3, as this version contains many bugfixes and useful enhancements. Accodingly, I adjusted the .yml configuration in my private GitHub repo for the CI-CD pipeline.

While the poetry installation works fine, there is an issue with pytest. See the details below.

What I changed is simply the with version: part of the snok/install-poetry@v1 part.

PyTest error log

Run poetry run pytest tests/ --cov=wksim --cov-report=xml
poetry run pytest tests/ --cov=wksim --cov-report=xml
shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
env:
pythonLocation: C:\hostedtoolcache\windows\Python\3.8.10\x64
VENV: .venv/scripts/activate
'pytest' is not recognized as an internal or external command,
operable program or batch file.
Error: Process completed with exit code 1.

YAML config

jobs:
  ci:
    # Set up operating system
    runs-on: windows-latest
    strategy:
      matrix:
        python-version: ["3.8", "3.9"]

    # Define job steps
    steps:
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v3
      with:
        python-version: ${{ matrix.python-version }}

    - name: Check-out repository
      uses: actions/checkout@v2

    - name: Run pre-commit hooks
      run: |
        python -m pip install --upgrade pip
        pip install pre-commit
        pre-commit install
        pre-commit run --all-files

    - name: Install poetry
      uses: snok/install-poetry@v1
      with:
        version: 1.2.0b3

    - name: Install package
      run: poetry install

    - name: Test with pytest
      run: poetry run pytest tests/ --cov=wksim --cov-report=xml

Unable to use '~' in virtualenvs-path from v1.2.0

Hello!

We recently updated to v1.2.0 and found that our virtualenvs were being put in the wrong place; instead of ~/.cache/virtualenvs they were being put into <project-dir>/~/.cache/virtualenvs.

Our action looked like this:

      - name: Install and configure poetry
        uses: snok/[email protected]
        with:
          virtualenvs-in-project: false
          virtualenvs-path: ~/.cache/virtualenvs

I did a bit of investigation and I think this is due to the github input being directly quoted: https://github.com/snok/install-poetry/blob/main/action.yml#L62, whereas previously it was not quoted before being passed to the script: https://github.com/snok/install-poetry/blob/v1.1.8/action.yml#L40, which allowed the shell to expand it.

I can of course hardcode the home directory instead of using ~ but this seems like a common case, so would it be worth changing this to allow expansion again?

Overwriting main.sh

I might be completely wrong, and if so, I'm very sorry for the noise, but prior to running this action I was skimming through the source code, and realized that if someone happens to have a main.sh (or a get-poetry.sh but that more uncommon) file at the root of their repository, this action was likely going to overwrite the scripts, then delete them, and break things (albeit just in the CI run). It might be worth copying the script in /tmp (or using mktemp).

Again, I may well have completely misread the code and if so, I'm sorry, but if I didn't, this may avoid a very very weird and hard-to-debug bug.

☮️ ❤️ and thanks for this action :)

Add support to install poetry plugins

Poetry 1.2+ will now support plugins. It will be a good idea to support installing plugins if the poetry version is 1.2+.
That is by adding the below lines to the main.sh script:

<...>
plugins=$7
<...>
poetry plugin add $plugins
<...>

.venv caching is not working using composable actions?

I am running this action as part of a workflow to build a package. In the workflow, at build time, I generate a new lockfile for CI (as the usual lockfile uses an internal pypi repo not available to the GitHub actions runner).

Then I load this lockfile and the .venv in future test steps such as pytest, so that each step can be a job but each step does not have to re-create the lockfile and re-install from scratch.

However, I must be doing something wrong as the installed dependencies are not found even after I restore and source the cache-restored .venv/bin/activate and restore the lockfile as well.

The build and restore are themselves each a composable action, as I have many tests that will need to run these..

Is there something about the composable action runtime that is not allowing the .venv to be restored when used in a step of a different workflow?

is the issue perhaps that I also need to cache and restore the poetry install itself?

Add input for POETRY_HOME

Hi snok

I'm working on a project which caches the poetry installation to speed up our test runs. We recently updated from 1.1.4 to 1.1.6 but the new installation location is not ideal for caching as it would it would be caching the contents of the entire ~/.local directory when we would prefer to cache only the poetry installation

It would be great if the path value used for poetry home could be supplied as an input to the workflow action instead of the currently hard coded implementation here:

POETRY_HOME=$path python3 $installation_script --yes --version=$version

I'll open a pull with a proposed implementation sometime tomorrow

Make the action work on all Windows shells

There should be a simple way to run an os-matrix, including windows, regardless of the shell you're running. We can detect which shell is running and adapt accordingly.

When we say "all" shells, I guess we actually only care about

  • powershell
  • bash
  • cmd

And cmd might not be that important if we can't easily fix it, but powershell is the default and bash is what we've recommended in the past.

Does not respect POETRY_HOME

I'm trying to install poetry in an alternative location as per the documentation

The problem with this action is that even when POETRY_HOME is set, it still installs to the default location.

Example minimal workflow:

name: Test Install Poetry

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    env:
      POETRY_HOME: /usr
    steps:
      - uses: actions/checkout@v3
      - name: Install Poetry
        uses: snok/install-poetry@v1

Example run: https://github.com/mahmoudhossam/test-poetry/actions/runs/5552599337/jobs/10140141699

Not working with pyhon 3.10?

I'd like to run tests with a Poetry environment and python 3.10.
My pyproject.toml also enforces this python version

python = ">=3.10,<3.11"

I grabbed the example from the README (with very minor modifications) and expected it to work:

name: tests

on:
  push:
    branches:
      - main

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository
        uses: actions/checkout@v2
      - name: Set up python
        uses: actions/setup-python@v2
        with:
          python-version: '3.10'
      - name: Install Poetry
        uses: snok/install-poetry@v1
        with:
          virtualenvs-create: true
          virtualenvs-in-project: true
          installer-parallel: true
      - name: Load cached venv
        id: cached-poetry-dependencies
        uses: actions/cache@v2
        with:
          path: .venv
          key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
      - name: Install dependencies
        if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
        run: poetry install --no-interaction --no-root
      - name: Install library
        run: poetry install --no-interaction
      - name: Print info
        run: |
          python --version
          poetry env info
          poetry run python --version
      - name: Run tests
        run: make test

The "Print info" step is there just for troubleshooting. It returns:

python --version
Python 3.10.1

poetry env info
Python:         3.9.9
Implementation: CPython
Path:           /home/runner/work/advent-of-code-2021/advent-of-code-2021/.venv
Valid:          True
System
Platform: linux
OS:       posix
Python:   /opt/hostedtoolcache/Python/3.9.9/x64

poetry run python --version
Python 3.9.9

Even though there is python 3.10.1 up and running, it is clearly not picked up by Poetry.

Any recommendations would be appreciated.

Error: `GLIBC_2.34' not found

We are getting intermittent errors in our CI pipeline during the snok/install-poetry@v1 task:

Run snok/install-poetry@v1

Run $GITHUB_ACTION_PATH/main.sh

Setting Poetry installation path as /github/home/.local

Installing Poetry :builder:

python3: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by python3)
python3: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.35' not found (required by /__w/_tool/Python/3.11.1/x64/lib/libpython3.11.so.1.0)
python3: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /__w/_tool/Python/3.11.1/x64/lib/libpython3.11.so.1.0)
python3: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /__w/_tool/Python/3.11.1/x64/lib/libpython3.11.so.1.0)
python3: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /__w/_tool/Python/3.11.1/x64/lib/libpython3.11.so.1.0)
Error: Process completed with exit code 1.

The `with` `virtualenvs-in-project` setting does not seem to work for me

My action looks like this:

name: Build MkDocs

on: 
  push:
    branches: [main]

permissions:
  contents: write

jobs:
  deploy:

    runs-on: ubuntu-latest

    steps:
      - name: Check-out repository
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Setup python
        id: setup-python
        uses: actions/setup-python@v4
        with:
          python-version: '3.10'
      - name: Load cached Poetry installation
        id: cached-poetry
        uses: actions/cache@v3
        with:
          path: ~/.local
          key: poetry-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}
      - name: Install Poetry
        if: steps.cached-poetry.outputs.cache-hit != 'true'
        uses: snok/install-poetry@v1
      - name: Configure Poetry
        run: poetry config virtualenvs.in-project true
      - name: Load cached venv
        id: cached-poetry-dependencies
        uses: actions/cache@v3
        with:
          path: .venv
          key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
      - name: Install dependencies
        if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
        run: poetry install --no-interaction --no-root --with docs
      - name: Install project
        run: poetry install --no-interaction --with docs
      - name: Deploy MkDocs
        run: |
          source .venv/bin/activate
          mkdocs gh-deploy --force --clean --verbose

I used to instead use the with usage underneath the action, but I kept getting an error that on the "Install Dependencies" stage of the workflow it was looking for a virtual env outside of the project folder. Is this a problem with caching the install?

Poetry fails on matrix strategies combinations

Hi,

I try to fix my workflow based on previous developers' experiences with this dependency management system. However, there is still not much still to bring the bugs to fly around. Among others, I cannot setup matrix.os as 'windows-latest' properly. Both, workflow file and error log, are below to consult:

URL: https://github.com/trouchet/appy/actions/runs/3778445115
Error log:

To get started you need Poetry's bin directory (C:\Users\runneradmin\.local\bin) in your `PATH`
environment variable.

Alternatively, you can call Poetry explicitly with `C:\Users\runneradmin\.local\bin\poetry`.

You can test that everything is set up by executing:

`poetry --version`

D:\a\_actions\snok\install-poetry\v1/main.sh: line 36: poetry: command not found

Skip poetry install step with cache hit

image

As you can see, poetry cache works, but it still takes 3s to "Install Poetry". Is it possible to skip this step when cache hit, just like "Install dependencies"?

Error on windows

Hi.
I am running a workflow, that runs on Mac and Windows.
Mac works perfectly fine.
But on Windows I get the following error:

D:\a_temp\ba90638b-3217-4c14-b352-615ff786d16c.sh: line 5: /c/Users/runneradmin/.poetry/env: No such file or directory
Error: Process completed with exit code 1.

`poetry install` stalls on Windows with warm cache

Dear Sondre,

thanks a stack for conceiving this excellent GitHub Action.

We already pinged you within earthobservations/wetterdienst#328 yesterday, where @gutzbenj was about to switch from Gr1N/setup-poetry to snok/install-poetry. However, he was still struggling with it so he was about to move on to abatilo/actions-poetry already.

Now that I've recognized that your GitHub Action probably has solved some problems specifically related to Windows environments already, I wanted to take the chance and created earthobservations/wetterdienst#331 in order to give us a chance to investigate more closely.

The observation is:

  • When running on Linux and macOS, everything works successfully on all occasions [1].
  • When running on Windows, the job succeeds when being on a cold cache [1].
  • When running on Windows, the job completely stalls on poetry install when running on a warm cache [2].

Maybe you already have an idea what might be going wrong there? Otherwise, I kindly ask for your support here - we really would like to see that download/environment caching also works appropriately on Windows.

With kind regards,
Andreas.

[1] https://github.com/earthobservations/wetterdienst/actions/runs/507426192
[2] https://github.com/earthobservations/wetterdienst/actions/runs/507437925

Running on windows doesn't link

Links to #windows but should link to #running-on-windows.

I can go ahead and make the change or someone else can too, just want to throw it out there.

image

`poetry install` stalls on ubuntu-latest

I don't know if this action is the problem, but I am not exactly sure where else to look, and I've seen other reports of poetry stalling. I've used the action for hundreds of runs, but lately the "Install Dependencies" step has stopped working (example here as the installation does not complete (and I have to stop the runner).

This is on ubuntu-latest. Any suggestion on how to debug/fix the problem would be welcome.

Caching doesn't work

Using the recommended settings caching does not work, it seems like things are cached correctly but calling source .venv/bin/activate results in a file not found error

on:
  push:
    branches-ignore:
      - main
name: Tests
jobs:
  test-round-pull:
    name: ground Pull
    runs-on: ubuntu-latest
    defaults:
      run:
        shell: bash
        working-directory: ground-pull
    steps:
      - uses: actions/checkout@v2
      - name: Setup Python
        uses: actions/setup-python@v2
        with:
          python-version: "3.8"
      - uses: harmon758/postgresql-action@v1
        with:
          postgresql version: "11"
          postgresql db: test-db
          postgresql user: postgres
          postgresql password: local_password
      - name: Check Postgres running
        run: |
          sleep 2
      - name: Check running containers
        run: docker ps -a
      #----------------------------------------------
      #  -----  install & configure poetry  -----
      #----------------------------------------------
      - name: Install Poetry
        uses: snok/install-poetry@v1
        with:
          version: 1.1.10
          virtualenvs-create: true
          virtualenvs-in-project: true
          installer-parallel: true
      #----------------------------------------------
      #       load cached venv if cache exists
      #----------------------------------------------
      - name: Load cached venv
        id: cached-poetry-dependencies
        uses: actions/cache@v2
        with:
          path: .venv
          key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
      #----------------------------------------------
      # install dependencies if cache does not exist
      #----------------------------------------------
      - name: Install dependencies
        if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
        run: poetry install --no-interaction --no-root
      #----------------------------------------------
      #              run test suite
      #----------------------------------------------
      - name: Run tests
        run: |
          source .venv/bin/activate
          poetry run make check-format
          poetry run make mypy
          poetry run make lint
          poetry run make test

Monorepo

Hi @sondrelg

This looks very neat - I like it! Nice, simple and flexible API you provide.

One question; do you know if this can be tweaked for a monorepo with multiple python applications?

Windows Latest on Python 3.8 Constantly Fails

For some reason, Windows-2022 is now failing for me on Python 3.8 only:

Run snok/install-poetry@v[1](https://github.com/adam-grant-hendry/qtpygraph/actions/runs/3202205327/jobs/5230946943#step:6:1).3.2
Run $GITHUB_ACTION_PATH/main.sh

Setting Poetry installation path as C:/Users/runneradmin/AppData/Roaming/Python/Scripts

Installing Poetry 👷

Retrieving Poetry metadata

# Welcome to Poetry!

This will download and install the latest version of Poetry,
a dependency and package manager for Python.

It will add the `poetry` command to Poetry's bin directory, located at:

C:\Users\runneradmin\AppData\Roaming\Python\Scripts\bin

You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.

Installing Poetry (1.2.1)
Installing Poetry (1.2.1): Creating environment
Installing Poetry (1.2.1): An error occurred. Removing partial environment.
Traceback (most recent call last):
  File "C:/Users/RUNNER~1/AppData/Local/Temp/tmp.0IGyZ1qQC7", line 9[40](https://github.com/adam-grant-hendry/qtpygraph/actions/runs/3202205327/jobs/5230946943#step:6:42), in <module>
    sys.exit(main())
  File "C:/Users/RUNNER~1/AppData/Local/Temp/tmp.0IGyZ1qQC7", line 919, in main
    return installer.run()
  File "C:/Users/RUNNER~1/AppData/Local/Temp/tmp.0IGyZ1qQC7", line 550, in run
    self.install(version)
  File "C:/Users/RUNNER~1/AppData/Local/Temp/tmp.0IGyZ1qQC7", line 571, in install
    with self.make_env(version) as env:
  File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "C:/Users/RUNNER~1/AppData/Local/Temp/tmp.0IGyZ1qQC7", line 643, in make_env
    raise e
  File "C:/Users/RUNNER~1/AppData/Local/Temp/tmp.0IGyZ1qQC7", line 629, in make_env
    yield VirtualEnvironment.make(env_path)
  File "C:/Users/RUNNER~1/AppData/Local/Temp/tmp.0IGyZ1qQC7", line 319, in make
    builder.create(target)
  File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\venv\__init__.py", line 68, in create
    self._setup_pip(context)
  File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\venv\__init__.py", line 289, in _setup_pip
    subprocess.check_output(cmd, stderr=subprocess.STDOUT)
  File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\subprocess.py", line [41](https://github.com/adam-grant-hendry/qtpygraph/actions/runs/3202205327/jobs/5230946943#step:6:43)5, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\subprocess.py", line [49](https://github.com/adam-grant-hendry/qtpygraph/actions/runs/3202205327/jobs/5230946943#step:6:51)3, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\subprocess.py", line 8[58](https://github.com/adam-grant-hendry/qtpygraph/actions/runs/3202205327/jobs/5230946943#step:6:60), in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\hostedtoolcache\windows\Python\3.8.10\x[64](https://github.com/adam-grant-hendry/qtpygraph/actions/runs/3202205327/jobs/5230946943#step:6:66)\lib\subprocess.py", line 1311, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
Error: Process completed with exit code 1.

Action versioning not following GitHub recommendations

GitHub Actions has recommendations on how to handle releases via tagging:

  • Create a release using semantic versioning. For more information, see "Creating releases."
  • Move the major version tag (such as v1, v2) to point to the Git ref of the current release. [...]

It would be great if this repository adapts the suggested recommendations 🙂.

That way every user could simply do

uses: snok/install-poetry@v1

in their GitHub action and will always get the latest 1.X.Y version.

poetry config unaffected by action inputs

I'm a novice with GitHub Actions, so let me preface this by saying that this issue could be entirely on my end :)

Anyways, I'm seeing that virtualenvs.in-project is always set to true when I run poetry config --list as a run action despite the default value for the action input virtualenvs-in-project being false. I've also noticed that setting the non-local config in a subsequent action, as per the README, does not actually affect the poetry config. Setting subsequent configs with --local is visible.

I did notice that the version action input is respected because I tested setting this to latest, 1.1.10 and 1.1.9 to check if it would respect that and it did.

Am I doing something wrong here? Taking a stab but perhaps the system-wide poetry config file is not writable?

Thanks!

Correct virtualenvs-path for caching

I am wondering if virtualenvs-path: .venv is missing? Following the example, only by setting .venv allows using the cache.

So it actually looks like:

- name: Install Poetry 
         uses: snok/install-poetry@v1 
         with: 
           virtualenvs-create: true 
           virtualenvs-in-project: true 
           installer-parallel: true
           virtualenvs-path: .venv

install-poetry/README.md

Lines 111 to 126 in 2d5fc9c

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

Trouble using poetry plugins with poetry 1.1

Hi,

It seems that when Poetry is installed with this action, other plugins such as poetry-dynamic-versioning do not function as expected. From this previous issue, it looks like the extensions do not function when Poetry is installed with install-poetry.py.

Hopefully this will all be sorted when the plugin system with Poetry 1.2 is released, but for now it would be good to get poetry extensions working with Poetry 1.1 with this action.

The issue seems to be that if the extensions are installed with e.g. pip install poetry-dynamic-versioning, the poetry interpreter cannot see that package. A proposed workaround is to specifically access the pip associated with the poetry install, e.g. ${XDG_DATA_HOME:-~/.local/share}/pypoetry/venv/bin/pip install poetry-dynamic-versioning.

I haven't seen documentation on what XDG_DATA_HOME means. Is this the right pip path to use with this action?

Installation of poetry with python 3.9 is failing on latest github runner image

Our builds started failing after a github runner image update.

On the github runner image Version: 20221018.2 the installation with snok/install-poetry leads to a non function poetry install. The install step does not fail, but poetry is not usable afterwards. Release notes of the github runner update: https://github.com/actions/runner-images/releases/tag/ubuntu20%2F20221018.2

The exact same workflow works with the github runner image version Version: 20221002.2 without issues.

The logs show, that there seems to be an issue within the snok/install-poetry step:

2022-10-24T07:46:33.6244875Z /home/runner/work/_actions/snok/install-poetry/2bf112a0f6979928eb6b011f39700db589c5961e/main.sh: /home/runner/.local//bin/poetry: /home/runner/.local/venv/bin/python: bad interpreter: No such file or directory

You can see the /home/runner/.local/venv/bin/python: bad interpreter: No such file or directory error in the logs.
I am not exactly sure what the issue is but it sounds like the python path is off.

The only difference it the github runner image used, apparently github updated the image in between builds which led the builds to fail. I've attached the logs starting at the checkout step.

Used workflow steps:

jobs:
  test:
    name: Run Tests 
    runs-on: ubuntu-latest
    
    steps:
    - name: Checkout git repository 🕝
      uses: actions/checkout@v3
    - name: Set up Python 3.9 🐍
      uses: actions/setup-python@0ebf233433c08fb9061af664d501c3f3ff0e9e20  # v3.0
      with:
        python-version: '3.9'

    - name: Cache poetry install
      uses: actions/cache@v2
      with:          
        path: ~/.local
        key: poetry-1.1.13-0

    - uses: snok/install-poetry@2bf112a0f6979928eb6b011f39700db589c5961e
      with:
        version: 1.1.13
        virtualenvs-create: true
        virtualenvs-in-project: true

    - name: Cache python dependencies
      id: cache-deps
      uses: actions/cache@v2
      with:
        path: services/analytics/.venv
        key: pydeps-${{ hashFiles('**/poetry.lock') }}

    - name: Install Dependencies & Project📦
      run: |
        poetry run python -m pip install -U pip

Failing Log:

2022-10-24T07:46:32.1377942Z ##[group]Run actions/setup-python@0ebf233433c08fb9061af664d501c3f3ff0e9e20
2022-10-24T07:46:32.1378415Z with:
2022-10-24T07:46:32.1378707Z   python-version: 3.9
2022-10-24T07:46:32.1379199Z   token: ***
2022-10-24T07:46:32.1379414Z env:
2022-10-24T07:46:32.1379714Z   DEFAULT_PYTHON_VERSION: 3.9
2022-10-24T07:46:32.1380076Z   POETRY_VERSION: 1.1.13
2022-10-24T07:46:32.1380315Z ##[endgroup]
2022-10-24T07:46:32.2926708Z ##[warning]The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
2022-10-24T07:46:32.2937466Z Successfully setup CPython (3.9.15)
2022-10-24T07:46:32.3028666Z ##[group]Run actions/cache@v2
2022-10-24T07:46:32.3028983Z with:
2022-10-24T07:46:32.3029288Z   path: ~/.local
2022-10-24T07:46:32.3029535Z   key: poetry-1.1.13-0
2022-10-24T07:46:32.3029935Z env:
2022-10-24T07:46:32.3030214Z   DEFAULT_PYTHON_VERSION: 3.9
2022-10-24T07:46:32.3030477Z   POETRY_VERSION: 1.1.13
2022-10-24T07:46:32.3030863Z   pythonLocation: /opt/hostedtoolcache/Python/3.9.15/x64
2022-10-24T07:46:32.3031261Z   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.15/x64/lib
2022-10-24T07:46:32.3031607Z ##[endgroup]
2022-10-24T07:46:32.5399973Z ##[warning]The `save-state` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
2022-10-24T07:46:33.1003531Z Received 23841880 of 23841880 (100.0%), 65.0 MBs/sec
2022-10-24T07:46:33.1008989Z Cache Size: ~23 MB (23841880 B)
2022-10-24T07:46:33.1034455Z [command]/usr/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/b269c137-bd98-405d-9354-9475dc78ee25/cache.tzst -P -C /home/runner/work/rasa-pro-services/rasa-pro-services
2022-10-24T07:46:33.3733626Z Cache restored successfully
2022-10-24T07:46:33.3780136Z ##[warning]The `save-state` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
2022-10-24T07:46:33.3810534Z 
2022-10-24T07:46:33.3814989Z ##[warning]The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
2022-10-24T07:46:33.3818615Z Cache restored from key: poetry-1.1.13-0
2022-10-24T07:46:33.4012950Z ##[group]Run snok/install-poetry@2bf112a0f6979928eb6b011f39700db589c5961e
2022-10-24T07:46:33.4013252Z with:
2022-10-24T07:46:33.4013459Z   version: 1.1.13
2022-10-24T07:46:33.4013694Z   virtualenvs-create: true
2022-10-24T07:46:33.4013961Z   virtualenvs-in-project: true
2022-10-24T07:46:33.4014265Z   virtualenvs-path: {cache-dir}/virtualenvs
2022-10-24T07:46:33.4014534Z   installer-parallel: true
2022-10-24T07:46:33.4014759Z env:
2022-10-24T07:46:33.4014979Z   DEFAULT_PYTHON_VERSION: 3.9
2022-10-24T07:46:33.4015223Z   POETRY_VERSION: 1.1.13
2022-10-24T07:46:33.4015524Z   pythonLocation: /opt/hostedtoolcache/Python/3.9.15/x64
2022-10-24T07:46:33.4015851Z   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.15/x64/lib
2022-10-24T07:46:33.4016122Z ##[endgroup]
2022-10-24T07:46:33.4263184Z ##[group]Run $GITHUB_ACTION_PATH/main.sh
2022-10-24T07:46:33.4263543Z �[36;1m$GITHUB_ACTION_PATH/main.sh�[0m
2022-10-24T07:46:33.4318390Z shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
2022-10-24T07:46:33.4318727Z env:
2022-10-24T07:46:33.4318952Z   DEFAULT_PYTHON_VERSION: 3.9
2022-10-24T07:46:33.4319439Z   POETRY_VERSION: 1.1.13
2022-10-24T07:46:33.4319741Z   pythonLocation: /opt/hostedtoolcache/Python/3.9.15/x64
2022-10-24T07:46:33.4320084Z   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.15/x64/lib
2022-10-24T07:46:33.4320349Z   VERSION: 1.1.13
2022-10-24T07:46:33.4320573Z   VIRTUALENVS_CREATE: true
2022-10-24T07:46:33.4320822Z   VIRTUALENVS_IN_PROJECT: true
2022-10-24T07:46:33.4321095Z   VIRTUALENVS_PATH: {cache-dir}/virtualenvs
2022-10-24T07:46:33.4321362Z   INSTALLER_PARALLEL: true
2022-10-24T07:46:33.4321605Z   INSTALLATION_ARGUMENTS: 
2022-10-24T07:46:33.4321826Z ##[endgroup]
2022-10-24T07:46:33.4769977Z 
2022-10-24T07:46:33.4771140Z �[33mSetting Poetry installation path as /home/runner/.local/�[0m
2022-10-24T07:46:33.4771593Z 
2022-10-24T07:46:33.4772152Z �[33mInstalling Poetry 👷�[0m
2022-10-24T07:46:33.4773198Z 
2022-10-24T07:46:33.6129957Z Retrieving Poetry metadata
2022-10-24T07:46:33.6130606Z 
2022-10-24T07:46:33.6131484Z The latest version (1.1.13) is already installed.
2022-10-24T07:46:33.6229634Z /home/runner/work/_actions/snok/install-poetry/2bf112a0f6979928eb6b011f39700db589c5961e/main.sh: /home/runner/.local//bin/poetry: /home/runner/.local/venv/bin/python: bad interpreter: No such file or directory
2022-10-24T07:46:33.6237560Z /home/runner/work/_actions/snok/install-poetry/2bf112a0f6979928eb6b011f39700db589c5961e/main.sh: /home/runner/.local//bin/poetry: /home/runner/.local/venv/bin/python: bad interpreter: No such file or directory
2022-10-24T07:46:33.6244875Z /home/runner/work/_actions/snok/install-poetry/2bf112a0f6979928eb6b011f39700db589c5961e/main.sh: /home/runner/.local//bin/poetry: /home/runner/.local/venv/bin/python: bad interpreter: No such file or directory
2022-10-24T07:46:33.6253202Z /home/runner/work/_actions/snok/install-poetry/2bf112a0f6979928eb6b011f39700db589c5961e/main.sh: /home/runner/.local//bin/poetry: /home/runner/.local/venv/bin/python: bad interpreter: No such file or directory
2022-10-24T07:46:33.6274989Z 
2022-10-24T07:46:33.6275904Z �[33mInstallation completed. Configuring settings 🛠�[0m
2022-10-24T07:46:33.6276394Z 
2022-10-24T07:46:33.6276727Z �[33mDone ✅�[0m
2022-10-24T07:46:33.6303177Z 
2022-10-24T07:46:33.6304312Z �[33mIf you are creating a venv in your project, you can activate it by running 'source .venv/bin/activate'. If you're running this in an OS matrix, you can use 'source $VENV' instead, as an OS agnostic option�[0m
2022-10-24T07:46:33.7518861Z ##[group]Run actions/cache@v2
2022-10-24T07:46:33.7519286Z with:
2022-10-24T07:46:33.7519500Z   path: services/analytics/.venv
2022-10-24T07:46:33.7519855Z   key: pydeps-9643f14b2d02941c37c631e0a382015bfc07be8867d51ba5a34a1c6dee70fd3d
2022-10-24T07:46:33.7520169Z env:
2022-10-24T07:46:33.7520384Z   DEFAULT_PYTHON_VERSION: 3.9
2022-10-24T07:46:33.7520636Z   POETRY_VERSION: 1.1.13
2022-10-24T07:46:33.7520919Z   pythonLocation: /opt/hostedtoolcache/Python/3.9.15/x64
2022-10-24T07:46:33.7521262Z   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.15/x64/lib
2022-10-24T07:46:33.7521549Z   VENV: .venv/bin/activate
2022-10-24T07:46:33.7521777Z ##[endgroup]
2022-10-24T07:46:33.8888514Z ##[warning]The `save-state` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
2022-10-24T07:46:33.9979197Z Cache not found for input keys: pydeps-9643f14b2d02941c37c631e0a382015bfc07be8867d51ba5a34a1c6dee70fd3d
2022-10-24T07:46:34.0118801Z ##[group]Run make install
2022-10-24T07:46:34.0119386Z �[36;1mmake install�[0m
2022-10-24T07:46:34.0169605Z shell: /usr/bin/bash -e {0}
2022-10-24T07:46:34.0169823Z env:
2022-10-24T07:46:34.0170050Z   DEFAULT_PYTHON_VERSION: 3.9
2022-10-24T07:46:34.0170298Z   POETRY_VERSION: 1.1.13
2022-10-24T07:46:34.0170599Z   pythonLocation: /opt/hostedtoolcache/Python/3.9.15/x64
2022-10-24T07:46:34.0170947Z   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.15/x64/lib
2022-10-24T07:46:34.0171233Z   VENV: .venv/bin/activate
2022-10-24T07:46:34.0171442Z ##[endgroup]
2022-10-24T07:46:34.0275316Z poetry run python -m pip install -U pip
2022-10-24T07:46:34.0283154Z make: poetry: Command not found

Issues with cached poetry installation: bad interpreter, no such file

Hi,

I've followed the instructions in the README for caching the poetry installation. It has been working well for several weeks, but recently has started failing with an error "bad interpreter: no such file or directory".

Our CI steps

https://github.com/bp/resqpy/blob/49f99ad3f135fde650cdd1959a9fdc1c6cbd3424/.github/actions/prepare-poetry/action.yml#L14-L30

  steps:
    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: ${{ inputs.python-version }}

    - name: Load cached Poetry installation
      uses: actions/cache@v2
      with:
        path: ~/.local  # the path depends on the OS
        key: poetry-0  # increment to reset cache

    - name: Install Poetry
      uses: snok/install-poetry@v1
      with:
        virtualenvs-create: true
        virtualenvs-in-project: true

Example failed job:

(Link to example job):

Prepare all required actions
Getting action download info
Download action repository 'actions/setup-python@v2' (SHA:7f80679172b057fc5e90d70d197929d454754a5a)
Download action repository 'actions/cache@v2' (SHA:937d24475381cd9c75ae6db12cb4e79714b926ed)
Download action repository 'snok/install-poetry@v1' (SHA:2bf112a0f6979928eb6b011f39700db589c5961e)
Run ./.github/actions/prepare-poetry
Run actions/setup-python@v2
Successfully setup CPython (3.9.12)
Run actions/cache@v2
Received 23265524 of 23265524 (100.0%), 87.4 MBs/sec
Cache Size: ~22 MB (23265524 B)
/usr/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/70290b69-1385-4918-8afa-e181eef33b05/cache.tzst -P -C /home/runner/work/resqpy/resqpy
Cache restored successfully

Cache restored from key: poetry-0
Run snok/install-poetry@v1
Run $GITHUB_ACTION_PATH/main.sh

Setting Poetry installation path as /home/runner/.local/

Installing Poetry 👷

Retrieving Poetry metadata

The latest version (1.1.13) is already installed.
/home/runner/work/_actions/snok/install-poetry/v1/main.sh: /home/runner/.local//bin/poetry: /home/runner/.local/venv/bin/python: bad interpreter: No such file or directory
/home/runner/work/_actions/snok/install-poetry/v1/main.sh: /home/runner/.local//bin/poetry: /home/runner/.local/venv/bin/python: bad interpreter: No such file or directory
/home/runner/work/_actions/snok/install-poetry/v1/main.sh: /home/runner/.local//bin/poetry: /home/runner/.local/venv/bin/python: bad interpreter: No such file or directory
/home/runner/work/_actions/snok/install-poetry/v1/main.sh: /home/runner/.local//bin/poetry: /home/runner/.local/venv/bin/python: bad interpreter: No such file or directory

Installation completed. Configuring settings 🛠

Done ✅

The CI job fails with "bad interpreter: no such file or directory.

Workaround

I found that incrementing the cache key resolves the issue. However, thought I'd share here in case there is a root cause that can be diagnosed & fixed in case others have the same issue

Basic Example. Bad interpreter: No such file or directory.

Hi snok!

I have with succes used your template earlier, but now I run into trouble. Due to trouble finding the bug, I went back to your basic script, only to find that this also caused a problem. I am very new to Github Actions, so it might just be me who is missing something vert basic. I have taken you basic example and changed a few things; that it should run on push (for testing), use Python 3.8, and not run coverage, i.e. the following:

name: test

on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      #----------------------------------------------
      #       check-out repo and set-up python
      #----------------------------------------------
      - name: Check out repository
        uses: actions/checkout@v2
      - name: Set up python
        uses: actions/setup-python@v2
        with:
          python-version: 3.8
      #----------------------------------------------
      #  -----  install & configure poetry  -----
      #----------------------------------------------
      - name: Install Poetry
        uses: snok/[email protected]
        with:
          virtualenvs-create: true
          virtualenvs-in-project: true
      #----------------------------------------------
      #       load cached venv if cache exists
      #----------------------------------------------
      - name: Load cached venv
        id: cached-poetry-dependencies
        uses: actions/cache@v2
        with:
          path: .venv
          key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
      #----------------------------------------------
      # install dependencies if cache does not exist
      #----------------------------------------------
      - name: Install dependencies
        run: poetry install
        if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
      #----------------------------------------------
      #              run test suite
      #----------------------------------------------
      - name: Run tests
        run: |
          source .venv/bin/activate
          pytest tests/

When I push my files to Github, the action fails in the "Run tests" step with the following error:

Screenshot 2021-01-21 at 11 59 59

Do you have any tips or tricks for fixing this?

How can we speed up this workflow?

We use something like this:

      - name: Install Python
        uses: actions/[email protected]
        with:
          python-version: "3.8"

      - name: Install Python poetry
        uses: snok/[email protected]
        with:
          virtualenvs-create: true
          virtualenvs-in-project: true

      - name: Load cached venv
        id: cached-poetry-dependencies
        uses: actions/[email protected]
        with:
          path: yari/deployer/.venv
          key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('.github/workflows/pr-review-companion.yml') }}

      - name: Install poetry dependencies
        if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
        run: |
          cd yari/deployer
          poetry install --no-interaction --no-root

It works great! I'm really happy about the workflow and it's been solid.

There's just one problem, the...

      - name: Install Python poetry
        uses: snok/[email protected]

...lines are usually the slowest part of our whole workflow.
For example:

Screen Shot 2021-07-26 at 3 59 36 PM

This is a very typical thing. The slowest one is "Install Python poetry". It's roughly 10-15 seconds.

We use Python (and poetry) as part of our build process for our CMS. First, there's some Node code that builds the raw content into rendered HTML. Then a Python script runs some analysis on that built HTML and it uploads the built files to AWS S3.

So we run this workflow a LOT. For every single build of our content, which is authored through GitHub.
See https://github.com/mdn/content/actions/workflows/pr-review-companion.yml

Is there a way we can use caching or something to speed up this workflow?

Rethink recommendation about conditionally running `poetry install`

Dear Sondre,

thanks for conceiving and maintaining this excellent package. Apart from #18, we have been able to ramp it up quickly by following the recommendations within the documentation, which are great.

However, there is one specific detail I would like to solicit attention for.

Your suggestion to only run poetry install conditionally like

- name: Install dependencies
  if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
  run: poetry install

might fall short because poetry install without other options is responsible for installing the root package and its dependencies. However, we only want to cache the dependencies here, right? Otherwise, the CI job will probably not test the current code being brought in through the very patch coming from the PR.

So, if you don't have any objections on this detail, I would like to suggest to instead use a procedure like

- name: Install dependencies
  if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
  run: poetry install --no-interaction --no-root

- name: Install library
  run: poetry install --no-interaction

The key is the --no-root option here which is bound to the conditional step only invoked when running on a cold cache.

Please change my mind if you believe I am wrong on this.

With kind regards,
Andreas.

.venv/scripts/activate: No such file or directory on Windows

Hi! thanks for your github action. I unfortunately am having trouble getting it to work on windows...perhaps I'm missing something simple, but I've fiddled with stuff and can't seem to get it.

Failure log:
https://github.com/decompme/decomp.me/runs/5250900347?check_suite_focus=true

Work-in-progress pr.yml with the windows section highlighed: https://github.com/decompme/decomp.me/blob/334938e96d08e43d5687cbd8b94b069b9a45dbe6/.github/workflows/pr.yml#L89

Thanks in advance for your time.

install-poetry breaks with Poetry 1.2.0

Poetry 1.2.0 changes a lot of things about how path and virtualenvs are handled, and it breaks install-poetry:

▶ Run snok/install-poetry@v1
  with:
    virtualenvs-create: true
    virtualenvs-in-project: true
    installer-parallel: true
    version: latest
    virtualenvs-path: {cache-dir}/virtualenvs
  env:
    DJANGO_ENV: LOCAL
    pythonLocation: /opt/hostedtoolcache/Python/3.6.15/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.6.15/x64/lib
Run $GITHUB_ACTION_PATH/main.sh
  $GITHUB_ACTION_PATH/main.sh
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    DJANGO_ENV: LOCAL
    pythonLocation: /opt/hostedtoolcache/Python/3.6.15/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.6.15/x64/lib
    VERSION: latest
    VIRTUALENVS_CREATE: true
    VIRTUALENVS_IN_PROJECT: true
    VIRTUALENVS_PATH: {cache-dir}/virtualenvs
    INSTALLER_PARALLEL: true
    INSTALLATION_ARGUMENTS: 

Setting Poetry installation path as /home/runner/.local/

Installing Poetry 👷

Retrieving Poetry metadata

# Welcome to Poetry!

This will download and install the latest version of Poetry,
a dependency and package manager for Python.

It will add the `poetry` command to Poetry's bin directory, located at:

/home/runner/.local/bin

You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.

Installing Poetry (1.[2](https://github.com/critizr/critizr-django-1.7/runs/8108219212?check_suite_focus=true#step:7:2).0)
Installing Poetry (1.2.0): Creating environment
Installing Poetry (1.2.0): Installing Poetry
Installing Poetry (1.2.0): Creating script
Installing Poetry (1.2.0): Done

Poetry (1.2.0) is installed now. Great!

You can test that everything is set up by executing:

`poetry --version`

/home/runner/work/_actions/snok/install-poetry/v1/main.sh: line [3](https://github.com/critizr/critizr-django-1.7/runs/8108219212?check_suite_focus=true#step:7:3)3: poetry: command not found
/home/runner/work/_actions/snok/install-poetry/v1/main.sh: line 3[4](https://github.com/critizr/critizr-django-1.7/runs/8108219212?check_suite_focus=true#step:7:4): poetry: command not found
/home/runner/work/_actions/snok/install-poetry/v1/main.sh: line 3[5](https://github.com/critizr/critizr-django-1.7/runs/8108219212?check_suite_focus=true#step:7:5): poetry: command not found
/home/runner/work/_actions/snok/install-poetry/v1/main.sh: line 3[7](https://github.com/critizr/critizr-django-1.7/runs/8108219212?check_suite_focus=true#step:7:7): poetry: command not found

Installation completed. Configuring settings 🛠

Done ✅

If you are creating a venv in your project, you can activate it by running 'source .venv/bin/activate'. If you're running this in an OS matrix, you can use 'source $VENV' instead, as an OS agnostic option

▶ Run poetry install --no-interaction --no-root
/home/runner/work/_temp/63f8c552-7bf4-4d02-bd7b-8b02d[9](https://github.com/critizr/critizr-django-1.7/runs/8109330298?check_suite_focus=true#step:9:10)c8b5c0.sh: line 1: poetry: command not found
Error: Process completed with exit code 127.

Add env: section to parse envs that are used in each poetry call

This is not really an issue but I would like to have a field env: where I can pass in env variables that are available in the virtualenv whenever e.g. poetry run is called. Is this possible somehow? I can obv add these commands every via export XY=abc && poetry run... but this is not concise and easily leads to errors....

poetry: command not found

After running poetry setup action, poetry is not getting accessed, and gives error poetry: command not found even for the action job also if you see the logs below.
can you help me on how to access poetry for installing depdencies, i followed the documentation for one of my job but it is failing, can you help me resolve the issue

Setting Poetry installation path as /home/runner/.local/

Installing Poetry 👷

Retrieving Poetry metadata

# Welcome to Poetry!

This will download and install the latest version of Poetry,
a dependency and package manager for Python.

It will add the `poetry` command to Poetry's bin directory, located at:

/home/runner/.local/bin

You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.

Installing Poetry (1.2.2)
Installing Poetry (1.2.2): Creating environment
Installing Poetry (1.2.2): Installing Poetry
Installing Poetry (1.2.2): Creating script
Installing Poetry (1.2.2): Done

Poetry (1.2.2) is installed now. Great!

You can test that everything is set up by executing:

`poetry --version`

/home/runner/work/_actions/snok/install-poetry/v1.3.1/main.sh: line [33](https://github.com/corridor/sqlalchemy-history/actions/runs/3592706774/jobs/6048741773#step:5:35): poetry: command not found
/home/runner/work/_actions/snok/install-poetry/v1.3.1/main.sh: line [34](https://github.com/corridor/sqlalchemy-history/actions/runs/3592706774/jobs/6048741773#step:5:36): poetry: command not found
/home/runner/work/_actions/snok/install-poetry/v1.3.1/main.sh: line [35](https://github.com/corridor/sqlalchemy-history/actions/runs/3592706774/jobs/6048741773#step:5:37): poetry: command not found
/home/runner/work/_actions/snok/install-poetry/v1.3.1/main.sh: line [37](https://github.com/corridor/sqlalchemy-history/actions/runs/3592706774/jobs/6048741773#step:5:39): poetry: command not found

Installation completed. Configuring settings 🛠

Done ✅

If you are creating a venv in your project, you can activate it by running 'source .venv/bin/activate'. If you're running this in an OS matrix, you can use 'source $VENV' instead, as an OS agnostic option

Final checks

Before releasing v1 we need to

  • Update readmes with version number
  • Test the implementation example in a real project

Actions started failing recently.

Hi there, I'm not really sure how to debug this but my actions recently have started failing while installing poetry.

I believe I've set it up right.

  #----------------------------------------------
  #  -----  install & configure poetry  -----      
  #----------------------------------------------
  - name: Install Poetry
    uses: snok/install-poetry@v1
    with:
      virtualenvs-in-project: true

I'm not sure where to look for the logs mentioned in the action.

Poetry installation failed.
See /home/runner/work/csv-reconcile/csv-reconcile/poetry-installer-error-896tncri.log for error logs.
Error: Process completed with exit code 1.

I see there was a release recently, but it's not clear to me if I need to take any action. (No pun intended) Should I be pointing to 1.3.4 explicitly?

Poetry itself was also released recently and it looks like the action is trying to pull this version. Perhaps some incompatibility was introduced?

Sorry I can't be more helpful. Any advice you could offer would be appreciated. I'm happy to offer any information that might prove useful.

Regards

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.