From 4d6641a7d3a72e8865df19de45d8f1cf588d266e Mon Sep 17 00:00:00 2001 From: Gary Snider <75227981+gsnider2195@users.noreply.github.com> Date: Wed, 18 Sep 2024 12:55:53 -0700 Subject: [PATCH 1/4] fixed invoke check-migrations --- tasks.py | 48 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/tasks.py b/tasks.py index 4bae04d6d..bc0bab1f7 100644 --- a/tasks.py +++ b/tasks.py @@ -16,12 +16,19 @@ from invoke import Collection, task as invoke_task import os -from dotenv import load_dotenv +try: + from dotenv import load_dotenv + + HAS_DOTENV = True +except ImportError: + HAS_DOTENV = False def _load_dotenv(): - load_dotenv("./development/development.env") - load_dotenv("./development/creds.env") + """Load environment variables from .env file.""" + if HAS_DOTENV: + load_dotenv("./development/development.env") + load_dotenv("./development/creds.env") def is_truthy(arg): @@ -104,7 +111,9 @@ def docker_compose(context, command, **kwargs): ] for compose_file in context.nautobot_ssot.compose_files: - compose_file_path = os.path.join(context.nautobot_ssot.compose_dir, compose_file) + compose_file_path = os.path.join( + context.nautobot_ssot.compose_dir, compose_file + ) compose_command_tokens.append(f' -f "{compose_file_path}"') compose_command_tokens.append(command) @@ -201,7 +210,9 @@ def restart(context, service=""): def stop(context, service=""): """Stop specified or all services, if service is not specified, remove all containers.""" print("Stopping Nautobot...") - docker_compose(context, "stop" if service else "down --remove-orphans", service=service) + docker_compose( + context, "stop" if service else "down --remove-orphans", service=service + ) @task @@ -409,7 +420,9 @@ def dbshell(context, query="", input="", output=""): if output: command += [f"> '{output}'"] - docker_compose(context, " ".join(command), env=env_vars, pty=not (input or output or query)) + docker_compose( + context, " ".join(command), env=env_vars, pty=not (input or output or query) + ) @task( @@ -507,7 +520,9 @@ def backup_db(context, output="dump.sql", readable=True): print(50 * "=") print("The database backup has been successfully completed and saved to the file:") print(output) - print("If you want to import this database backup, please execute the following command:") + print( + "If you want to import this database backup, please execute the following command:" + ) print(f"invoke import-db --input '{output}'") print(50 * "=") @@ -536,7 +551,9 @@ def docs(context): print("Serving Documentation...") run_command(context, command) else: - print("Only used when developing locally (i.e. context.nautobot_ssot.local=True)!") + print( + "Only used when developing locally (i.e. context.nautobot_ssot.local=True)!" + ) # ------------------------------------------------------------------------------ @@ -609,7 +626,7 @@ def yamllint(context): @task def check_migrations(context): """Check for missing migrations.""" - command = "nautobot-server --config=nautobot/core/tests/nautobot_config.py makemigrations --dry-run --check" + command = "nautobot-server makemigrations --dry-run --check" run_command(context, command) @@ -623,7 +640,14 @@ def check_migrations(context): "pattern": "Run specific test methods, classes, or modules instead of all tests", } ) -def unittest(context, keepdb=False, label="nautobot_ssot", failfast=False, buffer=True, pattern=""): +def unittest( + context, + keepdb=False, + label="nautobot_ssot", + failfast=False, + buffer=True, + pattern="", +): """Run Nautobot unit tests.""" command = f"coverage run --module nautobot.core.cli test {label}" @@ -641,7 +665,9 @@ def unittest(context, keepdb=False, label="nautobot_ssot", failfast=False, buffe @task def unittest_coverage(context): """Report on code test coverage as measured by 'invoke unittest'.""" - command = "coverage report --skip-covered --include 'nautobot_ssot/*' --omit *migrations*" + command = ( + "coverage report --skip-covered --include 'nautobot_ssot/*' --omit *migrations*" + ) run_command(context, command) From b6de2d690fd0a55f5bc370c50a3634df8e54cdb1 Mon Sep 17 00:00:00 2001 From: Gary Snider <75227981+gsnider2195@users.noreply.github.com> Date: Wed, 18 Sep 2024 13:00:19 -0700 Subject: [PATCH 2/4] black --- tasks.py | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/tasks.py b/tasks.py index bc0bab1f7..2a969cdd0 100644 --- a/tasks.py +++ b/tasks.py @@ -111,9 +111,7 @@ def docker_compose(context, command, **kwargs): ] for compose_file in context.nautobot_ssot.compose_files: - compose_file_path = os.path.join( - context.nautobot_ssot.compose_dir, compose_file - ) + compose_file_path = os.path.join(context.nautobot_ssot.compose_dir, compose_file) compose_command_tokens.append(f' -f "{compose_file_path}"') compose_command_tokens.append(command) @@ -210,9 +208,7 @@ def restart(context, service=""): def stop(context, service=""): """Stop specified or all services, if service is not specified, remove all containers.""" print("Stopping Nautobot...") - docker_compose( - context, "stop" if service else "down --remove-orphans", service=service - ) + docker_compose(context, "stop" if service else "down --remove-orphans", service=service) @task @@ -420,9 +416,7 @@ def dbshell(context, query="", input="", output=""): if output: command += [f"> '{output}'"] - docker_compose( - context, " ".join(command), env=env_vars, pty=not (input or output or query) - ) + docker_compose(context, " ".join(command), env=env_vars, pty=not (input or output or query)) @task( @@ -520,9 +514,7 @@ def backup_db(context, output="dump.sql", readable=True): print(50 * "=") print("The database backup has been successfully completed and saved to the file:") print(output) - print( - "If you want to import this database backup, please execute the following command:" - ) + print("If you want to import this database backup, please execute the following command:") print(f"invoke import-db --input '{output}'") print(50 * "=") @@ -551,9 +543,7 @@ def docs(context): print("Serving Documentation...") run_command(context, command) else: - print( - "Only used when developing locally (i.e. context.nautobot_ssot.local=True)!" - ) + print("Only used when developing locally (i.e. context.nautobot_ssot.local=True)!") # ------------------------------------------------------------------------------ @@ -665,9 +655,7 @@ def unittest( @task def unittest_coverage(context): """Report on code test coverage as measured by 'invoke unittest'.""" - command = ( - "coverage report --skip-covered --include 'nautobot_ssot/*' --omit *migrations*" - ) + command = "coverage report --skip-covered --include 'nautobot_ssot/*' --omit *migrations*" run_command(context, command) From 341f0b905cf93c3e34ba622a37299c34d6761e7b Mon Sep 17 00:00:00 2001 From: Gary Snider <75227981+gsnider2195@users.noreply.github.com> Date: Wed, 18 Sep 2024 14:19:48 -0700 Subject: [PATCH 3/4] fix ci --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2677de9b7..491e4d950 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ on: # yamllint disable-line rule:truthy rule:comments pull_request: ~ env: - PLUGIN_NAME: "nautobot-plugin-ssot" + PLUGIN_NAME: "nautobot-ssot" jobs: black: From fafc85d1d5f9061e699b31f198423a187c2dff24 Mon Sep 17 00:00:00 2001 From: Gary Snider <75227981+gsnider2195@users.noreply.github.com> Date: Wed, 18 Sep 2024 14:41:45 -0700 Subject: [PATCH 4/4] fix ci part 2 --- development/docker-compose.mysql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/development/docker-compose.mysql.yml b/development/docker-compose.mysql.yml index c7fa6a1fb..5896cddf2 100644 --- a/development/docker-compose.mysql.yml +++ b/development/docker-compose.mysql.yml @@ -19,7 +19,7 @@ services: db: image: "mysql:8" command: - - "--default-authentication-plugin=mysql_native_password" + - "--max_connections=1000" env_file: - "development.env" - "creds.env"