Skip to content

Commit

Permalink
Install Poetry with pipx
Browse files Browse the repository at this point in the history
  • Loading branch information
br3ndonland committed Jan 22, 2022
1 parent 2207dd6 commit 41748fa
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 12 deletions.
32 changes: 26 additions & 6 deletions .github/workflows/hooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ jobs:
matrix:
python-version: ["3.8", "3.9", "3.10"]
env:
POETRY_VIRTUALENVS_CREATE: false
PIPX_VERSION: "0.16.4"
POETRY_VERSION: "1.1.11"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
Expand All @@ -33,14 +34,33 @@ jobs:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: ${{ runner.os }}-pre-commit-
- name: Install pipx for Python ${{ matrix.python-version }}
run: python -m pip install "pipx==$PIPX_VERSION"
- name: Install Poetry
working-directory: py
run: pipx install "poetry==$POETRY_VERSION"
- name: Test Poetry version
run: |
curl -fsS -o get-poetry.py https://raw.githubusercontent.com/python-poetry/poetry/HEAD/get-poetry.py
python get-poetry.py -y
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
POETRY_VERSION_INSTALLED=$(poetry -V)
echo "The POETRY_VERSION environment variable is set to $POETRY_VERSION."
echo "The installed Poetry version is $POETRY_VERSION_INSTALLED."
case $POETRY_VERSION_INSTALLED in
*$POETRY_VERSION*) echo "Poetry version correct." ;;
*) echo "Poetry version incorrect." && exit 1 ;;
esac
- name: Install dependencies
working-directory: py
run: poetry install --no-interaction
- name: Test virtualenv location
working-directory: py
run: |
EXPECTED_VIRTUALENV_PATH=${{ github.workspace }}/py/.venv
INSTALLED_VIRTUALENV_PATH=$(poetry env info --path)
echo "The virtualenv should be at $EXPECTED_VIRTUALENV_PATH."
echo "Poetry is using a virtualenv at $INSTALLED_VIRTUALENV_PATH."
case "$INSTALLED_VIRTUALENV_PATH" in
"$EXPECTED_VIRTUALENV_PATH") echo "Correct Poetry virtualenv." ;;
*) echo "Incorrect Poetry virtualenv." && exit 1 ;;
esac
- name: Run pre-commit hooks
run: pre-commit run --all-files
working-directory: py
run: poetry run pre-commit run --all-files
38 changes: 32 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ jobs:
matrix:
python-version: ["3.8", "3.9", "3.10"]
env:
POETRY_VIRTUALENVS_CREATE: false
PIPX_VERSION: "0.16.4"
POETRY_VERSION: "1.1.11"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
Expand All @@ -30,15 +31,40 @@ jobs:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: ${{ runner.os }}-poetry-
- name: Set up pre-commit cache
uses: actions/cache@v2
if: startsWith(runner.os, 'Linux')
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: ${{ runner.os }}-pre-commit-
- name: Install pipx for Python ${{ matrix.python-version }}
run: python -m pip install "pipx==$PIPX_VERSION"
- name: Install Poetry
working-directory: py
run: pipx install "poetry==$POETRY_VERSION"
- name: Test Poetry version
run: |
curl -fsS -o get-poetry.py https://raw.githubusercontent.com/python-poetry/poetry/HEAD/get-poetry.py
python get-poetry.py -y
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
POETRY_VERSION_INSTALLED=$(poetry -V)
echo "The POETRY_VERSION environment variable is set to $POETRY_VERSION."
echo "The installed Poetry version is $POETRY_VERSION_INSTALLED."
case $POETRY_VERSION_INSTALLED in
*$POETRY_VERSION*) echo "Poetry version correct." ;;
*) echo "Poetry version incorrect." && exit 1 ;;
esac
- name: Install dependencies
working-directory: py
run: poetry install --no-interaction
- name: Test virtualenv location
working-directory: py
run: |
EXPECTED_VIRTUALENV_PATH=${{ github.workspace }}/py/.venv
INSTALLED_VIRTUALENV_PATH=$(poetry env info --path)
echo "The virtualenv should be at $EXPECTED_VIRTUALENV_PATH."
echo "Poetry is using a virtualenv at $INSTALLED_VIRTUALENV_PATH."
case "$INSTALLED_VIRTUALENV_PATH" in
"$EXPECTED_VIRTUALENV_PATH") echo "Correct Poetry virtualenv." ;;
*) echo "Incorrect Poetry virtualenv." && exit 1 ;;
esac
- name: Run unit tests
working-directory: py
run: pytest
run: poetry run pytest
5 changes: 5 additions & 0 deletions py/poetry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[experimental]
new-installer = false

[virtualenvs]
in-project = true

0 comments on commit 41748fa

Please sign in to comment.