Skip to content

Commit 9f24d42

Browse files
committed
feat: comprehensive improvements to code, documentation, and testing
BREAKING CHANGES: - Converted to proper Python package structure with __init__.py - Entry point now uses hier_config_cli:cli instead of module path Added Features: - Support for Fortinet FortiOS platform - Output format options (text, json, yaml) with --format flag - File output support with --output/-o flag - list-platforms command to show all available platforms - version command to display tool version - Comprehensive error handling for file operations and validation - Verbose logging with -v (INFO) and -vv (DEBUG) flags - Complete type hints throughout codebase Code Improvements: - Refactored duplicate code into shared process_configs() function - Fixed platform-specific output formatting (no longer hardcodes cisco_style_text()) - Improved error messages to be more descriptive and actionable - Added proper docstrings following Google style - Resolved unused PyYAML dependency (now used for YAML output) Testing: - 20+ comprehensive test cases including: - Error handling tests - All platform tests - Output format tests (text, JSON, YAML) - File output tests - Verbose logging tests - Added pytest configuration with coverage reporting Documentation: - Comprehensive README with installation, examples, and integrations - CONTRIBUTING.md with development guidelines - SECURITY.md with security policy and best practices - CHANGELOG.md with version history - Examples directory with sample configurations - Integration examples for Nornir, Ansible, and CI/CD Project Infrastructure: - Updated GitHub Actions to v4 (checkout, setup-python) - Added ruff linter and mypy type checker to CI - Added code coverage reporting with Codecov integration - Enhanced pyproject.toml with metadata and tool configurations - Added .editorconfig for consistent code style - Added py.typed marker for PEP 561 compliance
1 parent 599b493 commit 9f24d42

16 files changed

Lines changed: 2143 additions & 156 deletions

.editorconfig

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
charset = utf-8
11+
trim_trailing_whitespace = true
12+
13+
# Python files
14+
[*.py]
15+
indent_style = space
16+
indent_size = 4
17+
max_line_length = 100
18+
19+
# YAML files
20+
[*.{yml,yaml}]
21+
indent_style = space
22+
indent_size = 2
23+
24+
# TOML files
25+
[*.toml]
26+
indent_style = space
27+
indent_size = 2
28+
29+
# Markdown files
30+
[*.md]
31+
trim_trailing_whitespace = false
32+
max_line_length = 120
33+
34+
# Shell scripts
35+
[*.sh]
36+
indent_style = space
37+
indent_size = 2
38+
39+
# JSON files
40+
[*.json]
41+
indent_style = space
42+
indent_size = 2
43+
44+
# Configuration files
45+
[*.conf]
46+
indent_style = space
47+
indent_size = 2

.github/workflows/deploy.yaml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,36 @@ on:
44
release:
55
types: [created]
66

7+
permissions:
8+
contents: read
9+
710
jobs:
811
deploy:
912
runs-on: ubuntu-latest
13+
environment:
14+
name: pypi
15+
url: https://pypi.org/project/hier-config-cli/
16+
permissions:
17+
id-token: write # Required for trusted publishing
18+
1019
steps:
11-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v4
21+
1222
- name: Set up Python
13-
uses: actions/setup-python@v2
23+
uses: actions/setup-python@v5
1424
with:
15-
python-version: '3.9'
25+
python-version: '3.12'
26+
1627
- name: Install poetry
1728
uses: snok/install-poetry@v1
1829
with:
19-
version: 1.5.1
20-
- name: Build and publish to PyPI
30+
version: 1.8.2
31+
32+
- name: Build package
33+
run: |
34+
poetry build
35+
36+
- name: Publish to PyPI
2137
env:
2238
TWINE_API_KEY: ${{ secrets.TWINE_API_KEY }}
2339
run: |

.github/workflows/test-app.yaml

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [main]
88

99
jobs:
10-
build:
10+
test:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
@@ -16,21 +16,62 @@ jobs:
1616
- "3.10"
1717
- "3.11"
1818
- "3.12"
19+
- "3.13"
1920

