Skip to content

Commit 8fa45c8

Browse files
authored
Bump CI to use Ansible-Core 2.14 (#998)
1 parent 59e5095 commit 8fa45c8

File tree

109 files changed

+2393
-1643
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+2393
-1643
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
strategy:
3131
fail-fast: false
3232
matrix:
33-
python-version: ["3.9", "3.10"]
33+
python-version: ["3.9", "3.10", "3.11"]
3434

3535
steps:
3636

@@ -76,14 +76,13 @@ jobs:
7676
fail-fast: false
7777
matrix:
7878
include:
79-
- VERSION: "v3.2"
80-
NETBOX_DOCKER_VERSION: 1.6.1
8179
- VERSION: "v3.3"
8280
NETBOX_DOCKER_VERSION: 2.3.0
8381
- VERSION: "v3.4"
8482
NETBOX_DOCKER_VERSION: 2.5.3
8583
#- VERSION: "v3.5"
8684
# NETBOX_DOCKER_VERSION: 2.6.1
85+
# If we want to integration test wiht all supported Python:
8786
#python-version: ["3.9", "3.10", "3.11"]
8887

8988
steps:

poetry.lock

Lines changed: 1094 additions & 1051 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ license = "GPLv3"
77

88
[tool.poetry.dependencies]
99
python = "^3.9"
10-
ansible-core = "2.13.*"
10+
ansible-core = "2.14.3"
1111
black = "*"
1212
codecov = "*"
13-
coverage = "^4.0"
13+
coverage = "6.5.*"
14+
deepdiff = "*"
1415
cryptography = "*"
1516
jinja2 = "*"
1617
jmespath = "*"
17-
jsondiff = "*"
1818
pynetbox = "^7"
1919
pytest = "*"
2020
pytest-mock = "*"

tests/integration/netbox-deploy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import os
88
import sys
9+
910
import pynetbox
1011
from packaging import version
1112

tests/integration/targets/inventory-v3.3/compare_inventory_json.py

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
__metaclass__ = type
99

10-
import sys
11-
import json
1210
import argparse
13-
from jsondiff import diff
14-
from typing import Iterable
11+
import json
12+
import sys
1513
from operator import itemgetter
1614

15+
from deepdiff import DeepDiff
16+
1717
# NetBox includes "created" and "last_updated" times on objects. These end up in the interfaces objects that are included verbatim from the NetBox API.
1818
# "url" may be different if local tests use a different host/port
1919
# Remove these from files saved in git as test data
@@ -33,15 +33,6 @@
3333
)
3434

3535

36-
def all_keys_to_ignore(netbox_version):
37-
keys = KEYS_REMOVE.union(KEYS_IGNORE)
38-
39-
if netbox_version == "v2.7":
40-
return keys.union(KEYS_IGNORE_27)
41-
else:
42-
return keys
43-
44-
4536
# Assume the object will not be recursive, as it originally came from JSON
4637
def remove_keys(obj, keys):
4738
if isinstance(obj, dict):
@@ -71,24 +62,22 @@ def sort_hostvar_arrays(obj):
7162
if not hostvars:
7263
return
7364

74-
for hostname, host in hostvars.items():
75-
interfaces = host.get("interfaces")
76-
if interfaces:
65+
for _, host in hostvars.items():
66+
if interfaces := host.get("interfaces"):
7767
host["interfaces"] = sorted(interfaces, key=itemgetter("id"))
7868

79-
services = host.get("services")
80-
if services:
69+
if services := host.get("services"):
8170
host["services"] = sorted(services, key=itemgetter("id"))
8271

8372

8473
def read_json(filename):
85-
with open(filename, "r") as f:
86-
return json.loads(f.read())
74+
with open(filename, "r", encoding="utf-8") as file:
75+
return json.loads(file.read())
8776

8877

8978
def write_json(filename, data):
90-
with open(filename, "w") as f:
91-
json.dump(data, f, indent=4)
79+
with open(filename, "w", encoding="utf-8") as file:
80+
json.dump(data, file, indent=4)
9281

9382

9483
def main():
@@ -140,17 +129,15 @@ def main():
140129
data_b = read_json(args.filename_b)
141130

142131
# Ignore keys that we don't want to diff, in addition to the ones removed that change on every commit
143-
keys = all_keys_to_ignore(args.netbox_version)
132+
keys = KEYS_REMOVE.union(KEYS_IGNORE)
144133
remove_keys(data_a, keys)
145134
remove_keys(data_b, keys)
146135

147136
sort_hostvar_arrays(data_a)
148137
sort_hostvar_arrays(data_b)
149138

150139
# Perform the diff
151-
# syntax='symmetric' will produce output that prints both the before and after as "$insert" and "$delete"
152-
# marshal=True removes any special types, allowing to be dumped as json
153-
result = diff(data_a, data_b, marshal=True, syntax="symmetric")
140+
result = DeepDiff(data_a, data_b, ignore_order=True)
154141

155142
if result:
156143
# Dictionary is not empty - print differences

tests/integration/targets/inventory-v3.4/compare_inventory_json.py

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
__metaclass__ = type
99

10-
import sys
11-
import json
1210
import argparse
13-
from jsondiff import diff
14-
from typing import Iterable
11+
import json
12+
import sys
1513
from operator import itemgetter
1614

15+
from deepdiff import DeepDiff
16+
1717
# NetBox includes "created" and "last_updated" times on objects. These end up in the interfaces objects that are included verbatim from the NetBox API.
1818
# "url" may be different if local tests use a different host/port
1919
# Remove these from files saved in git as test data
@@ -33,15 +33,6 @@
3333
)
3434

3535

