Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LTM 1.6 housekeeping #350

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
name: "Pull Requests (main)"
name: "Pull Requests (LTM 1.6)"
concurrency: # Cancel any existing runs of this workflow for this same PR
group: "${{ '{{ github.workflow }}' }}-${{ '{{ github.ref }}' }}"
cancel-in-progress: true
on: # yamllint disable
pull_request:
branches:
- "main"
- "ltm-1.6"

jobs:
tests:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/trigger_pr_normal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ concurrency: # Cancel any existing runs of this workflow for this same PR
on: # yamllint disable
pull_request:
branches-ignore:
- "main"
- "ltm-1.6"

jobs:
tests:
Expand Down
11 changes: 0 additions & 11 deletions .github/workflows/trigger_scheduled.yml

This file was deleted.

1 change: 0 additions & 1 deletion development/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ x-nautobot-base: &nautobot-base
- "dev.env"
tty: true

version: "3.8"
services:
nautobot:
build:
Expand Down
8 changes: 0 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
version: "3.4"
x-args:
&args
PYTHON_VER: ${PYTHON_VER}
Expand Down Expand Up @@ -34,10 +33,3 @@ services:
build:
<<: *build
target: integration
networks:
- integration_network

# Attach these services to the Nautobot network that gets spun up from invoke start
networks:
integration_network:
name: nautobot_ansible_default
63 changes: 47 additions & 16 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def is_truthy(arg):
namespace.configure(
{
"nautobot_ansible": {
"nautobot_ver": "1.5",
"nautobot_ver": "1.6",
"project_name": "nautobot_ansible",
"python_ver": "3.9",
"local": False,
Expand Down Expand Up @@ -56,22 +56,22 @@ def task_wrapper(function=None):


def docker_compose(context, command, **kwargs):
"""Helper function for running a specific docker-compose command with all appropriate parameters and environment.
"""Helper function for running a specific docker compose command with all appropriate parameters and environment.
Args:
context (obj): Used to run specific commands
command (str): Command string to append to the "docker-compose ..." command, such as "build", "up", etc.
command (str): Command string to append to the "docker compose ..." command, such as "build", "up", etc.
**kwargs: Passed through to the context.run() call.
"""
build_env = {
"NAUTOBOT_VER": context.nautobot_ansible.nautobot_ver,
"PYTHON_VER": context.nautobot_ansible.python_ver,
}
compose_command = f'docker-compose --project-name {context.nautobot_ansible.project_name} --project-directory "{context.nautobot_ansible.compose_dir}"'
compose_command = f'docker compose --project-name {context.nautobot_ansible.project_name} --project-directory "{context.nautobot_ansible.compose_dir}"'
for compose_file in context.nautobot_ansible.compose_files:
compose_file_path = os.path.join(context.nautobot_ansible.compose_dir, compose_file)
compose_command += f' -f "{compose_file_path}"'
compose_command += f" {command}"
print(f'Running docker-compose command "{command}"')
print(f'Running docker compose command "{command}"')
return context.run(compose_command, env=build_env, **kwargs)


Expand Down Expand Up @@ -219,29 +219,53 @@ def post_upgrade(context):
def lint(context):
"""Run linting tools"""
context.run(
"docker-compose up --build --force-recreate --quiet-pull --exit-code-from lint lint",
"docker compose --project-name nautobot_ansible up --build --force-recreate --exit-code-from lint lint",
env={"PYTHON_VER": context["nautobot_ansible"]["python_ver"]},
)


@task
def unit(context):
@task(
help={
"verbose": "Run the tests with verbose output; can be provided multiple times for more verbosity (e.g. -v, -vv, -vvv)",
},
incrementable=["verbose"],
)
def unit(context, verbose=0):
"""Run unit tests"""
context.run(
"docker-compose up --build --force-recreate --quiet-pull --exit-code-from unit unit",
env={"PYTHON_VER": context["nautobot_ansible"]["python_ver"]},
)
env = {"PYTHON_VER": context["nautobot_ansible"]["python_ver"]}
if verbose:
env["ANSIBLE_UNIT_ARGS"] = f"-{'v' * verbose}"
context.run("docker compose --project-name nautobot_ansible up --build --force-recreate --exit-code-from unit unit", env=env)


@task
def integration(context):
@task(
help={
"verbose": "Run the tests with verbose output; can be provided multiple times for more verbosity (e.g. -v, -vv, -vvv)",
"tags": "Run specific test tags (e.g. 'device' or 'location'); can be provided multiple times (e.g. --tags device --tags location)",
},
iterable=["tags"],
incrementable=["verbose"],
)
def integration(context, verbose=0, tags=None):
"""Run all tests including integration tests"""
build(context)
# Destroy any existing containers and volumes that may be left over from a previous run
destroy(context)
start(context)
env = {"PYTHON_VER": context["nautobot_ansible"]["python_ver"]}
ansible_args = []
if verbose:
ansible_args.append(f"-{'v' * verbose}")
if tags:
ansible_args.append(f"--tags {','.join(tags)}")
if ansible_args:
env["ANSIBLE_INTEGRATION_ARGS"] = " ".join(ansible_args)
context.run(
"docker-compose up --build --force-recreate --quiet-pull --exit-code-from integration integration",
env={"PYTHON_VER": context["nautobot_ansible"]["python_ver"]},
"docker compose --project-name nautobot_ansible up --build --force-recreate --exit-code-from integration integration",
env=env,
)
# Clean up after the tests
destroy(context)


@task(
Expand All @@ -255,3 +279,10 @@ def galaxy_build(context, force=False):
if force:
command += " --force"
context.run(command)


@task()
def make_docs(context):
"""Update ansible module docs before release."""
command = "./hacking/make-docs.sh"
context.run(command)
Loading