Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

release: v1.2.0 #126

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
# E501: Line length is enforced by Black, so flake8 doesn't need to check it
# W503: Black disagrees with this rule, as does PEP 8; Black wins
ignore = E501, W503
exclude =
.venv
exclude =
migrations,
__pycache__,
manage.py,
settings.py,
.venv
142 changes: 71 additions & 71 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
---
name: "CI"
on: # yamllint disable-line rule:truthy rule:comments
- "push"
- "pull_request"
concurrency: # Cancel any existing runs of this workflow for this same PR
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
on: # yamllint disable-line rule:truthy rule:comments
push:
branches:
- "main"
- "develop"
tags:
- "v*"
pull_request: ~

env:
PLUGIN_NAME: "nautobot-plugin-chatops-panorama"
Expand All @@ -16,7 +24,7 @@ jobs:
- name: "Check out repository code"
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v2"
uses: "networktocode/gh-action-setup-poetry-environment@v4"
- name: "Linting: black"
run: "poetry run invoke black"
bandit:
Expand All @@ -27,7 +35,7 @@ jobs:
- name: "Check out repository code"
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v2"
uses: "networktocode/gh-action-setup-poetry-environment@v4"
- name: "Linting: bandit"
run: "poetry run invoke bandit"
pydocstyle:
Expand All @@ -38,7 +46,7 @@ jobs:
- name: "Check out repository code"
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v2"
uses: "networktocode/gh-action-setup-poetry-environment@v4"
- name: "Linting: pydocstyle"
run: "poetry run invoke pydocstyle"
flake8:
Expand All @@ -49,7 +57,7 @@ jobs:
- name: "Check out repository code"
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v2"
uses: "networktocode/gh-action-setup-poetry-environment@v4"
- name: "Linting: flake8"
run: "poetry run invoke flake8"
yamllint:
Expand All @@ -60,7 +68,7 @@ jobs:
- name: "Check out repository code"
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v2"
uses: "networktocode/gh-action-setup-poetry-environment@v4"
- name: "Linting: yamllint"
run: "poetry run invoke yamllint"
pylint:
Expand All @@ -74,16 +82,16 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.9"]
nautobot-version: ["1.2.0"]
python-version: ["3.8"]
nautobot-version: ["1.4.0"]
env:
INVOKE_NAUTOBOT_PLUGIN_CHATOPS_PANORAMA_PYTHON_VER: "${{ matrix.python-version }}"
INVOKE_NAUTOBOT_PLUGIN_CHATOPS_PANORAMA_NAUTOBOT_VER: "${{ matrix.nautobot-version }}"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v2"
uses: "networktocode/gh-action-setup-poetry-environment@v4"
- name: "Set up Docker Buildx"
id: "buildx"
uses: "docker/setup-buildx-action@v1"
Expand Down Expand Up @@ -111,11 +119,19 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.7", "3.8", "3.9"]
# If mysql is needed, add the mysql DB to the list
# Make sure to include steps required to setup the mysql DB
python-version: ["3.7", "3.8", "3.9", "3.10"]
db-backend: ["postgresql"]
nautobot-version: ["1.2.0", "stable"]
nautobot-version: ["stable"]
include:
- python-version: "3.10"
db-backend: "postgresql"
nautobot-version: "1.4.0"
- python-version: "3.7"
db-backend: "mysql"
nautobot-version: "1.4.0"
- python-version: "3.10"
db-backend: "mysql"
nautobot-version: "stable"
runs-on: "ubuntu-20.04"
env:
INVOKE_NAUTOBOT_PLUGIN_CHATOPS_PANORAMA_PYTHON_VER: "${{ matrix.python-version }}"
Expand All @@ -124,7 +140,7 @@ jobs:
- name: "Check out repository code"
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v2"
uses: "networktocode/gh-action-setup-poetry-environment@v4"
- name: "Set up Docker Buildx"
id: "buildx"
uses: "docker/setup-buildx-action@v1"
Expand All @@ -144,21 +160,15 @@ jobs:
PYTHON_VER=${{ matrix.python-version }}
- name: "Copy credentials"
run: "cp development/creds.example.env development/creds.env"
- name: "Use Mysql invoke settings when needed"
run: "cp invoke.mysql.yml invoke.yml"
if: "matrix.db-backend == 'mysql'"
- name: "Run Tests"
run: "poetry run invoke unittest"
## If you want to publish your your python wheel and source
## code under the GitHub releases uncomment this job.
## This will run everytime you tag a commit with the 'v' prefix.
## Publishing will be done with the built-in token GITHUB_TOKEN.
## This token uses the same permissions as a user created a release.
## If you want to use GitHub PAT instead replace GITHUB_TOKEN with
## your custom token.
publish_gh:
needs:
- "unittest"
name: "Publish to GitHub"
permissions:
contents: "write"
runs-on: "ubuntu-20.04"
if: "startsWith(github.ref, 'refs/tags/v')"
steps:
Expand All @@ -179,15 +189,11 @@ jobs:
- name: "Upload binaries to release"
uses: "svenstaro/upload-release-action@v2"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
repo_token: "${{ secrets.NTC_GITHUB_TOKEN }}"
file: "dist/*"
tag: "${{ github.ref }}"
overwrite: true
file_glob: true
## If you want to publish your package on PyPI, uncooment this job.
## You need to add the PYPI_API_TOKEN under GitHub secrets (on a project
## level or on a organizational level).
## This will run everytime you tag a commit with the 'v' prefix.
publish_pypi:
needs:
- "unittest"
Expand All @@ -214,44 +220,38 @@ jobs:
with:
user: "__token__"
password: "${{ secrets.PYPI_API_TOKEN }}"
## If you want to set a notification to a Slack channel, uncomment this
## job. This job requires the SLACK_WEBHOOK_URL secret. Follow these
## steps to get the webhook URL:
## https://api.slack.com/messaging/webhooks
## Update the SLACK_MESSAGE variable if you want to customize the
## message.
# slack-notify:
# needs:
# - "publish_gh"
# - "publish_pypi"
# runs-on: "ubuntu-20.04"
# env:
# SLACK_WEBHOOK_URL: "${{ secrets.SLACK_WEBHOOK_URL }}"
# SLACK_MESSAGE: >-
# *NOTIFICATION: NEW-RELEASE-PUBLISHED*\n
# Repository: <${{ github.server_url }}/${{ github.repository }}|${{ github.repository }}>\n
# Release: <${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }}|${{ github.ref_name }}>\n
# Published by: <${{ github.server_url }}/${{ github.actor }}|${{ github.actor }}>
# steps:
# - name: "Send a notification to Slack"
# # ENVs cannot be used directly in job.if. This is a workaround to check
# # if SLACK_WEBHOOK_URL is present.
# if: "${{ env.SLACK_WEBHOOK_URL != '' }}"
# uses: "slackapi/[email protected]"
# with:
# payload: |
# {
# "text": "${{ env.SLACK_MESSAGE }}",
# "blocks": [
# {
# "type": "section",
# "text": {
# "type": "mrkdwn",
# "text": "${{ env.SLACK_MESSAGE }}"
# }
# }
# ]
# }
# env:
# SLACK_WEBHOOK_URL: "${{ secrets.SLACK_WEBHOOK_URL }}"
# SLACK_WEBHOOK_TYPE: "INCOMING_WEBHOOK"
slack-notify:
needs:
- "publish_gh"
- "publish_pypi"
runs-on: "ubuntu-20.04"
env:
SLACK_WEBHOOK_URL: "${{ secrets.SLACK_WEBHOOK_URL }}"
SLACK_MESSAGE: >-
*NOTIFICATION: NEW-RELEASE-PUBLISHED*\n
Repository: <${{ github.server_url }}/${{ github.repository }}|${{ github.repository }}>\n
Release: <${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }}|${{ github.ref_name }}>\n
Published by: <${{ github.server_url }}/${{ github.actor }}|${{ github.actor }}>
steps:
- name: "Send a notification to Slack"
# ENVs cannot be used directly in job.if. This is a workaround to check
# if SLACK_WEBHOOK_URL is present.
if: "env.SLACK_WEBHOOK_URL != ''"
uses: "slackapi/[email protected]"
with:
payload: |
{
"text": "${{ env.SLACK_MESSAGE }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${{ env.SLACK_MESSAGE }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: "${{ secrets.SLACK_WEBHOOK_URL }}"
SLACK_WEBHOOK_TYPE: "INCOMING_WEBHOOK"
13 changes: 13 additions & 0 deletions .github/workflows/upstream_testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: "Nautobot Upstream Monitor"

on: # yamllint disable-line rule:truthy rule:comments
schedule:
- cron: "0 4 */2 * *" # every other day at midnight

jobs:
upstream-test:
uses: "nautobot/nautobot/.github/workflows/plugin_upstream_testing_base.yml@develop"
with: # Below could potentially be collapsed into a single argument if a concrete relationship between both is enforced
invoke_context_name: "NAUTOBOT_PLUGIN_CHATOPS_PANORAMA"
plugin_name: "nautobot-plugin-chatops-panorama"
80 changes: 63 additions & 17 deletions development/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,78 @@
ARG NAUTOBOT_VER="1.2.0"
ARG PYTHON_VER=3.8
FROM ghcr.io/nautobot/nautobot-dev:${NAUTOBOT_VER}-py${PYTHON_VER}
# -------------------------------------------------------------------------------------
# Nautobot App Developement Dockerfile Template
# Version: 1.1.0
#
# Apps that need to add additional steps or packages can do in the section below.
# -------------------------------------------------------------------------------------
# !!! USE CAUTION WHEN MODIFYING LINES BELOW

ENV prometheus_multiproc_dir=/prom_cache
# Accepts a desired Nautobot version as build argument, default to 1.5
ARG NAUTOBOT_VER="1.4"

# Accepts a desired Python version as build argument, default to 3.8
ARG PYTHON_VER="3.8"

# Retrieve published development image of Nautobot base which should include most CI dependencies
FROM ghcr.io/nautobot/nautobot-dev:${NAUTOBOT_VER}-py${PYTHON_VER}

# Runtime argument and environment setup
ARG NAUTOBOT_ROOT=/opt/nautobot

ENV prometheus_multiproc_dir=/prom_cache
ENV NAUTOBOT_ROOT ${NAUTOBOT_ROOT}

WORKDIR $NAUTOBOT_ROOT
# Install Poetry manually via its installer script;
# We might be using an older version of Nautobot that includes an older version of Poetry
# and CI and local development may have a newer version of Poetry
# Since this is only used for development and we don't ship this container, pinning Poetry back is not expressly necessary
# We also don't need virtual environments in container
RUN curl -sSL https://install.python-poetry.org | python3 - && \
poetry config virtualenvs.create false

# Configure poetry
RUN poetry config virtualenvs.create false \
&& poetry config installer.parallel false
# !!! USE CAUTION WHEN MODIFYING LINES ABOVE
# -------------------------------------------------------------------------------------
# App-specifc system build/test dependencies.
#
# Example: LDAP requires `libldap2-dev` to be apt-installed before the Python package.
# -------------------------------------------------------------------------------------
# --> Start safe to modify section

# Uncomment the lines below if you are apt-installing any package.
# RUN apt-get -y update && apt-get -y install \
# libldap2-dev \
# && rm -rf /var/lib/apt/lists/*

# --> Stop safe to modify section
# -------------------------------------------------------------------------------------
# Install Nautobot Plugin
# Install Nautobot App
# -------------------------------------------------------------------------------------
# !!! USE CAUTION WHEN MODIFYING LINES BELOW

# Copy in the source code
WORKDIR /source
COPY . /source

# Copy in only pyproject.toml/poetry.lock to help with caching this layer if no updates to dependencies
COPY poetry.lock pyproject.toml /source/
# --no-root declares not to install the project package since we're wanting to take advantage of caching dependency installation
# and the project is copied in and installed after this step
RUN poetry install --no-interaction --no-ansi --no-root
# Get container's installed Nautobot version as a forced constraint
# NAUTOBOT_VER may be a branch name and not a published release therefor we need to get the installed version
# so pip can use it to recognize local constraints.
RUN pip show nautobot | grep "^Version: " | sed -e 's/Version: /nautobot==/' > constraints.txt

# Copy in the rest of the source code and install local Nautobot plugin
COPY . /source
RUN poetry install --no-interaction --no-ansi
# Use Poetry to grab dev dependencies from the lock file
# Can be improved in Poetry 1.2 which allows `poetry install --only dev`
#
# We can't use the entire freeze as it takes forever to resolve with rigidly fixed non-direct dependencies,
# especially those that are only direct to Nautobot but the container included versions slightly mismatch
RUN poetry export -f requirements.txt --without-hashes --output poetry_freeze_base.txt
RUN poetry export -f requirements.txt --with dev --without-hashes --output poetry_freeze_all.txt
RUN sort poetry_freeze_base.txt poetry_freeze_all.txt | uniq -u > poetry_freeze_dev.txt

# Install all local project as editable, constrained on Nautobot version, to get any additional
# direct dependencies of the app
RUN pip install -c constraints.txt -e .

# Install any dev dependencies frozen from Poetry
# Can be improved in Poetry 1.2 which allows `poetry install --only dev`
RUN pip install -c constraints.txt -r poetry_freeze_dev.txt

COPY development/nautobot_config.py ${NAUTOBOT_ROOT}/nautobot_config.py
# !!! USE CAUTION WHEN MODIFYING LINES ABOVE
8 changes: 8 additions & 0 deletions development/creds.example.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
################################################################################
# CREDS File: Store private information. Copied to creds.env and always ignored
################################################################################
# Nautobot Configuration Secret Items
NAUTOBOT_CREATE_SUPERUSER=true
NAUTOBOT_DB_PASSWORD=changeme
NAUTOBOT_NAPALM_USERNAME=''
Expand All @@ -13,6 +17,10 @@ NAUTOBOT_SUPERUSER_API_TOKEN=0123456789abcdef0123456789abcdef01234567
POSTGRES_PASSWORD=${NAUTOBOT_DB_PASSWORD}
PGPASSWORD=${NAUTOBOT_DB_PASSWORD}

# MySQL Credentials
MYSQL_ROOT_PASSWORD=${NAUTOBOT_DB_PASSWORD}
MYSQL_PASSWORD=${NAUTOBOT_DB_PASSWORD}

# Use these to override values in development.env
# NAUTOBOT_DB_HOST=localhost
# NAUTOBOT_REDIS_HOST=localhost
Expand Down
Loading