We welcome contributions to LeastPrivilegedMSGraph! This document provides guidelines for contributing to this project.
- How to Contribute
- Getting Started
- Development Guidelines
- Submitting Issues
- Submitting Pull Requests
- Coding Standards
- Testing Requirements
- Documentation Requirements
- Release Process
There are several ways you can contribute to this project:
- Report bugs - Submit detailed bug reports
- Request features - Suggest new functionality
- Submit pull requests - Fix bugs or implement new features
- Improve documentation - Help make our docs better
- Review pull requests - Help review and test changes
Before contributing, ensure you have:
- PowerShell 5.1 or later
- Git for version control
- Visual Studio Code (recommended) with PowerShell extension
- .NET SDK (for certain build tasks)
-
Fork the Repository
# Fork the repo on GitHub, then clone your fork git clone https://github.com/YOUR-USERNAME/Least_Privileged_MSGraph.git cd LeastPrivilegedMSGraph
-
Add Upstream Remote
git remote add upstream https://github.com/Mynster9361/Least_Privileged_MSGraph.git
-
Bootstrap Development Dependencies
# Install all required modules for development ./build.ps1 -ResolveDependency -Tasks noop
-
Verify Setup
# Run a test build to ensure everything works ./build.ps1 -Tasks clean, build, test
- main - Production ready code
- feature/* - New features
- hotfix/* - Critical bug fixes
- docs/* - Documentation updates
This project uses GitVersion for automatic versioning:
- Breaking changes: Use commit message with
(breaking change|breaking|major) - New features: Use commit message with
(adds?|features?|minor) - Bug fixes: Use commit message with
(fix|patch) - No version bump: Use
+semver: noneor+semver: skip
When reporting bugs, please use the bug report template and include:
- Environment details (PowerShell version, OS, module version)
- Steps to reproduce the issue
- Expected behavior
- Actual behavior
- Error messages (if any)
- Screenshots (if applicable)
For feature requests, use the feature request template and include:
- Use case description
- Proposed solution
- Alternative solutions considered
- Impact assessment
For general questions, use the general template.
-
Fork the repository
-
Create a feature branch:
git checkout -b feature/amazing-feature
-
Make your changes following our guidelines
-
Add tests for your changes
-
Ensure all tests pass:
./build.ps1 -Tasks test
-
Update documentation as needed
-
Commit your changes:
git commit -m 'Add amazing feature' -
Push to your branch:
git push origin feature/amazing-feature
-
Submit a pull request
When submitting a PR, please:
- Use the PR template
- Provide a clear description of what your PR does
- Link related issues using keywords (e.g., "fixes #123")
- Update the CHANGELOG.md following Keep a Changelog format
- Ensure GitHub Actions CI passes on all platforms
- Request review from maintainers
Before submitting, ensure your PR meets these requirements:
- The PR represents a single logical change
- Added an entry under the Unreleased section in CHANGELOG.md
- Local clean build passes:
./build.ps1 -ResolveDependency - All tests pass with adequate coverage
- Code follows our style guidelines
- Documentation has been updated
- Comment-based help is complete and accurate
- Examples have been added/updated where appropriate
Follow these coding standards:
function Verb-Noun {
<#
.SYNOPSIS
Brief description of what the function does.
.DESCRIPTION
Detailed description of the function's purpose and behavior.
.PARAMETER ParameterName
Description of the parameter.
.EXAMPLE
Verb-Noun -ParameterName "Value"
Description of what this example does.
.NOTES
Additional notes about the function.
.LINK
https://github.com/Mynster9361/Least_Privileged_MSGraph
#>
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory, ValueFromPipeline)]
[ValidateNotNullOrEmpty()]
[string]$ParameterName
)
begin {
Write-Verbose "Starting $($MyInvocation.MyCommand)"
}
process {
if ($PSCmdlet.ShouldProcess($ParameterName, 'Process Item')) {
try {
# Implementation here
Write-Verbose "Processing: $ParameterName"
# Return result
[PSCustomObject]@{
Name = $ParameterName
Processed = Get-Date
}
}
catch {
Write-Error "Failed to process '$ParameterName': $_"
throw
}
}
}
end {
Write-Verbose "Completed $($MyInvocation.MyCommand)"
}
}- Functions: Use approved PowerShell verbs (
Get-Verbto see list) - Parameters: Use PascalCase
- Variables: Use camelCase for local variables
- Classes: Use PascalCase
- Files: Match the function name exactly
- Use explicit parameter types
- Include parameter validation where appropriate
- Support pipeline input when logical
- Use
ShouldProcessfor functions that modify state - Include proper error handling
- Write descriptive variable names
- Add comments for complex logic
All code must pass PSScriptAnalyzer rules configured in .vscode/analyzersettings.psd1.
Run analysis locally:
Invoke-ScriptAnalyzer -Path ./source -Recurse- Minimum 80% code coverage required
- All public functions must have comprehensive tests
- Critical private functions should have tests
- Edge cases and error conditions must be tested
Tests should be organized as follows:
tests/
├── Unit/ # Unit tests (required)
│ ├── Public/ # Tests for public functions
│ ├── Private/ # Tests for private functions
│ └── Classes/ # Tests for classes
├── Integration/ # Integration tests (recommended)
└── QA/ # Quality assurance tests
Use this template for unit tests:
BeforeAll {
$script:moduleName = 'LeastPrivilegedMSGraph'
# Remove any existing module
Get-Module -Name $script:moduleName -All | Remove-Module -Force
# Import the module being tested
Import-Module -Name $script:moduleName -Force
}
AfterAll {
# Clean up
Get-Module -Name $script:moduleName -All | Remove-Module -Force
}
Describe 'Function-Name' {
BeforeEach {
# Setup for each test
}
Context 'When provided with valid input' {
It 'Should return expected result' {
# Arrange
$inputValue = 'TestValue'
# Act
$result = Function-Name -Parameter $inputValue
# Assert
$result | Should -Not -BeNullOrEmpty
$result.Property | Should -Be $inputValue
}
}
Context 'When provided with invalid input' {
It 'Should throw when parameter is invalid' {
{ Function-Name -Parameter $null } | Should -Throw
}
}
Context 'When using WhatIf' {
It 'Should support WhatIf parameter' {
{ Function-Name -Parameter 'Test' -WhatIf } | Should -Not -Throw
}
}
}# Run all tests
./build.ps1 -Tasks test
# Run specific test file
Invoke-Pester ./tests/Unit/Public/Get-Something.tests.ps1
# Run tests with code coverage
./build.ps1 -Tasks test -CodeCoverageThreshold 80
# Run tests in VS Code
# Use Ctrl+Shift+P -> "PowerShell: Run Pester Tests"For more details, see the Testing Guidelines.
All public functions must include:
- Complete comment-based help with synopsis, description, parameters, examples
- Parameter descriptions for all parameters
- At least one example showing typical usage
- Additional examples for complex scenarios
When adding new functionality:
- Update the main README.md if the change affects users
- Add examples to demonstrate new features
- Update the Table of Contents if needed
All changes must be documented in CHANGELOG.md following Keep a Changelog format:
## [Unreleased]
### Added
- New feature description [#123]
### Changed
- Changed functionality description [#124]
### Fixed
- Bug fix description [#125]
### Removed
- Removed feature description [#126]This project uses automated releases:
- Merge to main - Changes are merged via pull request
- Version calculation - GitVersion automatically determines version based on commit messages
- CI/CD pipeline - GitHub Actions builds, tests, and packages
- Automatic release - On successful build, creates GitHub release and publishes to PowerShell Gallery
- Update version in GitVersion.yml if needed
- Update changelog with release notes
- Create release tag following semantic versioning
- GitHub Actions pipeline will handle the rest
If you need help:
- Check existing issues - Your question might already be answered
- Search documentation - Look through README and wiki
- Ask in discussions - Use GitHub Discussions for questions
- Contact maintainers - For sensitive issues
This contributing guide is part of the LeastPrivilegedMSGraph project