@@ -242,13 +242,16 @@ def lint(context):
242242 help = {
243243 "verbose" : "Run the tests with verbose output; can be provided multiple times for more verbosity (e.g. -v, -vv, -vvv)" ,
244244 "skip" : "Skip specific tests (choices: lint, sanity, unit); can be provided multiple times (e.g. --skip lint --skip sanity)" ,
245+ "ansible_core_branch" : "Test against a specific ansible-core git branch (e.g. 'devel', 'milestone')" ,
245246 },
246247 iterable = ["skip" ],
247248 incrementable = ["verbose" ],
248249)
249- def unit (context , verbose = 0 , skip = None ):
250+ def unit (context , verbose = 0 , skip = None , ansible_core_branch = None ):
250251 """Run unit tests."""
251252 env = {"PYTHON_VER" : context .nautobot_ansible .python_ver }
253+ if ansible_core_branch is not None :
254+ env ["ANSIBLE_CORE_BRANCH" ] = ansible_core_branch
252255 if verbose :
253256 env ["ANSIBLE_SANITY_ARGS" ] = f"-{ 'v' * verbose } "
254257 env ["ANSIBLE_UNIT_ARGS" ] = f"-{ 'v' * verbose } "
@@ -324,40 +327,6 @@ def integration(context, verbose=0, tags=None, update_inventories=False, skip=No
324327 destroy (context )
325328
326329
327- @task (
328- help = {
329- "branch" : "The ansible-core git branch to test against (default: devel)" ,
330- "python_ver" : "Python version to use (default: 3.12)" ,
331- "verbose" : "Run the tests with verbose output; can be provided multiple times for more verbosity" ,
332- "skip" : "Skip specific tests (choices: lint, sanity, unit); can be provided multiple times" ,
333- },
334- iterable = ["skip" ],
335- incrementable = ["verbose" ],
336- )
337- def devel (context , branch = "devel" , python_ver = "3.12" , verbose = 0 , skip = None ):
338- """Run sanity and unit tests against an ansible-core development branch."""
339- env = {
340- "PYTHON_VER" : python_ver ,
341- "ANSIBLE_CORE_BRANCH" : branch ,
342- }
343- if verbose :
344- env ["ANSIBLE_SANITY_ARGS" ] = f"-{ 'v' * verbose } "
345- env ["ANSIBLE_UNIT_ARGS" ] = f"-{ 'v' * verbose } "
346- if skip is not None :
347- if "lint" in skip :
348- env ["SKIP_LINT_TESTS" ] = "true"
349- if "sanity" in skip :
350- env ["SKIP_SANITY_TESTS" ] = "true"
351- if "unit" in skip :
352- env ["SKIP_UNIT_TESTS" ] = "true"
353- print (f"Running tests against ansible-core branch: { branch } " )
354- context .run (
355- f"docker compose --project-name { context .nautobot_ansible .project_name } up --build --force-recreate --exit-code-from unit unit" ,
356- env = env ,
357- )
358- context .run (f"docker compose --project-name { context .nautobot_ansible .project_name } down" )
359-
360-
361330@task (
362331 help = {
363332 "force" : "Force the build command to create a new collection, overwriting any existing files." ,
0 commit comments