Skip to content

Instantly share code, notes, and snippets.

@webyneter
Last active October 9, 2019 02:04
Show Gist options
  • Save webyneter/f9a957c7448583b0222e69430db14f68 to your computer and use it in GitHub Desktop.
Save webyneter/f9a957c7448583b0222e69430db14f68 to your computer and use it in GitHub Desktop.
Travis CI + Codecov + Docker / Docker Compose (+ Python / Django, but that's not the point anyway)
# This setup took me a few hours to come up with; codecov docs turned out to be useless in the end.
# With this gist I hope to be the last one to have ever faced it again :)
sudo: required
services:
- docker
before_install:
- docker version
- docker-compose version
before_script:
# Among other python requirements my app also installs:
# * pytest
# * pytest-cov
# * coverage
- docker-compose -f local.yml build
script:
# My setup premises:
# * TravisCI `CODECOV_TOKEN` env is set to the value from codecov.io project dashboard (which Codecov doesn't require for publicly-hosted projects) through TravisCI project dashboard settings
# * `django` is the app service name
# * Alpine Linux flavor of Python 3.6 is the app service base image
# * The app's working directory, including .git/, is mapped within the service as "./app/:/app/" via the local.yml Docker Compose config
- docker-compose -f local.yml run --rm $(bash <(curl -s https://codecov.io/env)) django ash -c 'pytest --cov=./ && apk update && apk add git && codecov'
# This is just a sample codecov config -- feel free to modify however you like so that it fits the unique setup of yours.
# N.B. Apparently, this file must be named `codecov.yml`, without the leading dot...
codecov:
notify:
require_ci_to_pass: yes
coverage:
precision: 2
round: down
range: "90...100"
status:
project: yes
patch: yes
changes: no
parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no
comment:
layout: "header, diff"
behavior: default
require_changes: no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment