snok / install-poetry

Github action for installing and configuring Poetry
MIT License
572 stars 53 forks source link

Virtual environment created in wrong location #145

Closed rushilsrivastava closed 1 month ago

rushilsrivastava commented 8 months ago

Here's my GitHub Action file:

name: Run tests

on:
    push:
        branches:
            - develop

defaults:
    run:
        working-directory: ./services/flask

jobs:
    tests:
        runs-on: 'ubuntu-latest'
        timeout-minutes: 5

        steps:
            - name: Check out Git repository
              uses: actions/checkout@v4
              with:
                fetch-depth: 2

            - name: Set up Python 3.11.7
              uses: actions/setup-python@v4
              with:
                  python-version: 3.11.7

            - name: Install and configure Poetry
              uses: snok/install-poetry@v1.3.4
              with:
                  virtualenvs-create: true
                  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 poetry dependencies
              run: poetry install --all-extras --no-interaction

            - name: Run tests
              run: |
                  source .venv/bin/activate
                  pytest tests/

Despite virtualenvs-in-project being set to True, the virtual environment is created in /home/runner/.cache/pypoetry/virtualenvs. Consequently, all my actions are now failing with error .venv/bin/activate: No such file or directory.

Strangely, this action worked previously without any modifications.

zalun commented 2 months ago

https://github.com/snok/install-poetry/pull/152