Skip to content

Commit 2c47d1a

Browse files
authoredOct 3, 2020
Merge pull request #75 from timdaman/workflow
Adding initial workflow
2 parents 0dc64b5 + d2ed455 commit 2c47d1a

File tree

5 files changed

+49
-5
lines changed

5 files changed

+49
-5
lines changed
 

‎.coveragerc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
include =
33
check_docker/check_*.py
44
omit =
5-
check_docker/tests/*
5+
tests/*
66
*/__init__.py

‎.github/workflows/tests.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Run tests
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python_version: [3.6, 3.7, 3.8]
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Set up Python
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: ${{ matrix.python_version }}
23+
- name: Install dependencies
24+
run: |
25+
python -V
26+
printenv
27+
python -m pip install --upgrade pip
28+
pip install flake8 pytest coverage pyfakefs pytest-cov
29+
- name: Lint with flake8
30+
run: |
31+
# stop the build if there are Python syntax errors or undefined names
32+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
33+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
34+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
35+
- name: Test with pytest
36+
run: |
37+
pytest --cov=check_docker --cov-fail-under 90 --cov-report term --cov-report html
38+
- uses: actions/upload-artifact@v2
39+
with:
40+
name: coverage_report
41+
path: htmlcov

‎check_docker/check_docker.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ def __getattr__(self, item):
101101
# urllib and http.client's capabilities the class below tweaks HttpConnection and passes it
102102
# to urllib registering for socket:// connections
103103

104+
# This is all side effect so excluding coverage
104105
class SocketFileHandler(AbstractHTTPHandler):
105-
class SocketFileToHttpConnectionAdaptor(HTTPConnection):
106+
class SocketFileToHttpConnectionAdaptor(HTTPConnection): # pragma: no cover
106107
def __init__(self, socket_file, timeout=DEFAULT_TIMEOUT):
107108
super().__init__(host='', port=0, timeout=timeout)
108109
self.socket_file = socket_file
@@ -765,7 +766,7 @@ def process_args(args):
765766
action='store',
766767
type=str,
767768
metavar='WARN:CRIT',
768-
help='Check cpu usage percentage taking into account any limits. Valid values are 0 - 100.')
769+
help='Check cpu usage percentage taking into account any limits.')
769770

770771
# Memory
771772
parser.add_argument('--memory',

‎check_docker/check_swarm.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
# urllib and http.client's capabilities the class below tweaks HttpConnection and passes it
5353
# to urllib registering for socket:// connections
5454

55-
56-
class SocketFileHandler(AbstractHTTPHandler):
55+
# This is all side effect so excluding coverage
56+
class SocketFileHandler(AbstractHTTPHandler): # pragma: no cover
5757
class SocketFileToHttpConnectionAdaptor(HTTPConnection):
5858
def __init__(self, socket_file, timeout=DEFAULT_TIMEOUT):
5959
super().__init__(host='', port=0, timeout=timeout)

‎tests/test_version.py

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ def test_package_present():
3737

3838
@pytest.mark.xfail('TRAVIS_BRANCH' in os.environ and os.environ['TRAVIS_BRANCH'].lower != 'master',
3939
reason="Ignore version check outside of master")
40+
@pytest.mark.xfail('GITHUB_HEAD_REF' in os.environ and os.environ['GITHUB_HEAD_REF'].lower != 'master',
41+
reason="Ignore version check outside of master")
4042
@pytest.mark.skipif('isolated' in os.environ and os.environ['isolated'].lower != 'false',
4143
reason="Can not reach Python package index when isolated")
4244
@pytest.mark.skipif(sys.version_info[0:2] != (3, 8), reason="Only check on python 3.8")

0 commit comments

Comments
 (0)
Please sign in to comment.