question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trouble running pipenv in CI

See original GitHub issue

I’ve been trying to get pipenv to work with gitlab CI, but i’m getting errors. Here are last lines of output:

To activate this project's virtualenv, run the following:
 $ pipenv shell
$ pipenv run --no-interactive python manage.py migrate
ERROR: Job failed: exit code 1

And here is my .gitlab.ci.yaml

# This file is a template, and might need editing before it works on your project.
# Official framework image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/python
image: python:latest

# Pick zero or more services to be used on all builds.
# Only needed when using a docker container to run your tests in.
# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-service
services:
  - postgres:latest

variables:
  POSTGRES_DB: db
  POSTGRES_USER: user
  POSTGRES_PASSWORD: password

# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
cache:
  paths:
  - ~/.cache/pip/

# This is a basic example for a gem or script which doesn't use
# services such as redis or postgres
before_script:
  - python -V                                   # Print out python version for debugging
  # Uncomment next line if your Django app needs a JS runtime:
  # - apt-get update -q && apt-get install nodejs -yqq
  - pip install pipenv
  - pipenv install --dev

test:
  variables:
    DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/$POSTGRES_DB"
  script:
  - pipenv run python manage.py migrate
  - pipenv run python manage.py test
  - pipenv run coverage run -m pytest
  - pipenv run coverage run report

Any idea why it fails? I did also try to run pipenv shell, but that failed too.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

11reactions
pszpetkowskicommented, Apr 25, 2017

I’ve found a workaround for the issue - not sure if it’s a proper way, however it’s only thing that at the moment works for me. The solution is to put following commands into CI job:

- export VENV_HOME_DIR=$(pipenv --venv)
- source $VENV_HOME_DIR/bin/activate
- py.test --capture=no --ds=config.settings.test --flake8 .
2reactions
pszpetkowskicommented, Apr 26, 2017

@nateprewitt #320 solved the issue for me without using workaround, so now I can simply use:

- pipenv run py.test --capture=no --ds=config.settings.test --flake8 .

For me issue is fixed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

using pipenv with gitlab ci - python - Stack Overflow
Therefore I want to use pipenv with Gitlab runner too. My gitlab-ci.yml file contains stages: - test - deploy test: stage: test script:...
Read more >
Quirks of Pipenv on Travis CI and AppVeyor | by Dirk Avery
My initial impressions of using Pipenv with continuous integration tools Travis CI and AppVeyor are basically good. However, there are a few quirks....
Read more >
Advanced Usage of Pipenv - Read the Docs
Pipenv makes an API call to retrieve those results and use them each time you run pipenv check to show you vulnerable dependencies....
Read more >
pipenv · PyPI
Pipenv : Python Development Workflow for Humans. image CI image. Pipenv is a tool that aims to bring the best of all packaging...
Read more >
Making pip installs a little less slow - Python⇒Speed
Installing packages with pip, Poetry, and Pipenv can be slow. ... Whether you're running tests in CI, building a Docker image, or installing ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found