Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for changes introduced in v1.2.0a1 #33

Merged
merged 2 commits into from
May 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on: pull_request

env:
# JSON variables (used in our strategy/matrix)
SUPPORTED_POETRY_VERSIONS: '\"poetry-version\":[\"1.1.0\", \"1.1.2\", \"1.1.4\", \"1.1.5\", \"1.1.6\"]'
SUPPORTED_POETRY_VERSIONS: '\"poetry-version\":[\"1.1.0\", \"1.1.6\", \"1.2.0a1\"]'
SUPPORTED_PYTHON_VERSIONS: '\"python-version\":[\"3.7\", \"3.8\", \"3.9\"]'
SUPPORTED_OPERATING_SYSTEMS: '\"os\":[\"ubuntu-latest\", \"macos-latest\", \"windows-latest\"]'

Expand Down Expand Up @@ -40,11 +40,11 @@ jobs:
# matrix:
# - os: [ubuntu-latest, ...]
steps:
- id: set-matrix-vars
run: |
echo "::set-output name=full-matrix::{${{ env.SUPPORTED_POETRY_VERSIONS }},${{ env.SUPPORTED_PYTHON_VERSIONS }},${{ env.SUPPORTED_OPERATING_SYSTEMS }}}"
echo "::set-output name=py-os-matrix::{${{ env.SUPPORTED_PYTHON_VERSIONS }},${{ env.SUPPORTED_OPERATING_SYSTEMS }}}"
echo "::set-output name=os-matrix::{${{ env.SUPPORTED_OPERATING_SYSTEMS }}}"
- id: set-matrix-vars
run: |
echo "::set-output name=full-matrix::{${{ env.SUPPORTED_POETRY_VERSIONS }},${{ env.SUPPORTED_PYTHON_VERSIONS }},${{ env.SUPPORTED_OPERATING_SYSTEMS }}}"
echo "::set-output name=py-os-matrix::{${{ env.SUPPORTED_PYTHON_VERSIONS }},${{ env.SUPPORTED_OPERATING_SYSTEMS }}}"
echo "::set-output name=os-matrix::{${{ env.SUPPORTED_OPERATING_SYSTEMS }}}"

# This job makes sure that the install-poetry action works,
# using the default settings, on all combinations of Python versions,
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
id: cached-poetry-dependencies
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}-2
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}-3
- run: poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
- run: |
Expand Down Expand Up @@ -170,3 +170,14 @@ jobs:
- run: |
source $VENV
pytest --version

# Make sure scripts are not deleted.
# If we deleted the scripts folder (or subfolders) by accident,
# different versions of the action would fail
test-scripts-exist:
runs-on: ubuntu-latest
steps:
# v1.1 script loaded in < 1.1.4
- uses: snok/install-poetry@v1.1.4
# # v1.2 script loaded in > 1.1.4
# - uses: snok/install-poetry@v1.1.5
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ If all you need is default Poetry, simply add this to your workflow:

```yaml
- name: Install Poetry
uses: snok/install-poetry@v1.1.4
uses: snok/install-poetry@v1.1.5
```

If you want to set Poetry config settings, or install a specific version, you can specify inputs

```yaml
- name: Install and configure Poetry
uses: snok/install-poetry@v1.1.4
uses: snok/install-poetry@v1.1.5
with:
version: 1.1.6
virtualenvs-create: true
Expand All @@ -49,7 +49,7 @@ or just to make changes to the Poetry config *after* invoking the action -
you can do so in a subsequent step, like this

```yaml
- uses: snok/install-poetry@v1.1.4
- uses: snok/install-poetry@v1.1.5
- run: poetry config experimental.new-installer false
```

Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1.1.4
uses: snok/install-poetry@v1.1.5
with:
virtualenvs-create: true
virtualenvs-in-project: true
Expand Down Expand Up @@ -192,7 +192,7 @@ jobs:
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1.1.4
uses: snok/install-poetry@v1.1.5
with:
virtualenvs-create: true
virtualenvs-in-project: true
Expand Down Expand Up @@ -259,7 +259,7 @@ jobs:
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1.1.4
uses: snok/install-poetry@v1.1.5
with:
virtualenvs-create: true
virtualenvs-in-project: true
Expand Down Expand Up @@ -360,7 +360,7 @@ jobs:
with:
python-version: 3.9
- name: Install Poetry
uses: snok/install-poetry@v1.1.4
uses: snok/install-poetry@v1.1.5
with:
virtualenvs-create: true
virtualenvs-in-project: true
Expand Down Expand Up @@ -395,7 +395,7 @@ All of the examples we've added use these Poetry settings

```yaml
- name: Install Poetry
uses: snok/install-poetry@v1.1.4
uses: snok/install-poetry@v1.1.5
with:
virtualenvs-create: true
virtualenvs-in-project: true
Expand Down
20 changes: 12 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@ runs:
steps:
- name: Install and configure Poetry
run: |
get_poetry="$(mktemp)"
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py --output "$get_poetry"
python $get_poetry --yes --version=${{ inputs.version }}
installation_script="$(mktemp)"
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/48339106eb0d403a3c66519317488c8185844b32/install-poetry.py --output "$installation_script"

