Thank you for your interest in contributing to PowerNetbox! This document explains our development practices and how to contribute effectively.
- Code of Conduct
- Getting Started
- Development Workflow
- Code Quality Standards
- Testing Requirements
- Pull Request Process
- Why These Practices?
Be respectful, inclusive, and constructive. We're all here to build great software together.
- PowerShell 5.1+ (Desktop) or PowerShell 7+ (Core)
- Git
- A Netbox instance for testing (or use Docker)
- Pester 5.0+ for running tests
# Clone the repository
git clone https://github.com/ctrl-alt-automate/PowerNetbox.git
cd PowerNetbox
# Build the module
./deploy.ps1 -Environment dev -SkipVersion
# Run tests
Invoke-Pester ./Tests/# Start a local Netbox instance
docker compose -f docker-compose.ci.yml up -d
# Wait for Netbox to be ready (2-3 minutes)
# Then run integration tests
pwsh -Command "Invoke-Pester ./Tests/Integration.Tests.ps1 -Tag 'Live'"
# Cleanup
docker compose -f docker-compose.ci.yml down -v| Branch | Purpose |
|---|---|
main |
Production releases (published to PSGallery) |
dev |
Active development |
beta |
Pre-release testing (e.g., Netbox 4.5 compatibility) |
feature/* |
Feature branches |
fix/* |
Bug fix branches |
-
Create a branch from
dev:git checkout dev git pull origin dev git checkout -b feature/your-feature-name
-
Make your changes following our code standards
-
Test your changes:
Invoke-Pester ./Tests/
-
Commit with meaningful messages:
git commit -m "feat(dcim): Add support for cable profiles" -
Push and create a PR against
dev
We follow the PowerShell Practice and Style Guidelines.
function Get-NBExample {
[CmdletBinding()] # Always required
[OutputType([PSCustomObject])] # Document return type
param (
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()] # Validate inputs
[string]$Name,
[switch]$Raw # All functions need -Raw switch
)
process { # Use process block for pipeline support
# Implementation
}
}Functions that modify data must use SupportsShouldProcess:
function New-NBExample {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Low')]
param(...)
process {
if ($PSCmdlet.ShouldProcess($Name, 'Create Example')) {
# Create the resource
}
}
}| Verb | ConfirmImpact |
|---|---|
| New- | Low |
| Set- | Medium |
| Remove- | High |
- Functions:
[Verb]-NB[Module][Resource](e.g.,Get-NBDCIMDevice) - Files: One function per file, filename matches function name
- Parameters: PascalCase, use standard names (
Id,Name,Limit,Offset)
- ❌
Write-Host(useWrite-Verboseinstead) - ❌ Hardcoded paths or credentials
- ❌ Using
\in paths (useJoin-Path) - ❌ Ignoring errors silently
Every PR is automatically checked for:
| Check | Tool | Purpose |
|---|---|---|
| Linting | PSScriptAnalyzer | PowerShell best practices |
| Unit Tests | Pester | Code correctness |
| Cross-Platform | GitHub Actions | Windows, Linux, macOS compatibility |
- All new functions need corresponding tests
- Tests go in
Tests/directory - Use Pester 5.x syntax
Describe "Get-NBDCIMDevice" {
It "Should return devices" {
# Test implementation
}
}We aim for comprehensive coverage of:
- Happy path scenarios
- Error handling
- Edge cases
- Pipeline input
# All tests
Invoke-Pester ./Tests/
# Specific test file
Invoke-Pester ./Tests/DCIM.Tests.ps1
# With coverage
Invoke-Pester ./Tests/ -CodeCoverage ./Functions/**/*.ps1- ✅ All tests pass locally
- ✅ Code follows style guidelines
- ✅ New functionality has tests
- ✅ Documentation updated (if needed)
PRs must pass these automated checks before merge:
| Check | Required |
|---|---|
| PSScriptAnalyzer (Lint) | ✅ |
| Pester Tests (Ubuntu) | ✅ |
| Pester Tests (Windows) | ✅ |
| Code Review (1 approval) | ✅ |
- Automated checks run immediately
- Code owners are automatically assigned as reviewers
- At least 1 approval is required
- All checks must pass before merge
We've implemented specific GitHub features to maintain code quality. Here's why:
Why? Prevents broken code from being merged.
- PSScriptAnalyzer catches common PowerShell mistakes
- Pester tests verify functionality works
- Cross-platform tests ensure compatibility
Why? Ensures consistent, complete information.
- Reviewers know what changed and why
- Checklist prevents forgotten steps
- Testing details help reproduce issues
Why? Gets the right information upfront.
- Bug reports include environment details
- Feature requests explain the use case
- Reduces back-and-forth communication
Why? Ensures the right people review changes.
- Module experts review their areas
- Critical files get extra attention
- Automatic assignment saves time
Why? Prevents accidental damage.
- Can't push directly to protected branches
- Must go through PR process
- Ensures all checks pass
Why? Tracks progress toward releases.
- Groups related issues together
- Shows what's included in each version
- Helps prioritize work
- Check the Wiki
- Open a Discussion
- Review existing Issues
Thank you for contributing to PowerNetbox! 🎉