Thank you for considering contributing to contract-cli! We appreciate your time and effort in helping improve this project. This guide will help you understand our development process and how to contribute effectively.
- Code of Conduct
- How Can I Contribute?
- Getting Started
- Development Workflow
- Coding Standards
- Commit Messages
- Pull Request Process
- Testing
- Reporting Bugs
- Suggesting Enhancements
- Questions
This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the maintainers listed in MAINTAINERS.md.
We use GitHub issue templates to ensure we collect all necessary information. To report a bug:
- Check for existing issues: Search existing issues to avoid duplicates
- Use the bug report template: Click here or select "Bug Report" when creating a new issue
- Fill out all required fields: The template will guide you through providing:
- Bug description and impact
- Steps to reproduce
- Expected vs actual behavior
- CLI command and flags used
- Environment details (CLI version, OS, OpenSSL version, etc.)
- Target platform (hpvs, hpcr-rhvs, hpcc-peerpod)
Important: For security vulnerabilities, do NOT create a public issue. Instead, report them via GitHub Security Advisories or follow our Security Policy.
To suggest a new feature or enhancement:
- Check for existing requests: Search existing issues to see if it's already been suggested
- Use the feature request template: Click here or select "Feature Request" when creating a new issue
- Provide detailed information: The template will guide you through:
- Problem statement and motivation
- Proposed solution
- Alternatives considered
- Use cases and examples
- Expected CLI usage
- Priority and impact assessment
If you have questions about using the CLI:
- Check the documentation first: Review our User Documentation and README
- Search existing Q&A: Look through closed issues with the "question" label
- Use GitHub Discussions: For general questions, use GitHub Discussions
- Create a question issue: If needed, use our question template
We actively welcome your pull requests! However, please follow this process:
-
Open an issue first - Before submitting a pull request, open an issue describing:
- What bug you're fixing or feature you're adding
- Why it should be fixed or added
- How you plan to implement it
This helps us discuss the approach early and avoid duplicated or unnecessary work.
Pull requests without a linked issue may be closed.
-
Get feedback - Wait for maintainer feedback on your issue before starting work.
-
Fork and create a branch - Once approved, fork the repo and create a feature branch.
-
Implement your changes - Follow our coding standards and best practices.
-
Test thoroughly - Add tests for your changes and ensure all tests pass.
-
Submit a pull request - Reference the original issue in your PR description.
- Go 1.25.6 or later
- OpenSSL - Required for encryption operations
- Make - For running build commands
- Git - For version control
-
Fork the repository on GitHub
-
Clone your fork:
git clone https://github.com/YOUR-USERNAME/contract-cli.git cd contract-cli -
Add upstream remote:
git remote add upstream https://github.com/ibm-hyper-protect/contract-cli.git
-
Install dependencies:
make install-deps
-
Verify your setup:
make test
-
Create a feature branch from
main:git checkout main git pull upstream main git checkout -b feature/your-feature-name
-
Make your changes following our coding standards
-
View available make targets:
make help -
Run tests frequently during development:
make test # Or simply run the default target make
-
Build the CLI to test locally:
make build
-
Tidy dependencies:
make tidy
-
Commit your changes with proper commit messages
-
Push to your fork:
git push origin feature/your-feature-name
-
Open a Pull Request from your fork to the main repository
- Follow the official Go Code Review Comments
- Use
gofmt(runmake fmt) to format your code (run automatically with most editors) - Follow Effective Go principles
- Write idiomatic Go code
- Keep functions small and focused - Each function should do one thing well
- Write self-documenting code - Use clear variable and function names
- Add comments for complex logic - Explain the "why", not the "what"
- Handle errors explicitly - Never ignore errors
- Use Cobra best practices - Follow the patterns established in the codebase
- Validate user input - Always validate flags and arguments
- Consistent flag names - Follow existing naming conventions (e.g.,
--in,--key,--output) - Clear error messages - Provide helpful, actionable error messages to users
- Help text - Write clear descriptions for commands and flags
- Exit codes - Use appropriate exit codes (0 for success, non-zero for errors)
- Add command documentation - Update docs/README.md for new commands
- Update main README - Add usage examples for significant new features
- Include examples - Provide practical examples in documentation
We follow Conventional Commits specification:
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
feat:- A new feature or commandfix:- A bug fixdocs:- Documentation only changesrefactor:- Code changes that neither fix a bug nor add a featureperf:- Performance improvementstest:- Adding or updating testschore:- Changes to build process, dependencies, etc.ci:- CI/CD configuration changes
feat(encrypt): add support for IBM Confidential Computing peer pod contracts
fix(base64-tgz): handle empty docker-compose files correctly
docs: update installation instructions for Windows
test(decrypt-attestation): add tests for malformed input
- Use imperative mood - "add feature" not "added feature"
- Keep subject line under 50 characters
- Capitalize the subject line
- Don't end subject line with a period
- Separate subject from body with a blank line
- Use body to explain what and why, not how
- Reference issues (e.g., "Fixes #123")
- Link to the related issue in your PR description
- Ensure all tests pass (
make test) - Run
make tidyto clean up dependencies - Build the CLI to verify compilation (
make build) - Update documentation if needed
- Add or update tests for your changes
- Follow the commit message conventions
- Rebase your branch on the latest
mainif needed
When opening a PR, include:
## Description
Brief description of the changes
## Related Issue
Fixes #issue_number
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
- [ ] Code refactor
## Testing
Describe the tests you ran and how to reproduce them
## Checklist
- [ ] My code follows the project's coding standards
- [ ] I have performed a self-review of my code
- [ ] I have commented my code where necessary
- [ ] I have updated the documentation
- [ ] I have added tests that prove my fix/feature works
- [ ] All new and existing tests pass- Automated checks - CI must pass before review
- Maintainer review - Tag @Sashwat-K and @vikas-sharma24 as reviewers
- Address feedback - Make requested changes promptly
- Approval - At least one maintainer must approve
- Merge - Maintainers will merge your PR
- Delete your feature branch
- Update your local repository:
git checkout main git pull upstream main
# Run all tests (default target)
make test
# Or simply
make
# Run tests with coverage
make test-cover
# Run tests with custom coverage
go test -v -race -coverprofile=coverage.out ./...
# Run specific package tests
go test ./cmd -v
# Run specific test
go test ./cmd -v -run TestEncryptCommand- Write tests for all new code - Aim for good coverage
- Use table-driven tests where appropriate
- Test edge cases and error conditions
- Use meaningful test names -
TestCommandName_Scenario_ExpectedBehavior - Keep tests independent - Tests should not depend on each other
- Test CLI output - Verify command output and exit codes
func TestEncryptCommand(t *testing.T) {
tests := []struct {
name string
args []string
wantErr bool
errMsg string
}{
{
name: "valid contract",
args: []string{"--in", "test.yaml", "--key", "key.pem"},
wantErr: false,
},
{
name: "missing contract flag",
args: []string{"--key", "key.pem"},
wantErr: true,
errMsg: "required flag \"contract\" not set",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cmd := NewEncryptCommand()
cmd.SetArgs(tt.args)
err := cmd.Execute()
if tt.wantErr {
require.Error(t, err)
assert.Contains(t, err.Error(), tt.errMsg)
} else {
require.NoError(t, err)
}
})
}
}If you have questions about contributing:
- Check the documentation
- Search existing issues
- Open a new issue with the
questionlabel - Reach out to the maintainers listed in MAINTAINERS.md
By contributing to contract-cli, you agree that your contributions will be licensed under the Apache License 2.0.
Thank you for contributing to contract-cli! Your efforts help make this project better for everyone.