From b7f2544b30689e346bb96d4cd9e4355a3795ab8d Mon Sep 17 00:00:00 2001 From: bakebot Date: Wed, 31 Jan 2024 12:59:19 +0000 Subject: [PATCH 1/4] Cookie updated by NetworkToCode Cookie Drift Manager Tool Template: ``` { "template": "https://github.com/nautobot/cookiecutter-nautobot-app.git", "dir": "nautobot-app", "ref": "refs/tags/nautobot-app-v2.1.0", "path": null } ``` Cookie: ``` { "remote": "https://github.com/nautobot/nautobot-app-firewall-models.git", "path": "/tmp/tmpmx_rlxff/nautobot-app-firewall-models", "repository_path": "/tmp/tmpmx_rlxff/nautobot-app-firewall-models", "dir": "", "branch_prefix": "drift-manager", "context": { "codeowner_github_usernames": "@whitej6 @itdependsnetworks @jdrew82", "full_name": "Network to Code, LLC", "email": "opensource@networktocode.com", "github_org": "nautobot", "app_name": "nautobot_firewall_models", "verbose_name": "Nautobot Firewall Models", "app_slug": "nautobot-firewall-models", "project_slug": "nautobot-app-firewall-models", "repo_url": "https://github.com/nautobot/nautobot-app-firewall-models", "base_url": "firewall-models", "min_nautobot_version": "2.0.0", "max_nautobot_version": "2.9999", "camel_name": "NautobotFirewallModels", "project_short_description": "Nautobot App to model firewall and security objects. Allows users to model policies in a vendor-neutral manner and use that data to drive network security automation", "model_class_name": "None", "open_source_license": "Apache-2.0", "docs_base_url": "https://docs.nautobot.com", "docs_app_url": "https://docs.nautobot.com/projects/firewall-models/en/latest", "_template": "https://github.com/nautobot/cookiecutter-nautobot-app.git", "_output_dir": "/tmp/tmpmx_rlxff", "_repo_dir": "/github/home/.cookiecutters/cookiecutter-nautobot-app/nautobot-app", "_checkout": "refs/tags/nautobot-app-v2.1.0" }, "base_branch": "develop", "remote_name": "origin", "pull_request_strategy": "PullRequestStrategy.CREATE", "post_actions": [ "PostAction.BLACK" ], "baked_commit_ref": "a6caf43d118d9da2655c6ac1244daf455e3f86bf", "draft": true } ``` CLI Arguments: ``` { "cookie_dir": "", "input": false, "json_filename": "", "output_dir": "", "push": true, "template": "", "template_dir": "", "template_ref": "refs/tags/nautobot-app-v2.1.0", "pull_request": null, "post_action": [], "disable_post_actions": false, "draft": null } ``` --- .cookiecutter.json | 4 +- .github/workflows/ci.yml | 43 ++++++++++++- .github/workflows/rebake.yml | 118 ----------------------------------- pyproject.toml | 31 ++++++--- 4 files changed, 64 insertions(+), 132 deletions(-) delete mode 100644 .github/workflows/rebake.yml diff --git a/.cookiecutter.json b/.cookiecutter.json index 37423e8b..531928a8 100644 --- a/.cookiecutter.json +++ b/.cookiecutter.json @@ -21,7 +21,7 @@ "_drift_manager": { "template": "https://github.com/nautobot/cookiecutter-nautobot-app.git", "template_dir": "nautobot-app", - "template_ref": "develop", + "template_ref": "refs/tags/nautobot-app-v2.1.0", "cookie_dir": "", "branch_prefix": "drift-manager", "pull_request_strategy": "create", @@ -29,7 +29,7 @@ "black" ], "draft": true, - "baked_commit_ref": "a6caf43d118d9da2655c6ac1244daf455e3f86bf" + "baked_commit_ref": "65a757a27f903f10bdaa73fabbf623b397551910" } } } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64a85974..993c2c7d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -136,8 +136,47 @@ jobs: run: "cp development/creds.example.env development/creds.env" - name: "Linting: pylint" run: "poetry run invoke pylint" - - name: "Checking: App Config" - run: "poetry run invoke validate-app-config" + check-migrations: + needs: + - "bandit" + - "ruff" + - "flake8" + - "poetry" + - "yamllint" + - "black" + runs-on: "ubuntu-22.04" + strategy: + fail-fast: true + matrix: + python-version: ["3.11"] + nautobot-version: ["2.0.0"] + env: + INVOKE_NAUTOBOT_FIREWALL_MODELS_PYTHON_VER: "${{ matrix.python-version }}" + INVOKE_NAUTOBOT_FIREWALL_MODELS_NAUTOBOT_VER: "${{ matrix.nautobot-version }}" + steps: + - name: "Check out repository code" + uses: "actions/checkout@v4" + - name: "Setup environment" + uses: "networktocode/gh-action-setup-poetry-environment@v4" + - name: "Set up Docker Buildx" + id: "buildx" + uses: "docker/setup-buildx-action@v3" + - name: "Build" + uses: "docker/build-push-action@v5" + with: + builder: "${{ steps.buildx.outputs.name }}" + context: "./" + push: false + load: true + tags: "${{ env.APP_NAME }}/nautobot:${{ matrix.nautobot-version }}-py${{ matrix.python-version }}" + file: "./development/Dockerfile" + cache-from: "type=gha,scope=${{ matrix.nautobot-version }}-py${{ matrix.python-version }}" + cache-to: "type=gha,scope=${{ matrix.nautobot-version }}-py${{ matrix.python-version }}" + build-args: | + NAUTOBOT_VER=${{ matrix.nautobot-version }} + PYTHON_VER=${{ matrix.python-version }} + - name: "Copy credentials" + run: "cp development/creds.example.env development/creds.env" - name: "Checking: migrations" run: "poetry run invoke check-migrations" unittest: diff --git a/.github/workflows/rebake.yml b/.github/workflows/rebake.yml deleted file mode 100644 index 13d1e3a0..00000000 --- a/.github/workflows/rebake.yml +++ /dev/null @@ -1,118 +0,0 @@ ---- -name: "Rebake Cookie" -on: # yamllint disable-line rule:truthy - workflow_call: - inputs: - cookie: - description: "The cookie to rebake" - type: "string" - default: "" - draft: - description: "Whether to create the pull request as a draft" - type: "string" - default: "" - pull-request: - description: "The pull request strategy" - type: "string" - default: "" - template: - description: "The template repository URL" - type: "string" - default: "" - template-dir: - description: "The directory within the template repository to use as the template" - type: "string" - default: "" - template-ref: - description: "The branch or tag to use for the template" - type: "string" - default: "" - drift-manager-tag: - description: "The drift manager Docker image tag to use" - type: "string" - default: "latest" - workflow_dispatch: - inputs: - cookie: - description: "The cookie to rebake" - type: "string" - default: "" - draft: - description: "Whether to create the pull request as a draft" - type: "string" - default: "" - pull-request: - description: "The pull request strategy" - type: "string" - default: "" - template: - description: "The template repository URL" - type: "string" - default: "" - template-dir: - description: "The directory within the template repository to use as the template" - type: "string" - default: "" - template-ref: - description: "The branch or tag to use for the template" - type: "string" - default: "" - drift-manager-tag: - description: "The drift manager Docker image tag to use" - type: "string" - default: "latest" -jobs: - rebake: - runs-on: "ubuntu-22.04" - permissions: - actions: "write" - contents: "write" - packages: "read" - pull-requests: "write" - container: "ghcr.io/nautobot/cookiecutter-nautobot-app-drift-manager/prod:${{ github.event.inputs.drift-manager-tag }}" - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - steps: - - name: "Configure Rebake Arguments" - id: "config" - shell: "bash" - run: | - ARGS='--push' - - if [[ '${{ github.event.inputs.draft }}' == 'true' ]]; then - ARGS="$ARGS --draft" - elif [[ '${{ github.event.inputs.draft }}' == 'false' ]]; then - ARGS="$ARGS --no-draft" - elif [[ '${{ github.event.inputs.draft }}' == '' ]]; then - echo "Using repo default value for --draft" - else - echo "ERROR: Invalid value for draft: '${{ github.event.inputs.draft }}'" - exit 1 - fi - - if [[ '${{ github.event.inputs.pull-request }}' != '' ]]; then - ARGS="$ARGS --pull-request='${{ github.event.inputs.pull-request }}'" - fi - - if [[ '${{ github.event.inputs.template }}' != '' ]]; then - ARGS="$ARGS --template='${{ github.event.inputs.template }}'" - fi - - if [[ '${{ github.event.inputs.template-dir }}' != '' ]]; then - ARGS="$ARGS --template-dir='${{ github.event.inputs.template-dir }}'" - fi - - if [[ '${{ github.event.inputs.template-ref }}' != '' ]]; then - ARGS="$ARGS --template-ref='${{ github.event.inputs.template-ref }}'" - fi - - if [[ '${{ github.event.inputs.cookie }}' == '' ]]; then - ARGS="$ARGS '${{ github.repositoryUrl }}'" - else - ARGS="$ARGS '${{ github.event.inputs.cookie }}'" - fi - - echo "args=$ARGS" >> $GITHUB_OUTPUT - - name: "Rebake" - run: | - python -m ntc_cookie_drift_manager rebake ${{ steps.config.outputs.args }} diff --git a/pyproject.toml b/pyproject.toml index f8c02659..c31b348f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,6 +20,10 @@ classifiers = [ packages = [ { include = "nautobot_firewall_models" }, ] +include = [ + # Poetry by default will exclude files that are in .gitignore + "nautobot_firewall_models/static/nautobot_firewall_models/docs/**/*", +] [tool.poetry.dependencies] python = ">=3.8,<3.12" @@ -39,7 +43,7 @@ ipython = "*" pylint = "*" pylint-django = "*" pylint-nautobot = "*" -ruff = "~0.1.10" +ruff = "*" yamllint = "*" toml = "*" Markdown = "*" @@ -116,16 +120,10 @@ supported_nautobot_versions = [ [tool.ruff] line-length = 120 target-version = "py38" -exclude = [ - "migrations", -] [tool.ruff.lint] select = [ - "D1", # pydocstyle - "D2", # pydocstyle - "D3", # pydocstyle - "D4", # pydocstyle + "D", # pydocstyle ] ignore = [ # warning: `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible. @@ -141,6 +139,19 @@ ignore = [ # Produces a lot of issues in the current codebase. "D401", # First line of docstring should be in imperative mood + "D407", # Missing dashed underline after section + "D416", # Section name ends in colon +] + +[tool.ruff.lint.pydocstyle] +convention = "google" + +[tool.ruff.per-file-ignores] +"nautobot_firewall_models/migrations/*" = [ + "D", # pydocstyle +] +"nautobot_firewall_models/tests/*" = [ + "D", # pydocstyle ] [build-system] @@ -150,10 +161,10 @@ build-backend = "poetry.core.masonry.api" [tool.towncrier] package = "nautobot" directory = "changes" -filename = "docs/admin/release_notes/version_2.1.md" +filename = "docs/admin/release_notes/version_X.Y.md" template = "development/towncrier_template.j2" start_string = "" -issue_format = "[#{issue}](https://github.com/nautobot/nautobot/issues/{issue})" +issue_format = "[#{issue}](https://github.com/nautobot/nautobot-app-firewall-models/issues/{issue})" [[tool.towncrier.type]] directory = "security" From 52799aacca727434d30216381292791bed1d13ee Mon Sep 17 00:00:00 2001 From: Jan Snasel Date: Wed, 31 Jan 2024 13:37:20 +0000 Subject: [PATCH 2/4] chore: Manual fixes --- .github/workflows/ci.yml | 43 ++-------------------------------------- 1 file changed, 2 insertions(+), 41 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 993c2c7d..64a85974 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -136,47 +136,8 @@ jobs: run: "cp development/creds.example.env development/creds.env" - name: "Linting: pylint" run: "poetry run invoke pylint" - check-migrations: - needs: - - "bandit" - - "ruff" - - "flake8" - - "poetry" - - "yamllint" - - "black" - runs-on: "ubuntu-22.04" - strategy: - fail-fast: true - matrix: - python-version: ["3.11"] - nautobot-version: ["2.0.0"] - env: - INVOKE_NAUTOBOT_FIREWALL_MODELS_PYTHON_VER: "${{ matrix.python-version }}" - INVOKE_NAUTOBOT_FIREWALL_MODELS_NAUTOBOT_VER: "${{ matrix.nautobot-version }}" - steps: - - name: "Check out repository code" - uses: "actions/checkout@v4" - - name: "Setup environment" - uses: "networktocode/gh-action-setup-poetry-environment@v4" - - name: "Set up Docker Buildx" - id: "buildx" - uses: "docker/setup-buildx-action@v3" - - name: "Build" - uses: "docker/build-push-action@v5" - with: - builder: "${{ steps.buildx.outputs.name }}" - context: "./" - push: false - load: true - tags: "${{ env.APP_NAME }}/nautobot:${{ matrix.nautobot-version }}-py${{ matrix.python-version }}" - file: "./development/Dockerfile" - cache-from: "type=gha,scope=${{ matrix.nautobot-version }}-py${{ matrix.python-version }}" - cache-to: "type=gha,scope=${{ matrix.nautobot-version }}-py${{ matrix.python-version }}" - build-args: | - NAUTOBOT_VER=${{ matrix.nautobot-version }} - PYTHON_VER=${{ matrix.python-version }} - - name: "Copy credentials" - run: "cp development/creds.example.env development/creds.env" + - name: "Checking: App Config" + run: "poetry run invoke validate-app-config" - name: "Checking: migrations" run: "poetry run invoke check-migrations" unittest: From 9661af4458db49731f5349a8081b8aae1240c841 Mon Sep 17 00:00:00 2001 From: Jan Snasel Date: Wed, 31 Jan 2024 13:41:09 +0000 Subject: [PATCH 3/4] chore: Poetry lock --- poetry.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index b6c31590..73d09ec0 100644 --- a/poetry.lock +++ b/poetry.lock @@ -3508,4 +3508,4 @@ all = [] [metadata] lock-version = "2.0" python-versions = ">=3.8,<3.12" -content-hash = "dd2d6d0e9a99224eebe95efed1cfcb9d3f99b033615164523abcafd0ac6955d8" +content-hash = "2556ccc74ba2190be8368061393473586299f54e8594ff6993d48d5896e6d1e2" From 4933c06598b64a55185192f4be45b034f39fbeaa Mon Sep 17 00:00:00 2001 From: Jan Snasel Date: Wed, 31 Jan 2024 13:42:55 +0000 Subject: [PATCH 4/4] chore: Changelog fragment --- changes/218.housekeeping | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/218.housekeeping diff --git a/changes/218.housekeeping b/changes/218.housekeeping new file mode 100644 index 00000000..190989d8 --- /dev/null +++ b/changes/218.housekeeping @@ -0,0 +1 @@ +Rebaked using `nautobot-app-v2.1.0` cookiecutter template tag.