diff --git a/.github/workflows/check-pr-qa.yaml b/.github/workflows/check-pr-qa.yaml deleted file mode 100644 index 13a225f..0000000 --- a/.github/workflows/check-pr-qa.yaml +++ /dev/null @@ -1,32 +0,0 @@ ---- -name: "Check Pull Request Quality Assurance" - -on: # yamllint disable-line rule:truthy - - "pull_request" - -# Cancel any existing runs of this workflow for this same PR -concurrency: - group: "${{ github.workflow }}-${{ github.ref }}" - cancel-in-progress: true - -jobs: - qa: - runs-on: "ubuntu-22.04" - env: - COMPOSE_FILE: "development/compose.yaml" - FROM_IMAGE: "python:3.11-slim" - IMAGE_PREFIX: "ghcr.io/${{ github.repository }}" - IMAGE_TAG: "${{ github.sha }}" - TARGET_WORKDIR: "/${{ github.repository }}" - steps: - - name: "Checkout" - uses: "actions/checkout@v3" - - name: "QA" - run: | - docker compose \ - up \ - --exit-code-from=qa \ - --no-color \ - --no-log-prefix \ - -- \ - qa diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f6d6fe8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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" diff --git a/.gitignore b/.gitignore index 3f4d59b..4a5dc6b 100644 --- a/.gitignore +++ b/.gitignore @@ -129,3 +129,4 @@ dmypy.json .pyre/ /outputs/ +/nautobot-app*/examples/ diff --git a/nautobot-app-ssot/tests/conftest.py b/nautobot-app-ssot/tests/conftest.py index 8851601..bc55edb 100644 --- a/nautobot-app-ssot/tests/conftest.py +++ b/nautobot-app-ssot/tests/conftest.py @@ -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 diff --git a/nautobot-app-ssot/tests/test_bake_nautobot_app_ssot.py b/nautobot-app-ssot/tests/test_bake_nautobot_app_ssot.py index 1403843..dc6c744 100644 --- a/nautobot-app-ssot/tests/test_bake_nautobot_app_ssot.py +++ b/nautobot-app-ssot/tests/test_bake_nautobot_app_ssot.py @@ -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 diff --git a/nautobot-app/tests/conftest.py b/nautobot-app/tests/conftest.py index 2568d18..6f773c0 100644 --- a/nautobot-app/tests/conftest.py +++ b/nautobot-app/tests/conftest.py @@ -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 diff --git a/nautobot-app/tests/test_bake_nautobot_app.py b/nautobot-app/tests/test_bake_nautobot_app.py index 85073e8..90284b3 100644 --- a/nautobot-app/tests/test_bake_nautobot_app.py +++ b/nautobot-app/tests/test_bake_nautobot_app.py @@ -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 diff --git a/pyproject.toml b/pyproject.toml index dd1f2e4..94f83ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -88,3 +88,4 @@ testpaths = [ # "nautobot-app-chatops/tests", "nautobot-app-ssot/tests", ] +addopts = "--color=yes" diff --git a/tasks.py b/tasks.py index 31a7a26..c79b22d 100644 --- a/tasks.py +++ b/tasks.py @@ -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" @@ -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...")