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 @@ -10,20 +10,21 @@
"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",
"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": "b23a9ed5a4714810d83670ad47cc182764c6d464",
"drift_managed_branch": "develop"
}
}
}
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
124 changes: 11 additions & 113 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,17 +97,19 @@ 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 }}"
INVOKE_NETUTILS_PYTHON_VER: "${{ matrix.python-version }}"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
Expand All @@ -138,19 +134,19 @@ jobs:
cache-from: "type=gha,scope=${{ env.INVOKE_NETUTILS_IMAGE_NAME }}-${{ env.INVOKE_NETUTILS_IMAGE_VER }}-py${{ matrix.python-version }}"
cache-to: "type=gha,scope=${{ env.INVOKE_NETUTILS_IMAGE_NAME }}-${{ env.INVOKE_NETUTILS_IMAGE_VER }}-py${{ matrix.python-version }}"
build-args: |
PYTHON_VER=${{ env.PYTHON_VER }}
PYTHON_VER=${{ matrix.python-version }}
- 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 }}"
INVOKE_NETUTILS_PYTHON_VER: "${{ matrix.python-version }}"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
Expand All @@ -175,11 +171,9 @@ jobs:
cache-from: "type=gha,scope=${{ env.INVOKE_NETUTILS_IMAGE_NAME }}-${{ env.INVOKE_NETUTILS_IMAGE_VER }}-py${{ matrix.python-version }}"
cache-to: "type=gha,scope=${{ env.INVOKE_NETUTILS_IMAGE_NAME }}-${{ env.INVOKE_NETUTILS_IMAGE_VER }}-py${{ matrix.python-version }}"
build-args: |
PYTHON_VER=${{ env.PYTHON_VER }}
PYTHON_VER=${{ matrix.python-version }}
- 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: "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"
# Steps to publish to PyPI.
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
## Used for networktocode org since trusted publisher isn't supported for GitHub Plan.
with:
user: "__token__"
password: "${{ secrets.PYPI_API_TOKEN }}"
# End publish to PyPI job.

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
1 change: 1 addition & 0 deletions changes/+drift-cb8b5e.housekeeping
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Run drift manager to get app updated with NTC standards.
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
Loading
Loading