Skip to content
Open
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
9 changes: 5 additions & 4 deletions .cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@
"cookiecutter": {
"codeowner_github_usernames": "@itdependsnetworks @jeffkala @qduk",
"full_name": "Network to Code, LLC",
"email": "info@networktocode.com",
"email": "opensource@networktocode.com",
"github_org": "networktocode",
"description": "Common helper functions useful in network automation.",
"project_name": "netutils",
"project_slug": "netutils",
"repo_url": "https://github.com/networktocode/netutils",
"base_url": "netutils",
"project_python_name": "netutils",
"project_python_base_version": "3.9",
"project_python_base_version": "3.10",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't hold up.. but i am still of the opinion, we should be using the latest by default, and CI should run the oldest. There are some idiosyncrasies, like I think ruff says to use the oldest version in the config.. but that is just the config.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I'll look again but this specific variable is for the min python version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, but the Dockerfile is using is, e.g.

ARG PYTHON_VER="3.10"

also, where is the max defined?

"project_with_config_settings": "no",
"generate_docs": "yes",
"version": "1.15.1",
"original_publish_year": "2021",
"_drift_manager": {
"template": "https://github.com/networktocode-llc/cookiecutter-ntc.git",
"template_dir": "python",
"template_ref": "main",
"cookie_dir": "",
"branch_prefix": "drift-manager",
"pull_request_strategy": "create",
"pull_request_strategy": "update-or-create",
"post_actions": [],
"draft": false,
"baked_commit_ref": "cb8b5e31dece5ab2663d2ffd218a96ca1ae794c5"
"baked_commit_ref": "6e903d3c14d2fd9a9e73ac9725d2eb2efdc315e7"
}
}
}
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ about: Report a reproducible bug in the current release of netutils
---

### Environment
* Python version: <!-- Example: 3.9 -->
* Python version: <!-- Example: 3.10 -->
* netutils version: <!-- Example: 1.0.0 -->

<!-- What did you expect to happen? -->
Expand Down
116 changes: 7 additions & 109 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ on: # yamllint disable-line rule:truthy rule:comments
branches:
- "main"
- "develop"
tags:
- "v*"
pull_request: ~

env:
Expand Down Expand Up @@ -86,10 +84,6 @@ jobs:
poetry-version: "2.1.3"
- name: "Checking: poetry lock file"
run: "poetry run invoke lock --check"
needs:
- "ruff-format"
- "ruff-lint"
- "yamllint"
yamllint:
runs-on: "ubuntu-latest"
env:
Expand All @@ -103,15 +97,17 @@ jobs:
poetry-version: "2.1.3"
- name: "Linting: yamllint"
run: "poetry run invoke yamllint"
check-in-docker:
needs:
- "ruff-format"
- "ruff-lint"
pylint:
- "poetry"
- "yamllint"
runs-on: "ubuntu-latest"
strategy:
fail-fast: true
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.13"]
env:
PYTHON_VER: "${{ matrix.python-version }}"
steps:
Expand Down Expand Up @@ -141,13 +137,13 @@ jobs:
PYTHON_VER=${{ env.PYTHON_VER }}
- name: "Linting: Pylint"
run: "poetry run invoke pylint"
needs:
- "poetry"
pytest:
needs:
- "check-in-docker"
strategy:
fail-fast: true
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
runs-on: "ubuntu-latest"
env:
PYTHON_VER: "${{ matrix.python-version }}"
Expand Down Expand Up @@ -178,8 +174,6 @@ jobs:
PYTHON_VER=${{ env.PYTHON_VER }}
- name: "Run Tests"
run: "poetry run invoke pytest"
needs:
- "poetry"
changelog:
if: >
contains(fromJson('["develop"]'), github.base_ref) &&
Expand All @@ -198,99 +192,3 @@ jobs:
run: |
git fetch --no-tags origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
poetry run towncrier check --compare-with origin/${{ github.base_ref }}
publish_gh:
name: "Publish to GitHub"
runs-on: "ubuntu-latest"
# yamllint disable-line rule:quoted-strings
if: startsWith(github.ref, 'refs/tags/v')
env:
INVOKE_NETUTILS_LOCAL: "True"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "2.1.3"
python-version: "3.12"
poetry-install-options: "--no-root"
- name: "Set env"
run: "echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV"
- name: "Run Poetry Version"
run: "poetry version $RELEASE_VERSION"
- name: "Build Documentation"
run: "poetry run invoke build-and-check-docs"
- name: "Run Poetry Build"
run: "poetry build"
- name: "Upload binaries to release"
run: "gh release upload ${{ github.ref_name }} dist/*.{tar.gz,whl}"
env:
GH_TOKEN: "${{ secrets.NTC_GITHUB_TOKEN }}"
needs:
- "pytest"
publish_pypi:
name: "Push Package to PyPI"
runs-on: "ubuntu-latest"
# yamllint disable-line rule:quoted-strings
if: startsWith(github.ref, 'refs/tags/v')
env:
INVOKE_NETUTILS_LOCAL: "True"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "2.1.3"
- name: "Set env"
run: "echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV"
- name: "Run Poetry Version"
run: "poetry version $RELEASE_VERSION"
- name: "Install Dependencies (needed for mkdocs)"
run: "poetry install --no-root"
- name: "Build Documentation"
run: "poetry run invoke build-and-check-docs"
- name: "Run Poetry Build"
run: "poetry build"
- name: "Push to PyPI"
uses: "pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc" # v1.12.4
with:
user: "__token__"
password: "${{ secrets.PYPI_API_TOKEN }}"
needs:
- "pytest"
slack-notify:
needs:
- "publish_gh"
- "publish_pypi"
runs-on: "ubuntu-latest"
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/slack-github-action@fcfb566f8b0aab22203f066d80ca1d7e4b5d05b3" # v1.27.1
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"
106 changes: 106 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---
name: "Release"
on: # yamllint disable-line rule:truthy rule:comments
release:
types: ["published"]