36-
def all_keys_to_ignore(netbox_version):
37-
keys = KEYS_REMOVE.union(KEYS_IGNORE)
38-
39-
if netbox_version == "v2.7":
40-
return keys.union(KEYS_IGNORE_27)
41-
else:
42-
return keys
43-
44-
4536
# Assume the object will not be recursive, as it originally came from JSON
4637
def remove_keys(obj, keys):
4738
if isinstance(obj, dict):
@@ -71,24 +62,22 @@ def sort_hostvar_arrays(obj):
7162
if not hostvars:
7263
return
7364

74-
for hostname, host in hostvars.items():
75-
interfaces = host.get("interfaces")
76-
if interfaces:
65+
for _, host in hostvars.items():
66+
if interfaces := host.get("interfaces"):
7767
host["interfaces"] = sorted(interfaces, key=itemgetter("id"))
7868

79-
services = host.get("services")
80-
if services:
69+
if services := host.get("services"):
8170
host["services"] = sorted(services, key=itemgetter("id"))
8271

8372

8473
def read_json(filename):
85-
with open(filename, "r") as f:
86-
return json.loads(f.read())
74+
with open(filename, "r", encoding="utf-8") as file:
75+
return json.loads(file.read())
8776

8877

8978
def write_json(filename, data):
90-
with open(filename, "w") as f:
91-
json.dump(data, f, indent=4)
79+
with open(filename, "w", encoding="utf-8") as file:
80+
json.dump(data, file, indent=4)
9281

9382

9483
def main():
@@ -140,17 +129,15 @@ def main():
140129
data_b = read_json(args.filename_b)
141130

142131
# Ignore keys that we don't want to diff, in addition to the ones removed that change on every commit
143-
keys = all_keys_to_ignore(args.netbox_version)
132+
keys = KEYS_REMOVE.union(KEYS_IGNORE)
144133
remove_keys(data_a, keys)
145134
remove_keys(data_b, keys)
146135

147136
sort_hostvar_arrays(data_a)
148137
sort_hostvar_arrays(data_b)
149138

150139
# Perform the diff
151-
# syntax='symmetric' will produce output that prints both the before and after as "$insert" and "$delete"
152-
# marshal=True removes any special types, allowing to be dumped as json
153-
result = diff(data_a, data_b, marshal=True, syntax="symmetric")
140+
result = DeepDiff(data_a, data_b, ignore_order=True)
154141

155142
if result:
156143
# Dictionary is not empty - print differences

tests/integration/targets/inventory-v3.2/compare_inventory_json.py renamed to tests/integration/targets/inventory-v3.5/compare_inventory_json.py

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
__metaclass__ = type
99

10-
import sys
11-
import json
1210
import argparse
13-
from jsondiff import diff
14-
from typing import Iterable
11+
import json
12+
import sys
1513
from operator import itemgetter
1614

15+
from deepdiff import DeepDiff
16+
1717
# NetBox includes "created" and "last_updated" times on objects. These end up in the interfaces objects that are included verbatim from the NetBox API.
1818
# "url" may be different if local tests use a different host/port
1919
# Remove these from files saved in git as test data
@@ -33,15 +33,6 @@
3333
)
3434

3535

36-
def all_keys_to_ignore(netbox_version):
37-
keys = KEYS_REMOVE.union(KEYS_IGNORE)
38-
39-
if netbox_version == "v2.7":
40-
return keys.union(KEYS_IGNORE_27)
41-
else:
42-
return keys
43-
44-
4536
# Assume the object will not be recursive, as it originally came from JSON
4637
def remove_keys(obj, keys):
4738
if isinstance(obj, dict):
@@ -71,24 +62,22 @@ def sort_hostvar_arrays(obj):
7162
if not hostvars:
7263
return
7364

74-
for hostname, host in hostvars.items():
75-
interfaces = host.get("interfaces")
76-
if interfaces:
65+
for _, host in hostvars.items():
66+
if interfaces := host.get("interfaces"):
7767
host["interfaces"] = sorted(interfaces, key=itemgetter("id"))
7868

79-
services = host.get("services")
80-
if services:
69+
if services := host.get("services"):
8170
host["services"] = sorted(services, key=itemgetter("id"))
8271

8372

8473
def read_json(filename):
85-
with open(filename, "r") as f:
86-
return json.loads(f.read())
74+
with open(filename, "r", encoding="utf-8") as file:
75+
return json.loads(file.read())
8776

8877

8978
def write_json(filename, data):
90-
with open(filename, "w") as f:
91-
json.dump(data, f, indent=4)
79+
with open(filename, "w", encoding="utf-8") as file:
80+
json.dump(data, file, indent=4)
9281

9382

9483
def main():
@@ -140,17 +129,15 @@ def main():
140129
data_b = read_json(args.filename_b)
141130

142131
# Ignore keys that we don't want to diff, in addition to the ones removed that change on every commit
143-
keys = all_keys_to_ignore(args.netbox_version)
132+
keys = KEYS_REMOVE.union(KEYS_IGNORE)
144133
remove_keys(data_a, keys)
145134
remove_keys(data_b, keys)
146135

147136
sort_hostvar_arrays(data_a)
148137
sort_hostvar_arrays(data_b)
149138

150139
# Perform the diff
151-
# syntax='symmetric' will produce output that prints both the before and after as "$insert" and "$delete"
152-
# marshal=True removes any special types, allowing to be dumped as json
153-
result = diff(data_a, data_b, marshal=True, syntax="symmetric")
140+
result = DeepDiff(data_a, data_b, ignore_order=True)
154141

155142
if result:
156143
# Dictionary is not empty - print differences

0 commit comments

Comments
 (0)