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.

Travis + Docker result in broken build on CI

See original GitHub issue

What happened?

Try to generate a project with Docker and Tarvis enabled, the tarvis config is not suitable and fails the build:

Build logs
travis_fold:end:install
travis_time:start:183a4568
$ pytest
Traceback (most recent call last):
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/environ/environ.py", line 273, in get_value
    value = self.ENVIRON[var]
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/os.py", line 669, in __getitem__
    raise KeyError(key) from None
KeyError: 'DATABASE_URL'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/travis/virtualenv/python3.6.7/bin/pytest", line 10, in <module>
    sys.exit(main())
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/_pytest/config/__init__.py", line 63, in main
    config = _prepareconfig(args, plugins)
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/_pytest/config/__init__.py", line 207, in _prepareconfig
    pluginmanager=pluginmanager, args=args
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/pluggy/hooks.py", line 289, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/pluggy/manager.py", line 87, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/pluggy/manager.py", line 81, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/pluggy/callers.py", line 203, in _multicall
    gen.send(outcome)
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/_pytest/helpconfig.py", line 94, in pytest_cmdline_parse
    config = outcome.get_result()
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/_pytest/config/__init__.py", line 687, in pytest_cmdline_parse
    self.parse(args)
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/_pytest/config/__init__.py", line 895, in parse
    self._preparse(args, addopts=addopts)
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/_pytest/config/__init__.py", line 851, in _preparse
    early_config=self, args=args, parser=self._parser
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/pluggy/hooks.py", line 289, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/pluggy/manager.py", line 87, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/pluggy/manager.py", line 81, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/pytest_django/plugin.py", line 333, in pytest_load_initial_conftests
    dj_settings.DATABASES
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/django/conf/__init__.py", line 79, in __getattr__
    self._setup(name)
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/django/conf/__init__.py", line 66, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/django/conf/__init__.py", line 157, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/travis/build/browniebroke/cc-dj-tests/config/settings/test.py", line 5, in <module>
    from .base import *  # noqa
  File "/home/travis/build/browniebroke/cc-dj-tests/config/settings/base.py", line 44, in <module>
    DATABASES = {"default": env.db("DATABASE_URL")}
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/environ/environ.py", line 204, in db_url
    return self.db_url_config(self.get_value(var, default=default), engine=engine)
  File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/environ/environ.py", line 277, in get_value
    raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: Set the DATABASE_URL environment variable
travis_time:end:183a4568:start=1559838789069844257,finish=1559838789825801676,duration=755957419
The command "pytest" exited with 1.



Done. Your build exited with 1.

We should provide a suitable config when Docker is selected with Travis.

How to fix this?

Generate a project with the 2 options enabled, push it to Github with Travis and make the build pass by running the appropriate docker commands instead of bare metals ones.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
step21commented, Jun 26, 2019

This works with docker-in-docker and probably requires docker to run in privileged mode, and requires an image with docker-compose (see below).

image: docker:latest
services:
  - docker:dind

variables:
  DOCKER_HOST: tcp://docker:2375
  DOCKER_DRIVER: overlay2

stages:
  - build
  - start
  - test
  
build:
  stage: build
  image: tiangolo/docker-with-compose
  script:
    - docker-compose -f local.yml build

start:
  stage: start
  image: tiangolo/docker-with-compose
  script:
    - docker-compose -f local.yml up -d
    - docker-compose -f local.yml down -v

test:
  stage: test
  image: tiangolo/docker-with-compose
  script:
    - docker-compose run django coverage run -m pytest
  allow_failure: true
Read more comments on GitHub >

github_iconTop Results From Across the Web

Common Build Problems - Travis CI Docs
A very common cause when a test is suddenly breaking without any major code changes involved is a change in upstream dependencies. This...
Read more >
Building A CI/CD Pipeline With Travis CI, Docker, And ...
If any of those jobs fails, the build is considered broken; else, the build is successful. On the success of the build, Travis...
Read more >
travis_wait fail docker run · Issue #6934 · travis-ci ... - GitHub
Your build exited with 1. https://travis-ci.org/galeksandrp/httpse/builds/178829025. Workaround is. travis_wait 120 sleep infinity & docker ...
Read more >
Using Travis CI to test Docker builds - Benjamin Cane
However, if a single test case fails only a portion is broken. By showing all testing results users will be able to identify...
Read more >
Docker and travis ci faling on build - Stack Overflow
I am trying to dockerize my app as part of travis ci so i can then publish it to docker hub: I have...
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