jobs:
build:
name: "Build package with poetry"
runs-on: "ubuntu-latest"
if: "startsWith(github.ref, 'refs/tags/v')"
steps:
- uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "2.1.3"
python-version: "3.13"
poetry-install-options: "--no-root"
- name: "Build Documentation"
run: "poetry run invoke build-and-check-docs"
- name: "Run Poetry Build"
run: "poetry build"

- name: "Check that the release tag matches the version in pyproject.toml"
run: |
if [ "${{ github.ref_name }}" != "v$(poetry version -s)" ]; then exit 1; fi

- uses: "actions/upload-artifact@v4"
with:
name: "distfiles"
path: "dist/"
if-no-files-found: "error"

publish-github:
name: "Publish to GitHub"
runs-on: "ubuntu-latest"
if: "startsWith(github.ref, 'refs/tags/v')"
permissions:
contents: "write"
needs: "build"
steps:
- uses: "actions/checkout@v4"
- name: "Retrieve built package from cache"
uses: "actions/download-artifact@v4"
with:
name: "distfiles"
path: "dist/"

- name: "Upload binaries to release"
run: "gh release upload ${{ github.ref_name }} dist/*.{tar.gz,whl}"
env:
GH_TOKEN: "${{ secrets.NTC_GITHUB_TOKEN }}"

publish-pypi:
name: "Push Package to PyPI"
runs-on: "ubuntu-latest"
if: "startsWith(github.ref, 'refs/tags/v')"
needs: "build"
environment: "pypi"
permissions:
# IMPORTANT: this permission is mandatory for Trusted Publishing
id-token: "write"
steps:
- name: "Retrieve built package from cache"
uses: "actions/download-artifact@v4"
with:
name: "distfiles"
path: "dist/"

- name: "Publish package distributions to PyPI"
uses: "pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e" # v1.13.0

slack-notify:
needs:
- "publish-github"
- "publish-pypi"
runs-on: "ubuntu-latest"
env:
# Secrets cannot be directly referenced in if: conditionals. They must be set as a job env var first.
# Ref: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#example-using-secrets
SLACK_WEBHOOK_URL: "${{ secrets.OSS_PYPI_SLACK_WEBHOOK_URL }}"
SLACK_WEBHOOK_TYPE: "INCOMING_WEBHOOK"
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"
if: "${{ env.SLACK_WEBHOOK_URL != '' }}"
uses: "slackapi/slack-github-action@fcfb566f8b0aab22203f066d80ca1d7e4b5d05b3" # v1.27.1
with:
payload: |
{
"text": "${{ env.SLACK_MESSAGE }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${{ env.SLACK_MESSAGE }}"
}
}
]
}
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ version: 2
build:
os: "ubuntu-lts-latest"
tools:
python: "3.12"
python: "3.13"
jobs:
post_install:
# Install poetry
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PYTHON_VER="3.9"
ARG PYTHON_VER="3.10"

