From 498d51b4e802cb40cac58aae1eff1f723bbbd896 Mon Sep 17 00:00:00 2001 From: philippeitis <33013301+philippeitis@users.noreply.github.com> Date: Wed, 4 Mar 2020 16:07:32 -0800 Subject: [PATCH 1/5] Enable Continuous Integration with GitHub Actions. This automatically runs unit tests on various operating systems and Python versions when Python files are modified to ensure that functionality remains correct. --- .github/workflows/pythonapp.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/pythonapp.yml diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml new file mode 100644 index 00000000..4f6bbc0b --- /dev/null +++ b/.github/workflows/pythonapp.yml @@ -0,0 +1,31 @@ +name: Test code + +on: + push: + paths: + - "**/*.py" + pull_request: + paths: + - "**/*.py" + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + python-version: [3.6, 3.7, 3.8] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: Test with unittest + run: | + python -m unittest discover tests From de28932650d5027e2781011f1243b89f053b241d Mon Sep 17 00:00:00 2001 From: philippeitis <33013301+philippeitis@users.noreply.github.com> Date: Wed, 4 Mar 2020 16:14:03 -0800 Subject: [PATCH 2/5] Consolidate dictionary into creation, trigger CI --- jc/parsers/arp.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/jc/parsers/arp.py b/jc/parsers/arp.py index 1d8e9d92..babffcd9 100644 --- a/jc/parsers/arp.py +++ b/jc/parsers/arp.py @@ -196,12 +196,13 @@ def parse(data, raw=False, quiet=False): raw_output = [] for line in cleandata: line = line.split() - output_line = {} - output_line['name'] = line[0] - output_line['address'] = line[1].lstrip('(').rstrip(')') - output_line['hwtype'] = line[4].lstrip('[').rstrip(']') - output_line['hwaddress'] = line[3] - output_line['iface'] = line[6] + output_line = { + 'name': line[0], + 'address': line[1].lstrip('(').rstrip(')'), + 'hwtype': line[4].lstrip('[').rstrip(']'), + 'hwaddress': line[3], + 'iface': line[6], + } raw_output.append(output_line) if raw: From 9b148e0ba37e18749d95608e1bac6c090ab83ee2 Mon Sep 17 00:00:00 2001 From: philippeitis <33013301+philippeitis@users.noreply.github.com> Date: Wed, 4 Mar 2020 16:16:19 -0800 Subject: [PATCH 3/5] Add requirements.txt --- requirements.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..0a08f111 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +ifconfig-parser>=0.0.5 +ruamel.yaml>=0.15.0 +xmltodict>=0.12.0 From e4eab4641ac15220f2787c5d27b443ab8c718b86 Mon Sep 17 00:00:00 2001 From: philippeitis <33013301+philippeitis@users.noreply.github.com> Date: Wed, 4 Mar 2020 16:17:58 -0800 Subject: [PATCH 4/5] Change line in blkid.py to trigger CI --- jc/parsers/blkid.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/jc/parsers/blkid.py b/jc/parsers/blkid.py index d21353d3..b241acaf 100644 --- a/jc/parsers/blkid.py +++ b/jc/parsers/blkid.py @@ -150,8 +150,7 @@ def process(proc_data): for key in int_list: if key in entry: try: - key_int = int(entry[key]) - entry[key] = key_int + entry[key] = int(entry[key]) except (ValueError): entry[key] = None From 51d5c3892d6ff1e2e6ac7c4f3e496e7d9ed4b6a7 Mon Sep 17 00:00:00 2001 From: philippeitis <33013301+philippeitis@users.noreply.github.com> Date: Wed, 4 Mar 2020 16:21:06 -0800 Subject: [PATCH 5/5] Remove Windows tests, due to lack of support. --- .github/workflows/pythonapp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 4f6bbc0b..9acb14c6 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -13,7 +13,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-latest, ubuntu-latest, windows-latest] + os: [macos-latest, ubuntu-latest] python-version: [3.6, 3.7, 3.8] steps: