|
| 1 | +# Contributing to go-sqlcmd |
| 2 | + |
| 3 | +Thank you for your interest in contributing to go-sqlcmd! This document provides guidelines for contributing to the project. |
| 4 | + |
| 5 | +## Development Setup |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | + |
| 9 | +- Go 1.24 or later |
| 10 | +- Git |
| 11 | + |
| 12 | +### Building the Project |
| 13 | + |
| 14 | +```bash |
| 15 | +# Clone the repository |
| 16 | +git clone https://github.com/microsoft/go-sqlcmd.git |
| 17 | +cd go-sqlcmd |
| 18 | + |
| 19 | +# Build sqlcmd |
| 20 | +./build/build.sh # Linux/macOS |
| 21 | +.\build\build.cmd # Windows |
| 22 | +``` |
| 23 | + |
| 24 | +### Running Tests |
| 25 | + |
| 26 | +```bash |
| 27 | +# Run all tests |
| 28 | +go test ./... |
| 29 | + |
| 30 | +# Run tests with verbose output |
| 31 | +go test -v ./... |
| 32 | + |
| 33 | +# Run tests for a specific package |
| 34 | +go test -v ./pkg/sqlcmd/... |
| 35 | +``` |
| 36 | + |
| 37 | +## Release Process |
| 38 | + |
| 39 | +This project uses [Release Please](https://github.com/googleapis/release-please) for automated version management and releases. Release Please analyzes commits since the last release and automatically creates a Release PR that: |
| 40 | + |
| 41 | +- Bumps the version based on [Conventional Commits](https://www.conventionalcommits.org/) |
| 42 | +- Updates the CHANGELOG.md with changes |
| 43 | +- Creates a GitHub release when the PR is merged |
| 44 | + |
| 45 | +### Conventional Commits |
| 46 | + |
| 47 | +All commits should follow the [Conventional Commits](https://www.conventionalcommits.org/) specification. This enables automated version bumping and changelog generation. |
| 48 | + |
| 49 | +#### Commit Message Format |
| 50 | + |
| 51 | +``` |
| 52 | +<type>[optional scope]: <description> |
| 53 | +
|
| 54 | +[optional body] |
| 55 | +
|
| 56 | +[optional footer(s)] |
| 57 | +``` |
| 58 | + |
| 59 | +#### Types and Version Bumping |
| 60 | + |
| 61 | +| Type | Version Bump | Description | Example | |
| 62 | +|------|--------------|-------------|---------| |
| 63 | +| `feat:` | Minor (0.X.0) | New feature | `feat: add query timeout option` | |
| 64 | +| `fix:` | Patch (0.0.X) | Bug fix | `fix: resolve connection timeout issue` | |
| 65 | +| `feat!:` or `BREAKING CHANGE:` | Major (X.0.0) | Breaking change | `feat!: change default port to 1433` | |
| 66 | +| `docs:` | No bump | Documentation only | `docs: update README with examples` | |
| 67 | +| `chore:` | No bump | Maintenance tasks | `chore: update dependencies` | |
| 68 | +| `ci:` | No bump | CI/CD changes | `ci: add workflow for linting` | |
| 69 | +| `test:` | No bump | Test changes | `test: add unit tests for parser` | |
| 70 | +| `refactor:` | No bump | Code refactoring | `refactor: simplify connection logic` | |
| 71 | +| `perf:` | No bump | Performance improvements | `perf: optimize query execution` | |
| 72 | +| `build:` | No bump | Build system changes | `build: update build script` | |
| 73 | + |
| 74 | +#### Examples |
| 75 | + |
| 76 | +**Feature (Minor bump):** |
| 77 | +``` |
| 78 | +feat: add support for Azure AD authentication |
| 79 | +
|
| 80 | +Adds new authentication method for connecting to Azure SQL |
| 81 | +databases using Azure Active Directory credentials. |
| 82 | +``` |
| 83 | + |
| 84 | +**Bug fix (Patch bump):** |
| 85 | +``` |
| 86 | +fix: correct handling of null values in output |
| 87 | +
|
| 88 | +Previously, null values were displayed as empty strings. |
| 89 | +Now they are properly displayed as "NULL". |
| 90 | +``` |
| 91 | + |
| 92 | +**Breaking change (Major bump):** |
| 93 | +``` |
| 94 | +feat!: change default encryption to mandatory |
| 95 | +
|
| 96 | +BREAKING CHANGE: The default encryption setting has changed |
| 97 | +from optional to mandatory. Users must explicitly set |
| 98 | +encryption to optional if needed. |
| 99 | +``` |
| 100 | + |
| 101 | +**Non-version-bumping changes:** |
| 102 | +``` |
| 103 | +docs: add examples for container commands |
| 104 | +chore: update go-mssqldb dependency |
| 105 | +ci: add codeql security scanning |
| 106 | +test: add integration tests for query command |
| 107 | +``` |
| 108 | + |
| 109 | +### How Releases Work |
| 110 | + |
| 111 | +1. **Make changes** following conventional commit guidelines |
| 112 | +2. **Create PR** with your changes |
| 113 | +3. **Merge PR to main** - Release Please will analyze commits |
| 114 | +4. **Release Please creates/updates a Release PR** that: |
| 115 | + - Bumps version in relevant files |
| 116 | + - Updates CHANGELOG.md |
| 117 | + - Tags the release |
| 118 | +5. **Review and merge the Release PR** - This triggers: |
| 119 | + - Creation of a GitHub Release |
| 120 | + - Publishing of release artifacts |
| 121 | + |
| 122 | +### Manual Release Process (if needed) |
| 123 | + |
| 124 | +If you need to create a release manually: |
| 125 | + |
| 126 | +1. Update the version in `.release-please-manifest.json` |
| 127 | +2. Update CHANGELOG.md manually |
| 128 | +3. Create and push a git tag: |
| 129 | + ```bash |
| 130 | + git tag v1.0.0 |
| 131 | + git push origin v1.0.0 |
| 132 | + ``` |
| 133 | +4. Create a GitHub release from the tag |
| 134 | + |
| 135 | +## Pull Request Guidelines |
| 136 | + |
| 137 | +- Follow the conventional commit format in PR titles |
| 138 | +- Keep PRs focused on a single feature or fix |
| 139 | +- Add tests for new functionality |
| 140 | +- Ensure all tests pass locally before submitting |
| 141 | +- Update documentation if needed |
| 142 | + |
| 143 | +## Code Style |
| 144 | + |
| 145 | +- Follow standard Go conventions and idioms |
| 146 | +- Use `gofmt` for formatting |
| 147 | +- Run `golangci-lint` before submitting |
| 148 | + |
| 149 | +## Questions? |
| 150 | + |
| 151 | +If you have questions, feel free to: |
| 152 | +- Open an issue for discussion |
| 153 | +- Check existing issues and discussions |
| 154 | +- Review the [README](README.md) for more information |
| 155 | + |
| 156 | +## License |
| 157 | + |
| 158 | +By contributing, you agree that your contributions will be licensed under the MIT License. |
0 commit comments