From b0b2f8557cd402f381041b658df4680d40bae7b2 Mon Sep 17 00:00:00 2001 From: Aaron Date: Tue, 19 Nov 2019 06:24:25 -0700 Subject: [PATCH 1/3] feat: support setting of python and poetry versions This change introduces variables for allowing you to set whatever versions of Python and poetry you'd like to install. You set these using the GitHub Actions `with` block, where you can set `python_version` and `poetry_version`. There are defaults listed in the action.yml. We are considering letting those defaults automatically go lookup the latest versions of python and/or poetry. This is as opposed to the previous behavior which would only run the latest version of Python, and the latest version of poetry. At the same time, we've switched off using Alpine as this has been a popular request. Fixes #8 Fixes #9 Fixes #10 --- Dockerfile | 37 ++++++++++++++++++++++++++++++++----- README.md | 8 ++++++-- action.yml | 9 +++++++++ entrypoint.sh | 8 ++++++++ requirements.txt | 2 +- 5 files changed, 56 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 77fd620..fcc48c5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,34 @@ -FROM python:3.8.0-alpine3.10 +FROM python:slim-buster -COPY requirements.txt requirements.txt -RUN pip install -r requirements.txt +ENV PYENV_HOME=/root/.pyenv +ENV PATH $PYENV_HOME/shims:$PYENV_HOME/bin:$PATH -COPY entrypoint.sh / -ENTRYPOINT [ "/entrypoint.sh" ] +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + build-essential \ + curl \ + git \ + libbz2-dev \ + libffi-dev \ + liblzma-dev \ + libncurses5-dev \ + libncursesw5-dev \ + libreadline-dev \ + libsqlite3-dev \ + libssl-dev \ + llvm \ + make \ + python-openssl \ + tk-dev \ + wget \ + xz-utils \ + zlib1g-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Install pyenv, then install python versions +RUN git clone --depth 1 https://github.com/pyenv/pyenv.git $PYENV_HOME && \ + rm -rfv $PYENV_HOME/.git + +COPY requirements.txt entrypoint.sh / +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index f1f6dbe..bdbabc0 100644 --- a/README.md +++ b/README.md @@ -22,12 +22,16 @@ jobs: steps: - uses: actions/checkout@master - name: Install - uses: abatilo/actions-poetry@v1.0.0 + uses: abatilo/actions-poetry@v1.1.0 with: + python_version: 3.8.0 + poetry_version: 0.12.17 args: install - name: Run pytest - uses: abatilo/actions-poetry@v1.0.0 + uses: abatilo/actions-poetry@v1.1.0 with: + python_version: 3.8.0 + poetry_version: 0.12.17 args: run python -m pytest --cov=src --cov-branch --cov-fail-under=100 tests/ ``` diff --git a/action.yml b/action.yml index d5dbe08..13b2238 100644 --- a/action.yml +++ b/action.yml @@ -7,3 +7,12 @@ runs: branding: icon: 'truck' color: 'gray-dark' +inputs: + python_version: + description: 'The version of python to install' + required: true + default: '3.8.0' + poetry_version: + description: 'The version of poetry to install' + required: true + default: '0.12.17' diff --git a/entrypoint.sh b/entrypoint.sh index 44a450f..6c8bad7 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,2 +1,10 @@ #!/bin/sh +pythonVersion="$INPUT_PYTHON_VERSION" +poetryVersion="$INPUT_POETRY_VERSION" +pyenv install $pythonVersion +pyenv global $pythonVersion +pip install -r /requirements.txt +pip install poetry==$poetryVersion +pyenv rehash + sh -c "poetry $*" diff --git a/requirements.txt b/requirements.txt index 4683a98..3877da2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -poetry==0.12.17 +pip==19.3.1 From f309ca8a4dff7b6f0d70ea0d3b42276489af8f7d Mon Sep 17 00:00:00 2001 From: Aaron Date: Tue, 19 Nov 2019 06:34:18 -0700 Subject: [PATCH 2/3] update ci to pass in versions --- .github/workflows/ci.yml | 12 +++++------- Dockerfile | 8 ++++---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f1cc7ee..3c92a47 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,13 +6,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@master - - name: Build image - run: | - docker build -t actions-poetry . - - name: Print ref - run: | - echo $GITHUB_REF - env + - name: Run image + uses: ./ + with: + python_version: 3.8.0 + poetry_version: 0.12.17 - name: Generate release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Dockerfile b/Dockerfile index fcc48c5..aaa20b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM python:slim-buster -ENV PYENV_HOME=/root/.pyenv -ENV PATH $PYENV_HOME/shims:$PYENV_HOME/bin:$PATH +ENV PYENV_ROOT=/root/.pyenv +ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH RUN apt-get update \ && apt-get install -y --no-install-recommends \ @@ -27,8 +27,8 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* # Install pyenv, then install python versions -RUN git clone --depth 1 https://github.com/pyenv/pyenv.git $PYENV_HOME && \ - rm -rfv $PYENV_HOME/.git +RUN git clone --depth 1 https://github.com/pyenv/pyenv.git $PYENV_ROOT && \ + rm -rfv $PYENV_ROOT/.git COPY requirements.txt entrypoint.sh / ENTRYPOINT ["/entrypoint.sh"] From a192d31bcb99f0258c98e95e6640ba1d5485506d Mon Sep 17 00:00:00 2001 From: Aaron Date: Tue, 19 Nov 2019 06:42:16 -0700 Subject: [PATCH 3/3] run matrix for testing multiple versions --- .github/workflows/ci.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c92a47..f8d9270 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,14 +3,22 @@ on: push jobs: ci: + strategy: + matrix: + python_version: [3.5.9, 3.7.0, 3.8.0] + poetry_version: [0.12.17] runs-on: ubuntu-latest steps: - uses: actions/checkout@master - name: Run image uses: ./ with: - python_version: 3.8.0 - poetry_version: 0.12.17 + python_version: ${{ matrix.python_version }} + poetry_version: ${{ matrix.poetry_version }} + release: + needs: ci + runs-on: ubuntu-latest + steps: - name: Generate release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}