Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion .cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"pull_request_strategy": "update-or-create",
"post_actions": [],
"draft": false,
"baked_commit_ref": "b23a9ed5a4714810d83670ad47cc182764c6d464",
"baked_commit_ref": "46f70d30baa1e0c5af3da3fdcf1c77b31157d3f9",
"drift_managed_branch": "develop"
}
}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: "Release"
on: # yamllint disable-line rule:truthy rule:comments
on: # yamllint disable-line rule:truthy rule:comments
release:
types: ["published"]

Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
- name: "Upload binaries to release"
run: "gh release upload ${{ github.ref_name }} dist/*.{tar.gz,whl}"
env:
GH_TOKEN: "${{ secrets.NTC_GITHUB_TOKEN }}"
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

publish-pypi:
name: "Push Package to PyPI"
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Apache Software License 2.0

Copyright (c) 2021-2025, Network to Code, LLC
Copyright (c) 2021-2026, Network to Code, LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
1 change: 1 addition & 0 deletions changes/+main.housekeeping
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rebaked from the cookie `main`.
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
29 changes: 25 additions & 4 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def is_truthy(arg):
"python_ver": "3.10",
"local": is_truthy(os.getenv("INVOKE_NETUTILS_LOCAL", "false")),
"image_name": "netutils",
"image_ver": os.getenv("INVOKE_PARSER_IMAGE_VER", "latest"),
"image_ver": os.getenv("INVOKE_NETUTILS_IMAGE_VER", "latest"),
"pwd": Path(__file__).parent,
}
}
Expand All @@ -66,13 +66,14 @@ def task_wrapper(function=None):
return task_wrapper


def run_command(context, exec_cmd, port=None):
def run_command(context, exec_cmd, port=None, rm=True):
"""Wrapper to run the invoke task commands.

Args:
context ([invoke.task]): Invoke task object.
exec_cmd ([str]): Command to run.
port (int): Used to serve local docs.
rm (bool): Whether to remove the container after running the command.

Returns:
result (obj): Contains Invoke result from running task.
Expand All @@ -86,12 +87,12 @@ def run_command(context, exec_cmd, port=None):
)
if port:
result = context.run(
f"docker run -it -p {port} -v {context.netutils.pwd}:/local {context.netutils.image_name}:{context.netutils.image_ver} sh -c '{exec_cmd}'",
f"docker run -it {'--rm' if rm else ''} -p {port} -v {context.netutils.pwd}:/local {context.netutils.image_name}:{context.netutils.image_ver} sh -c '{exec_cmd}'",
pty=True,
)
else:
result = context.run(
f"docker run -it -v {context.netutils.pwd}:/local {context.netutils.image_name}:{context.netutils.image_ver} sh -c '{exec_cmd}'",
f"docker run -it {'--rm' if rm else ''} -v {context.netutils.pwd}:/local {context.netutils.image_name}:{context.netutils.image_ver} sh -c '{exec_cmd}'",
pty=True,
)

Expand Down Expand Up @@ -188,6 +189,26 @@ def pytest(context, pattern=None, label=None):
exec_cmd = " && ".join([doc_test_cmd, pytest_cmd, coverage_cmd])
run_command(context, exec_cmd)

doc_test_cmd = "pytest -vv --doctest-modules netutils/"
pytest_cmd = "coverage run --source=netutils -m pytest"
if pattern:
pytest_cmd += "".join([f" -k {_pattern}" for _pattern in pattern])
if label:
pytest_cmd += "".join([f" {_label}" for _label in label])
coverage_cmd = "coverage report"
exec_cmd = " && ".join([doc_test_cmd, pytest_cmd, coverage_cmd])
run_command(context, exec_cmd)

doc_test_cmd = "pytest -vv --doctest-modules netutils/"
pytest_cmd = "coverage run --source=netutils -m pytest"
if pattern:
pytest_cmd += "".join([f" -k {_pattern}" for _pattern in pattern])
if label:
pytest_cmd += "".join([f" {_label}" for _label in label])
coverage_cmd = "coverage report"
exec_cmd = " && ".join([doc_test_cmd, pytest_cmd, coverage_cmd])
run_command(context, exec_cmd)


@task(aliases=("a",))
def autoformat(context):
Expand Down