Skip to content
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
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"
62 changes: 41 additions & 21 deletions .github/workflows/oui_filepull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,59 @@ name: "OUI-Updates"
on: # yamllint disable-line rule:truthy
schedule:
- cron: "0 2 1 * *"
workflow_dispatch: {}

jobs:
data_gathering:
runs-on: "ubuntu-latest"
env:
BRANCH_NAME: "OUI_Updates"
steps:
# Checkout repo
- name: "Check out code"
uses: "actions/checkout@v4"
with:
ref: "develop"
# Delete old branch if it exists
fetch-depth: 0

- name: "Authenticate git remote"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"

- name: "Delete existing branch"
run: "git branch -D $BRANCH_NAME || true"
# Create branch for Flatbot
- name: "Create Flatbot branch"
run: "git checkout -b $BRANCH_NAME"
# Push new branch so Flatbot can make its commit
- name: "Push Flatbot branch"
run: "git push -f --set-upstream origin $BRANCH_NAME"
# This step installs Deno, which is a new Javascript runtime that improves on Node. Can be used for an optional postprocessing step
- name: "Setup deno"
uses: "denoland/setup-deno@main"
with:
deno-version: "v1.10.x"
# The Flat Action step. We fetch the data in the http_url and save it as downloaded_filename
- name: "Fetch data"
uses: "githubocto/flat@v3"
with:
http_url: "https://standards-oui.ieee.org"
downloaded_filename: "./netutils/data_files/oui_mappings.py"
postprocess: "./flat_postprocess/oui_postprocess.ts"
run: |
git branch -D "$BRANCH_NAME" || true

- name: "Create branch"
run: |
git checkout -b "$BRANCH_NAME"

- name: "Push branch"
run: |
git push -f --set-upstream origin "$BRANCH_NAME"

# Fetch data via curl as IEEE has blocked requests/urllib library requests
- name: "Download IEEE OUI data"
run: |
curl -fsSL "https://standards-oui.ieee.org/oui/oui.csv" \
-o "./netutils/data_files/oui_mappings.py"

- name: "Generate oui_mappings.py"
run: "python ./flat_postprocess/oui_postprocess.py ./netutils/data_files/oui_mappings.py"

- name: "Commit changes"
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

git add ./netutils/data_files/oui_mappings.py
git diff --cached --quiet || git commit -m "Update OUI mappings"

- name: "Push changes"
run: |
git push origin "$BRANCH_NAME"

pr_creation:
runs-on: "ubuntu-latest"
needs: "data_gathering"
Expand Down
Loading