2021
steps:
21-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v4
23+
2224
- name: Set up Python ${{ matrix.python-version }}
23-
uses: actions/setup-python@v2
25+
uses: actions/setup-python@v5
2426
with:
2527
python-version: ${{ matrix.python-version }}
28+
2629
- name: Install poetry
2730
uses: snok/install-poetry@v1
2831
with:
29-
version: 1.5.1
30-
- name: Set PYTHONPATH
31-
run: echo "PYTHONPATH=src" >> $GITHUB_ENV
32-
- name: Run tests
32+
version: 1.8.2
33+
34+
- name: Cache dependencies
35+
uses: actions/cache@v4
36+
with:
37+
path: ~/.cache/pypoetry
38+
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
39+
restore-keys: |
40+
${{ runner.os }}-poetry-
41+
42+
- name: Install dependencies
43+
run: |
44+
poetry install --no-interaction
45+
46+
- name: Run black formatter check
47+
run: |
48+
poetry run black --check src/ tests/
49+
50+
- name: Run ruff linter
3351
run: |
34-
poetry install --no-interaction --no-root
35-
poetry run black --check .
36-
poetry run pytest tests/
52+
poetry run ruff check src/ tests/
53+
54+
- name: Run mypy type checker
55+
run: |
56+
poetry run mypy src/
57+
58+
- name: Run tests with coverage
59+
run: |
60+
poetry run pytest --cov=hier_config_cli --cov-report=xml --cov-report=term-missing
61+
62+
- name: Upload coverage to Codecov
63+
uses: codecov/codecov-action@v4
64+
if: matrix.python-version == '3.12'
65+
with:
66+
file: ./coverage.xml
67+
flags: unittests
68+
name: codecov-umbrella
69+
fail_ci_if_error: false
70+
71+
- name: Upload coverage reports
72+
uses: actions/upload-artifact@v4
73+
if: matrix.python-version == '3.12'
74+
with:
75+
name: coverage-report
76+
path: htmlcov/
77+
retention-days: 7

CHANGELOG.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
## [0.2.0] - 2026-01-25
11+
12+
### Added
13+
- Added support for Fortinet FortiOS platform
14+
- Added `--format` option to output results in JSON, YAML, or text formats
15+
- Added `--output` / `-o` flag to save output to file
16+
- Added `list-platforms` command to show all available platforms
17+
- Added `version` command to display tool version
18+
- Added comprehensive error handling for file operations and platform validation
19+
- Added verbose logging support with `-v` (INFO) and `-vv` (DEBUG) flags
20+
- Added complete type hints throughout codebase
21+
- Added comprehensive test suite with 20+ test cases including:
22+
- Error handling tests
23+
- All platform tests
24+
- Output format tests (text, JSON, YAML)
25+
- File output tests
26+
- Verbose logging tests
27+
- Added comprehensive documentation:
28+
- Detailed README with installation instructions and examples
29+
- CONTRIBUTING.md with development guidelines
30+
- SECURITY.md with security policy
31+
- Examples directory with sample configurations
32+
- Integration examples for Nornir, Ansible, and CI/CD
33+
- Added development tools configuration:
34+
- Black formatter configuration
35+
- Ruff linter configuration
36+
- Mypy type checker configuration
37+
- Pytest with coverage reporting
38+
- Added `py.typed` marker file for PEP 561 compliance
39+
40+
### Changed
41+
- **BREAKING**: Converted to proper Python package structure with `__init__.py`
42+
- **BREAKING**: Entry point now uses `hier_config_cli:cli` instead of module path
43+
- Refactored duplicate code in commands into shared `process_configs()` function
44+
- Fixed platform-specific output formatting (no longer hardcodes `cisco_style_text()` for all platforms)
45+
- Improved command help text with detailed descriptions and examples
46+
- Enhanced pyproject.toml with comprehensive metadata and classifiers
47+
- Updated Python version support to 3.9-3.13
48+
- Improved error messages to be more descriptive and actionable
49+
50+
### Fixed
51+
- Fixed incorrect output format for Juniper JunOS configurations
52+
- Fixed missing platform support for Fortinet FortiOS
53+
- Fixed lack of error handling for missing or unreadable configuration files
54+
- Fixed unused PyYAML dependency (now actively used for YAML output)
55+
56+
### Removed
57+
- Removed code duplication across remediation, rollback, and future commands
58+
59+
## [0.1.0] - 2024-12-XX
60+
61+
### Added
62+
- Initial release
63+
- Basic remediation, rollback, and future commands
64+
- Support for major network platforms:
65+
- Cisco IOS
66+
- Cisco NX-OS
67+
- Cisco IOS XR
68+
- Arista EOS
69+
- Juniper JunOS
70+
- VyOS
71+
- HP Comware5
72+
- HP ProCurve
73+
- Generic platform
74+
- GitHub Actions CI/CD pipeline
75+
- Basic test coverage
76+
- Apache 2.0 license
77+
78+
[Unreleased]: https://github.com/netdevops/hier-config-cli/compare/v0.2.0...HEAD
79+
[0.2.0]: https://github.com/netdevops/hier-config-cli/compare/v0.1.0...v0.2.0
80+
[0.1.0]: https://github.com/netdevops/hier-config-cli/releases/tag/v0.1.0

0 commit comments

Comments
 (0)