Skip to content
This repository has been archived by the owner on Mar 31, 2021. It is now read-only.

docker-codecov #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Cov Test CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:

build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Build the Docker image
run: docker-compose build --no-cache

- name: Run tests and upload coverage to Codecov
run: |
ci_env="bash <(curl -s https://codecov.io/env)"
ci_post_cov="bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }}"
docker-compose run -e CI=true --rm api bash -c "$ci_env && pytest && $ci_post_cov"
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM python:3.9.2-slim-buster

ENV PYTHONUNBUFFERED 1

# Install prerequisites
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y curl && \
apt-get install -y git

RUN pip install --upgrade pip

RUN mkdir /app
WORKDIR /app

COPY requirements.txt /app/
RUN pip install -r requirements.txt

COPY . /app/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Cov Test

[![codecov](https://codecov.io/gh/Hacksbr/cov-test/branch/main/graph/badge.svg?token=3YVKHF2eyl)](https://codecov.io/gh/Hacksbr/cov-test)

## License

Expand Down
27 changes: 27 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
codecov:
require_ci_to_pass: yes

coverage:
precision: 2
round: down
range: "70...100"

parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no

comment:
layout: "reach,diff,flags,files,footer"
behavior: default
require_changes: no

ignore:
- "test/"
- "*/**/test/*"
- "**/test/"
- "**/test/*"
- "**/test/**/"
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: "3.8"

services:
api:
build: .
ports:
- "8000:8000"
volumes:
- .:/app
4 changes: 4 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
python manage.py collectstatic --noinput
python manage.py migrate --no-input
python manage.py runserver 0.0.0.0:8000
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[pytest]
testpaths = .
python_files = tests.py test_*.py *_tests.py
addopts = --flake8 -vv -s --cov
addopts = --flake8 --cov=. -vv -s --cov-report=html
flake8-ignore =
*.py E501
.venv
3 changes: 3 additions & 0 deletions .github/workflows/python-app.yml → python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

- name: Test with pytest
run: |
pytest

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
Expand Down
12 changes: 6 additions & 6 deletions src/main/calc_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ def subtraction(a, b):
return a - b


def sum_1(a, b, c):
return a + b + c


def subtraction_2(a, b, c):
return a - b - c
# def sum_1(a, b, c):
# return a + b + c
#
#
# def subtraction_2(a, b, c):
# return a - b - c
4 changes: 2 additions & 2 deletions src/main/calc_02.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ def multiplication(a, b):
return a * b


def multiplication_2(a, b, c, d):
return (a * b) + (c - d)
# def multiplication_2(a, b, c, d):
# return (a * b) + (c - d)
8 changes: 4 additions & 4 deletions src/main/text.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def text_xx(a):
return a * 2
# def text_xx(a):
# return a * 2


def text_xxx(a):
Expand All @@ -10,5 +10,5 @@ def text_xxxx(a):
return a * 4


def text(a):
return a
# def text(a):
# return a