Skip to content

Commit 7f41831

Browse files
Merge pull request #19 from Python-Dojo/13-formatter-linter-on-pull
Added formatting checks
2 parents bbf0488 + 2041c51 commit 7f41831

8 files changed

Lines changed: 60 additions & 25 deletions

File tree

.github/workflows/linting.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Linting Linux
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
linting:
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
os: [ubuntu-latest]
12+
python-version:
13+
- "3.11"
14+
15+
name: linting
16+
runs-on: ${{ matrix.os }}
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v3
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version : ${{ matrix.python-version }}
26+
27+
- name: Install flake8
28+
run: |
29+
python -m pip install flake8
30+
31+
- name: Check format without making corrections
32+
run: |
33+
flake8

.github/workflows/unit-test.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
name: Unit Test Linux
22

33
on:
4-
push:
5-
# pull_request:
4+
workflow_run:
5+
workflows: [Linting Linux]
6+
types:
7+
- completed
68

79
jobs:
8-
run-tests:
10+
unit-test:
911
strategy:
1012
fail-fast: false
1113
matrix:
@@ -15,7 +17,7 @@ jobs:
1517

1618
name: unit-test
1719
runs-on: ${{ matrix.os }}
18-
# runs-on: python:alpine
20+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1921

2022
steps:
2123
- name: Checkout code
@@ -37,4 +39,3 @@ jobs:
3739
- name: Run tests
3840
run: |
3941
python -m unittest discover -v
40-

funcs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# placeholder file to modularize (to package) .py files under the directory "funcs", making the files importable.
1+
# placeholder file to modularize (to package) .py files under the directory "tests", making the files importable.

funcs/func.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
def sum(x: float, y: float) -> float:
2-
return x + y
2+
return x + y

requirements.txt

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
1-
annotated-types==0.5.0
2-
anyio==3.7.1
3-
fastapi==0.101.1
4-
idna==3.4
5-
numpy==1.25.2
6-
pandas==2.0.3
7-
pydantic==2.3.0
8-
pydantic_core==2.6.3
9-
python-dateutil==2.8.2
10-
pytz==2023.3
11-
six==1.16.0
12-
sniffio==1.3.0
13-
starlette==0.27.0
14-
typing_extensions==4.7.1
15-
tzdata==2023.3
1+
flake8==6.1.0
2+
mccabe==0.7.0
3+
pycodestyle==2.11.0
4+
pyflakes==3.1.0

setup.cfg

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[flake8]
2+
max-line-length = 120
3+
exclude =
4+
.git,
5+
__pycache__,
6+
docs/source/conf.py,
7+
old,
8+
build,
9+
dist,
10+
venv

tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# placeholder file to modularize (to package) .py files under the directory "tests", making the files importable.
1+
# placeholder file to modularize (to package) .py files under the directory "tests", making the files importable.

tests/test_func.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import unittest
22
from funcs import func
33

4+
45
class Test(unittest.TestCase):
56

67
def test_sum(self):
7-
self.assertEqual(func.sum(2,3), 5)
8+
self.assertEqual(func.sum(2, 3), 5)
9+
810

911
if __name__ == "__main__":
10-
unittest.main()
12+
unittest.main()

0 commit comments

Comments
 (0)