VaultVulp / action-pipenv

Use pipenv commands in your GitHub Actions Workflow
MIT License
33 stars 9 forks source link

Supporting Python Image Versions Beyond Latest? #1

Open markpbaggett opened 4 years ago

markpbaggett commented 4 years ago

Hello,

It looks like 2 days ago the base python3 image was changed to be associated with python3.9 on docker hub. I'm curious if whether it is possible to pass an argument from a Github action yaml to this action rather than forcing Pipfiles that use this action to specify python3.9.

Thanks in advance for any thoughts you have!

VaultVulp commented 4 years ago

Hi, Mark! That's a great idea! I'll try to think about some solution! Thanks for your contribution to my project.

gilesknap commented 3 years ago

Hi I've hit this issue too. I want to build using pipenv and a matrix of python 3.7 and python 3.8. Thanks for this project.

amir-smrt commented 3 years ago

Same here. I'll appreciate support for non-latest

VaultVulp commented 3 years ago

I spent a bit of time looking for a solution, but without any luck - to provide different versions of python in one action we have to setup interpreter after the initialization of docker container, but this will drastically increase actual execution time of this action. So, right now, I do not have any ideas. I'll look a bit more into this issue later, but if you have any ideas - feel free to share them here.

burnedikt commented 1 year ago

I also ran into this issue today. This time, the python docker image for version 3 changed from 3.10 to 3.11 - which is of course a problem if the Pipfile specifies the version to still be 3.10.

I might be mistaken but the dockerfile already accepts a specific image (and therefore python) version https://github.com/VaultVulp/action-pipenv/blob/3a655e21a5d246a5c6351787aa9ce206c87bd3ad/Dockerfile#L1

I am not familiar with github actions but wouldn't it be possible to pass this also as an option using with:? E.g. like

      - name: Install dependecies
        uses: VaultVulp/action-pipenv@v2.0.1
        with:
          command: sync --dev
+         python_version: 3.10
burnedikt commented 1 year ago

I am not familiar with github actions but wouldn't it be possible to pass this also as an option using with:? E.g. like

      - name: Install dependecies
        uses: VaultVulp/action-pipenv@v2.0.1
        with:
          command: sync --dev
+         python_version: 3.10

To answer my own question: it appears there's currently no way to pass that input (python version) to the docker build process as a build arg according to github action's docs. Sad!


I guess the other way around would then be to install pyenv within the docker container which would then automatically take care of installing the python version specified in a Pipfile.

VaultVulp commented 1 year ago

As far as I know, it's impossible to use Dockerfile arguments in Github Actions.

Action's execution is separated in two steps: 1) Build stage: this is a docker build call that builds Image. At this stage we are could use Dockerifle-arguments, but Actions do not allow us to set arguments at this stage. 2) Execution stage: this is a docker run call that passes with-arguments into the Image we built earlier.

So right now, as far as, I know the only possible solution is to built and support multiple versions of the same Action, ex: VaultVulp/action-pipenv@v2.0.1.py3.10, VaultVulp/action-pipenv@v2.0.1.py3.11, etc.

VaultVulp commented 1 year ago

pyenv is a possible solution, but it will significantly incease action's execution time, for it will build and install python interpreter on each run.

burnedikt commented 1 year ago

I see the struggle. In my case that meant to use a more manual approach for pipenv again, which is sad but I guess there's no way around it right now, given the lack of flexibility of github actions in conjunction with docker (obviously, you could rewrite the github action to not use docker and instead install stuff directly on the build machine, but that seems like a bigger change for this project 😉).


For reference and others that face the same issue, this is what I ended up with. Definitely more verbose but works.

- - name: Install dependecies
-   uses: VaultVulp/action-pipenv@v2.0.1
+ - name: Setup python version
+   uses: actions/setup-python@v2
    with:
-     command: sync --dev # Install all dependencies, including development ones
+     python-version: "3.10"
+ - name: Install pipenv
+   run: pip install --user pipenv
+ - name: Install all dependencies, including development ones
+   run: pipenv sync --dev
  - name: Run tests
-   uses: VaultVulp/action-pipenv@v2.0.1
-   with:
-     command: run pytest
+   run: pipenv run pytest