Skip to content

Develop #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 34 commits into
base: master
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
13 changes: 13 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
codecov:
require_ci_to_pass: yes

coverage:
precision: 1
round: down
target: "20...100"

ignore:
- '**/test/**'
- 'env/**'
- 'reports/**'
- '.pytest_cache/**'
43 changes: 28 additions & 15 deletions .github/workflows/continous_integration.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
name: Python application

on: [push]
on: [push,pull_request]

jobs:
build:

env:
PYTHON_FILES: .

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: get changed files for push
if: ${{ github.event_name == 'push' }}
run: |
echo ::set-env name=PYTHON_FILES::$(find . -type f -name "*.py" | xargs git diff --name-only --diff-filter=ACMRT ${{ github.sha }}~ ${{ github.sha }} | awk '{print $1}' | paste -d' ' -s)
- name: get changed files for pull request
if: ${{ github.event_name == 'pull_request' }}
run: |
echo ::set-env name=PYTHON_FILES::$(find . -type f -name "*.py" | xargs git diff --name-only --diff-filter=ACMRT origin/${{ github.base_ref }} origin/${{ github.head_ref }} | awk '{print $1}' | paste -d' ' -s)
- name: print PYTHON_FILES
run: |
echo ${{ env.PYTHON_FILES }}
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
Expand All @@ -17,21 +33,18 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: get changed files
id: getfile
run: |
echo "::set-output name=files::$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | xargs)"
- name: echo output
- name: Formatting check
if: ${{ env.PYTHON_FILES }}
run: |
echo ${{ steps.getfile.outputs.files }}
# - name: Lint with flake8
# run: |
# pip install -q wemake-python-styleguide
# wget "https://raw.githubusercontent.com/ebot7/eb7-styleguide/master/settings/setup_ml_githooks.cfg"
# flake8 pgb/ --config=setup_ml_githooks.cfg
# rm setup_ml_githooks.cfg
# with:
# - fail_ci_if_error: true
pip install -qU autoflake==1.4 black==20.8b1 docformatter==1.3.1 isort==5.5.3
echo "Checking with autoflake"
autoflake --check --expand-star-imports --remove-all-unused-imports --ignore-init-module-imports --remove-duplicate-keys --remove-unused-variables ${{ env.PYTHON_FILES }}
echo "Checking with docformatter"
docformatter --check --make-summary-multi-line --pre-summary-newline ${{ env.PYTHON_FILES }}
echo "Checking with isort"
isort --check-only --quiet ${{ env.PYTHON_FILES }}
echo "Checking with black"
black --check ${{ env.PYTHON_FILES }} -l 79
- name: Test with pytest
run: |
pip install pytest==5.3.5 coverage==4.5.4
Expand Down
2 changes: 1 addition & 1 deletion pgb/add.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def add(a: int, b: int) -> int:
"""
Adds two number
Adds two number.

Args:
a (int): First argument
Expand Down
2 changes: 1 addition & 1 deletion pgb/mul.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def mul(a: int, b: int) -> int:
"""
Multiplies two number
Multiplies two number.

Args:
a (int): First argument
Expand Down
12 changes: 12 additions & 0 deletions pgb/pow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def pow(a: int, b: int) -> int:
"""
Power of two number.

Args:
a (int): First argument
b (int): Second argument

Returns:
Power of second arguments on the base of first argument
"""
return a ** b
2 changes: 1 addition & 1 deletion pgb/sub.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def sub(a: int, b: int) -> int:
"""
Subtracts two number
Subtracts two number.

Args:
a (int): First argument
Expand Down
15 changes: 13 additions & 2 deletions tests/test_calculator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest
from pgb import add, mul

from pgb import add, mul, pow, sub


class TestCalculator(unittest.TestCase):
Expand All @@ -13,6 +14,16 @@ def test_mul(self):
b = 10
self.assertEqual(mul.mul(a, b), 50)

def test_sub(self):
a = 5
b = 10
self.assertEqual(sub.sub(a, b), -5)

def test_pow(self):
a = 2
b = 10
self.assertEqual(pow.pow(a, b), 1024)


if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()