diff --git a/.github/workflows/commit.yaml b/.github/workflows/commit.yaml new file mode 100644 index 0000000..07b4330 --- /dev/null +++ b/.github/workflows/commit.yaml @@ -0,0 +1,62 @@ +--- +name: build +on: [push, pull_request] +jobs: + test: + name: Lint and test + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [3.6, 3.7, 3.8, 3.9] + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -r requirements-dev.txt + python -m pip install -e . + - name: Run black + run: | + black --check . + - name: Run linter + run: | + pylava . + - name: Run Tests + run: | + py.test --cov=napalm --cov-report term-missing -vs + release: + name: Build wheels and upload + runs-on: ubuntu-latest + needs: test + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: 3.9 + - name: Install dependencies + run: | + python -m pip install --upgrade pip wheel + python -m pip install -r requirements-dev.txt + - name: Build wheel + run: | + python setup.py bdist_wheel --universal --build-number $GITHUB_RUN_NUMBER + - name: Upload to test + if: github.event_name == 'push' + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + skip_existing: true + - name: Upload Pypi + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index dc15649..0000000 --- a/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -dist: xenial -language: python -python: -- 3.6 -- 3.7 -- 3.8 -env: -- NAPALM=3.0.0 -matrix: - include: - - python: 3.6 - env: TOXENV=black -install: -- pip install tox-travis -- pip install coveralls -deploy: - provider: pypi - skip_existing: true - user: bewing - on: - tags: true - branch: master - password: - secure: mk0a0sOT4Qja0BPRNTvsRU7+vhyEBktZ6rcmdcd0tYM2jqUZzo/zPqPrXDX0Chjl/h4J7jg2LIgBF2Zmmh4SO86un1z77V4DVAYh4U+EGJSFKBNcEZbb0ihRQ0F2mfpiD2TXu7UM47YiPWAvVgWoi/NsIJh/gQWV4qmo/IN0rSrhAsNFyJtwa2uZHIvr3kBnUFSBLu4iScI8Ajf8Nxsz/xbw0HjHHLDd9qE8uE2jc+OVXkTScGRkDyC8sthFSRot6pODDD5Xf2xPFDip6txvS/9i9j8bCsSfIKJg9Syicy/jhXJqI7bKZW6aceqdCuzczDErhuVXvOuYmKlQ0Ks9+6AsU5RICXxOGX3hzw6imFiare1BR0+1i9Aap45fZJ4k3VXfrAaYIm4MZU4n4qNTMOyAbd85BDO1injMgWwg0TKvDzbN7pbRp159rhEN/x/Lee5JN7+ZXsWR5Nx7dmX47zTRTuCitGbkI671goqoaa03uRJGwIpFNsgIFzZI+KiKH/w5CcDE+v10HX+HNMTPkDbq3f2eL5GgAtjVJ3EezXkgmSS8aECU9yUBTThgkwxb0+vHDVHAnH4z02aMK+SiJQ+F3Wv2yaujm7bXEnOTOSkrXNGE0VPZLucn/z5+eUaNsMcXQ9mwGBq6mWOOsDc2Mf4GmhAcEhxu1KUqS/v7W0c= -script: -- tox -after_success: -- coveralls diff --git a/README.md b/README.md index c1794c2..1c2d504 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ [![PyPI](https://img.shields.io/pypi/v/napalm-mos.svg)](https://pypi.python.org/pypi/napalm-mos) -[![Build Status](https://travis-ci.org/napalm-automation-community/napalm-mos.svg?branch=master)](https://travis-ci.org/napalm-automation-community/napalm-mos) [![Coverage Status](https://coveralls.io/repos/github/napalm-automation-community/napalm-mos/badge.svg?branch=master)](https://coveralls.io/github/napalm-automation-community/napalm-mos) diff --git a/napalm_mos/mos.py b/napalm_mos/mos.py index 0b9d6bc..df6d7cc 100644 --- a/napalm_mos/mos.py +++ b/napalm_mos/mos.py @@ -623,7 +623,7 @@ def get_ntp_stats(self): r"^\s?(\+|\*|x|-)?([a-zA-Z0-9\.+-:]+)" r"\s+([a-zA-Z0-9\.]+)\s+([0-9]{1,2})" r"\s+(-|u)\s+([0-9h-]+)\s+([0-9]+)" - r"\s+([0-9]+)\s+([0-9\.]+)\s+([0-9\.-]+)" + r"\s+([0-9]+)\s+([0-9\.]+)\s+([\+0-9\.-]+)" r"\s+([0-9\.]+)\s?$" ) diff --git a/requirements-dev.txt b/requirements-dev.txt index 95e8b53..07cdc76 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,7 +1,7 @@ -black==18.9b0;python_version>="3.6" +black pytest pytest-cov pytest-json pytest-pythonpath -pylama +pylava flake8-import-order diff --git a/setup.cfg b/setup.cfg index 2ae4063..c9c32b9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,13 +1,13 @@ -[pylama] +[pylava] linters = mccabe,pep8,pyflakes ignore = D203,C901 skip = build/*,.tox/* -[pylama:pep8] +[pylava:pep8] max_line_length = 100 [tool:pytest] -addopts = --cov=napalm_mos --cov-report term-missing -vs --pylama +addopts = --cov=napalm_mos --cov-report term-missing -vs --pylava json_report = report.json jsonapi = true diff --git a/setup.py b/setup.py index e07df78..b6ec1a0 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name="napalm-mos", - version="3.0.0", + version="3.0.1", packages=find_packages(), author="Benny Holmgren, Brandon Ewing", author_email="benny@holmgren.id.au, brandon.ewing@warningg.com", diff --git a/test/unit/mocked_data/test_get_ntp_stats/positive_offset/expected_result.json b/test/unit/mocked_data/test_get_ntp_stats/positive_offset/expected_result.json new file mode 100644 index 0000000..4aa5379 --- /dev/null +++ b/test/unit/mocked_data/test_get_ntp_stats/positive_offset/expected_result.json @@ -0,0 +1 @@ +[{"referenceid": ".GPS.", "remote": "192.0.2.1", "synchronized": false, "hostpoll": 64, "stratum": 1, "when": "17", "delay": 0.343, "reachability": 1, "offset": 0.004, "jitter": 0.0, "type": "u"}, {"referenceid": ".MRS.", "remote": "192.0.2.2", "synchronized": false, "hostpoll": 64, "stratum": 1, "when": "1", "delay": 14.541, "reachability": 1, "offset": -0.001, "jitter": 0.0, "type": "u"}] diff --git a/test/unit/mocked_data/test_get_ntp_stats/positive_offset/show_ntp_associations.text b/test/unit/mocked_data/test_get_ntp_stats/positive_offset/show_ntp_associations.text new file mode 100644 index 0000000..98f51b3 --- /dev/null +++ b/test/unit/mocked_data/test_get_ntp_stats/positive_offset/show_ntp_associations.text @@ -0,0 +1,5 @@ + remote refid st t when poll reach delay offset jitter +============================================================================== + 192.0.2.1 .GPS. 1 u 17 64 1 0.343 +0.004 0.000 + 192.0.2.2 .MRS. 1 u 1 64 1 14.541 -0.001 0.000 +