echo "$HOME/.poetry/bin" >> $GITHUB_PATH
config_script="$(mktemp)"
curl -sSL https://raw.githubusercontent.com/snok/install-poetry/v1.2/scripts/v1.2/main.sh --output "$config_script"
chmod +x "$config_script"

install="$(mktemp)"
curl -sSL https://raw.githubusercontent.com/snok/install-poetry/main/scripts/v1.1/main.sh --output "$install"
chmod +x "$install"
$install ${{ runner.os }} ${{ inputs.virtualenvs-create }} ${{ inputs.virtualenvs-in-project }} ${{ inputs.virtualenvs-path }}
$config_script \
${{ runner.os }} \
${{ inputs.virtualenvs-create }} \
${{ inputs.virtualenvs-in-project }} \
${{ inputs.virtualenvs-path }} \
${{ inputs.version }} \
$installation_script
shell: bash
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "install-poetry"
version = "1.1.4"
version = "1.1.5"
description = ""
authors = ["Sondre Lillebø Gundersen <sondrelg@live.no.com>"]
maintainers = ["Jonas Krüger Svensson <jonasks@hotmail.com>"]
Expand Down
59 changes: 59 additions & 0 deletions scripts/v1.2/main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

# Give inputs sensible names
os=$1
venv_create=$2
venv_in_project=$3
venv_path=$4
version=$5
installation_script=$6

# Define OS specific help text
if [ "$os" == "Windows" ]; then
conf="\033[33mConfiguring Poetry for Windows!\033[0m"
act="source .venv/scripts/activate"
echo "VENV=.venv/scripts/activate" >>"$GITHUB_ENV"
else
conf="\033[33mConfiguring Poetry!\033[0m"
act="source .venv/bin/activate"
echo "VENV=.venv/bin/activate" >>"$GITHUB_ENV"
fi

# Echo help texts
echo -e "\n\n-------------------------------------------------------------------------------\n\n$conf 🎉"
if [ "$venv_create" == true ] || [ "$venv_create" == "true" ]; then
# If user is creating a venv in-project we tell them how to activate venv
echo -e "\n\n\033[33mIf you are creating a venv in your project, you can activate it by running '$act'\033[0m"
echo -e "\n\033[33mIf you're running this in an OS matrix, use 'source \$VENV'\033[0m"
fi
if [ "$os" == "Windows" ]; then
# If $SHELL isn't some variation of bash, output a yellow-texted warning
echo -e "\n\n\033[33mMake sure to set your default shell to bash when on Windows.\033[0m"
echo -e "\n\033[33mSee the github action docs for more information and examples.\033[0m"
fi
echo -e '\n-------------------------------------------------------------------------------\n'

if [ "$os" == "Windows" ]; then
path="C:/Users/runneradmin/AppData/Roaming/Python/Scripts/"
else
path="$HOME/.local/"
fi

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

echo "$path/bin" >>$GITHUB_PATH
export PATH="$path/bin:$PATH"

if [ "$os" == "Windows" ]; then
# Adding to path on windows doesn't immediately take effect
# so calling the executable directly here - should be available
# in next steps regardless.
"$path/bin/poetry.exe" config virtualenvs.create "$venv_create"
"$path/bin/poetry.exe" config virtualenvs.in-project "$venv_in_project"
"$path/bin/poetry.exe" config virtualenvs.path "$venv_path"
else
poetry config virtualenvs.create "$venv_create"
poetry config virtualenvs.in-project "$venv_in_project"
poetry config virtualenvs.path "$venv_path"
fi