nautobot / cookiecutter-nautobot-app

Cookiecutter template for creating new Nautobot Apps.
https://docs.nautobot.com/projects/cookiecutter-nautobot-app/en/latest/
Apache License 2.0
14 stars 5 forks source link

Newly baked cookie does not pass GitHub tests #119

Closed mzbroch closed 1 month ago

mzbroch commented 2 months ago

Environment

Observed Behavior

For the newly rendered cookie tests on GitHub are failing :

Run poetry run invoke ruff --action format
Would reformat: aci_models/__init__.py
Would reformat: aci_models/api/serializers.py
Would reformat: aci_models/forms.py
Would reformat: aci_models/tests/fixtures.py
Would reformat: aci_models/tests/test_api_views.py
Would reformat: aci_models/tests/test_form_acimodel.py
Would reformat: aci_models/tests/test_views.py
Would reformat: aci_models/views.py
Would reformat: development/app_config_schema.py
9 files would be reformatted, 16 files already formatted
Error: Process completed with exit code 1.

Expected Behavior

I can render cookie and it passes all GH tests

Steps to Reproduce

  1. Render with cookiecutter
  2. Upload to GH (tests are failing)
glennmatthews commented 2 months ago

This is due to not pinning a specific version of ruff in the cookiecutter - presumably a newly baked cookie is pulling in a newer version of ruff than the one that the cookiecutter was tested against.

bryanculver commented 1 month ago

We should pin ruff with this work.

gsnider2195 commented 1 month ago

I don't think we're going to be able to make this perfect because of variability in the project name length causing issues like this:

diff --git a/tasks.py b/tasks.py
index add0c7f..3068dc7 100644
--- a/tasks.py
+++ b/tasks.py
@@ -661,7 +661,9 @@ def hadolint(context):
 @task
 def pylint(context):
     """Run pylint code analysis."""
-    command = 'pylint --init-hook "import nautobot; nautobot.setup()" --rcfile pyproject.toml nautobot_ssot_system_of_record'
+    command = (
+        'pylint --init-hook "import nautobot; nautobot.setup()" --rcfile pyproject.toml nautobot_ssot_system_of_record'
+    )
     run_command(context, command)
diff --git a/tasks.py b/tasks.py
index ad30929..f41ea1e 100644
--- a/tasks.py
+++ b/tasks.py
@@ -661,9 +661,7 @@ def hadolint(context):
 @task
 def pylint(context):
     """Run pylint code analysis."""
-    command = (
-        'pylint --init-hook "import nautobot; nautobot.setup()" --rcfile pyproject.toml nautobot_chatops_my_app'
-    )
+    command = 'pylint --init-hook "import nautobot; nautobot.setup()" --rcfile pyproject.toml nautobot_chatops_my_app'
     run_command(context, command)

I'll update the docs to add ruff to the quick start steps

gsnider2195 commented 1 month ago

@glennmatthews do you think it's worth the technical debt to pin ruff in the cookie cutter? I do remember that at some point there was a change in ruff's behavior for line breaks but I can't remember if that was a change in ruff's behavior or if it was something we changed in core's config. I think the root cause of this issue is fixed by fixing the docs and the invoke autoformat/invoke ruff commands.

glennmatthews commented 1 month ago

My personal preference would be to pin the versions of all the dev dependencies (at least to a major version, for those using semver) for reproducible results, and use renovate to keep the cookie up-to-date and driftmanager to push the updates to the apps as appropriate.

gsnider2195 commented 1 month ago

My personal preference would be to pin the versions of all the dev dependencies (at least to a major version, for those using semver) for reproducible results, and use renovate to keep the cookie up-to-date and driftmanager to push the updates to the apps as appropriate.

It looks like ruff doesn't use semantic versioning so our only option here may be to hard pin it.