FROM python:${PYTHON_VER}-slim

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<img src="https://raw.githubusercontent.com/networktocode/netutils/develop/docs/images/icon-Netutils.png" class="logo" height="200px">
<br>
<a href="https://github.com/networktocode/netutils/actions"><img src="https://github.com/networktocode/netutils/actions/workflows/ci.yml/badge.svg?branch=main"></a>
<a href="https://netutils.readthedocs.io/en/latest"><img src="https://readthedocs.org/projects/netutils/badge/"></a>
<a href="https://netutils.readthedocs.io/en/latest/"><img src="https://readthedocs.org/projects/netutils/badge/"></a>
<a href="https://pypi.org/project/netutils/"><img src="https://img.shields.io/pypi/v/netutils"></a>
<a href="https://pypi.org/project/netutils/"><img src="https://img.shields.io/pypi/dm/netutils"></a>
<br>
Expand All @@ -16,19 +16,19 @@ A Python library that is a collection of functions that are used in the common n

## Documentation

Full web-based HTML documentation for this library can be found over on the [Netutils Docs](https://netutils.readthedocs.io) website:
Full documentation for this library can be found over on the [Netutils Docs](https://netutils.readthedocs.io/) website:

- [User Guide](https://netutils.readthedocs.io/en/latest/user/lib_overview/) - Overview, Using the library, Getting Started.
- [Administrator Guide](https://netutils.readthedocs.io/en/latest/admin/install/) - How to Install, Configure, Upgrade, or Uninstall the library.
- [Developer Guide](https://netutils.readthedocs.io/en/latest/dev/contributing/) - Extending the library, Code Reference, Contribution Guide.
- [Release Notes / Changelog](https://netutils.readthedocs.io/en/latest/admin/release_notes/).
- [Frequently Asked Questions](https://netutils.readthedocs.io/en/latest/user/faq/).

### Contributing to the Docs
### Contributing to the Documentation

All the Markdown source for the library documentation can be found under the [docs](https://github.com/networktocode/netutils/tree/develop/docs) folder in this repository. For simple edits, a Markdown capable editor is sufficient - clone the repository and edit away.
You can find all the Markdown source for the library documentation under the [`docs`](https://github.com/networktocode/netutils/tree/develop/docs) folder in this repository. For simple edits, a Markdown capable editor is sufficient: clone the repository and edit away.

If you need to view the fully generated documentation site, you can build it with [mkdocs](https://www.mkdocs.org/). A container hosting the docs will be started using the invoke commands (details in the [Development Environment Guide](https://netutils.readthedocs.io/en/latest/dev/dev_environment/#docker-development-environment)) on [http://localhost:8001](http://localhost:8001). As your changes are saved, the live docs will be automatically reloaded.
If you need to view the fully-generated documentation site, you can build it with [MkDocs](https://www.mkdocs.org/). A container hosting the documentation can be started using the `invoke` commands (details in the [Development Environment Guide](https://netutils/dev/dev_environment/#docker-development-environment)) on [http://localhost:8001](http://localhost:8001). Using this container, as your changes to the documentation are saved, they will be automatically rebuilt and any pages currently being viewed will be reloaded in your browser.

Any PRs with fixes or improvements are very welcome!

Expand Down
1 change: 1 addition & 0 deletions changes/+mainv2.housekeeping
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rebaked from the cookie `main`.
Empty file removed changes/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion docs/dev/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ The branching policy includes the following tenets:
- PRs intended to address bug fixes and security patches should be sourced from the develop branch.
- PRs intended to add new features that break backward compatibility should be discussed before a PR is created.

Netutils will observe semantic versioning, as of 1.0. This may result in an quick turn around in minor versions to keep pace with an ever growing feature set.
Netutils will observe Semantic Versioning, as of 1.0. This may result in an quick turn around in minor versions to keep pace with an ever growing feature set.

## Release Policy

Expand Down
2 changes: 1 addition & 1 deletion example.invoke.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
"netutils":
python_ver: "3.9"
python_ver: "3.10"
local: false
# image_name: "netutils"
# image_ver: "latest"
Expand Down
3 changes: 3 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ plugins:
- "netutils.config.parser"
classy_libraries:
- "netutils"
- "glightbox":
manual: true # See https://blueswen.github.io/mkdocs-glightbox/flexibility/enable-by-image-or-page/
- "section-index"
- "mkdocstrings":
default_handler: "python"
handlers:
Expand Down
Loading