Skip to content

Commit

Permalink
update test runs & ci
Browse files Browse the repository at this point in the history
  • Loading branch information
whitej6 committed Dec 7, 2023
1 parent ba51b2f commit f3f48a2
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 45 deletions.
32 changes: 0 additions & 32 deletions .github/workflows/check-pr-qa.yaml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: "CI"
concurrency: # Cancel any existing runs of this workflow for this same PR
group: "{% raw %}${{ github.workflow }}-${{ github.ref }}{% endraw %}"
cancel-in-progress: true
on: # yamllint disable-line rule:truthy rule:comments
push:
branches:
- "main"
- "develop"
tags:
- "v*"
pull_request: ~

jobs:
qa:
runs-on: "ubuntu-22.04"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v4"
- name: "Linting: black"
run: "poetry run invoke black"
- name: "Linting: yamllint"
run: "poetry run invoke yamllint"
- name: "Linting: pylint"
run: "poetry run invoke pylint"
- name: "Docs: mkdocs build check"
run: "poetry run invoke build-and-check-docs"
- name: "Testing: unittest"
run: "poetry run invoke unittest"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,4 @@ dmypy.json
.pyre/

/outputs/
/nautobot-app*/examples/
2 changes: 1 addition & 1 deletion nautobot-app-ssot/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def cookies_baked_nautobot_app_ssot(cookies):
# pylint: disable-next=protected-access
environ["COOKIECUTTER_CONFIG"] = str(cookies._config_file)
for plugin_slug, extra_context in extra_contexts.items():
results[plugin_slug] = cookies.bake(extra_context=extra_context)
results[plugin_slug] = cookies.bake(extra_context=extra_context, template="nautobot-app-ssot")

assert results[plugin_slug].exception is None

Expand Down
2 changes: 1 addition & 1 deletion nautobot-app-ssot/tests/test_bake_nautobot_app_ssot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def test_bake_project(cookies):
# pylint: disable-next=protected-access
environ["COOKIECUTTER_CONFIG"] = str(cookies._config_file)
result = cookies.bake()
result = cookies.bake(template="nautobot-app-ssot")

assert result.exit_code == 0
assert result.exception is None
Expand Down
2 changes: 1 addition & 1 deletion nautobot-app/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def cookies_baked_nautobot_app(cookies):
# pylint: disable-next=protected-access
environ["COOKIECUTTER_CONFIG"] = str(cookies._config_file)
for plugin_slug, extra_context in extra_contexts.items():
results[plugin_slug] = cookies.bake(extra_context=extra_context)
results[plugin_slug] = cookies.bake(extra_context=extra_context, template="nautobot-app")

assert results[plugin_slug].exception is None

Expand Down
2 changes: 1 addition & 1 deletion nautobot-app/tests/test_bake_nautobot_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def test_bake_project(cookies):
# pylint: disable-next=protected-access
environ["COOKIECUTTER_CONFIG"] = str(cookies._config_file)
result = cookies.bake()
result = cookies.bake(template="nautobot-app")

assert result.exit_code == 0
assert result.exception is None
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,4 @@ testpaths = [
# "nautobot-app-chatops/tests",
"nautobot-app-ssot/tests",
]
addopts = "--color=yes"
15 changes: 6 additions & 9 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,18 +368,15 @@ def yamllint(context):

@task(
help={
"label": "specify a directory or template to test instead of running all tests for all templates",
"label": "specify a directory with tests directory instead of running all tests for all templates (e.g. -l='nautobot-app/tests')",
"failfast": "fail as soon as a single test fails don't run the entire test suite",
"pattern": "Run specific test methods, classes, or modules instead of all tests",
"verbose": "Enable verbose test output.",
}
)
def unittest(context, label="", failfast=False, pattern="", verbose=False, templates=[]):
"""Run Nautobot unit tests."""
command = f"coverage run --module pytest"
templates = templates if templates else context.cookiecutter_nautobot_app.templates
for template in templates:
command += f" --template={template}"
def unittest(context, label="", failfast=False, pattern="", verbose=False):
"""Run Cookie bake unit tests."""
command = f"pytest"

if failfast:
command += " --failfast"
Expand Down Expand Up @@ -411,8 +408,8 @@ def tests(context, failfast=False, keepdb=False, lint_only=False):
black(context)
print("Running yamllint...")
yamllint(context)
# print("Running poetry check...")
# lock(context, check=True)
print("Running poetry check...")
lock(context, check=True)
print("Running pylint...")
pylint(context)
print("Running mkdocs...")
Expand Down

0 comments on commit f3f48a2

Please sign in to comment.