This document describes the local commit checks that you can run before pushing changes to the repository. These checks mirror the GitHub workflows that run in CI, ensuring your contributions will pass pipeline validation.
A pre-commit hook has been set up to run the same checks as the GitHub workflows. This will prevent commits that would fail the CI checks.
The pre-commit hook will run:
go mod tidycheck - Ensures module files are clean and up-to-date- Code formatting verification with
gofmt- Enforces Go code style standards - Linting with
golangci-lint- Identifies code quality issues - Security scanning with
gosec- Finds potential security vulnerabilities - Vulnerability checking with
govulncheck- Detects known vulnerabilities in dependencies - Running tests with race detection - Validates functionality and thread safety
- Verifying that the code builds - Ensures code compiles correctly
You can install all development tools at once with:
make install-toolsThis will install:
- pre-commit hook manager
- gopls (Go language server)
- golangci-lint
- gosec
- govulncheck
- goimports
And set up the pre-commit hooks in your local repository.
This project includes a comprehensive Makefile to run checks individually or together:
# Run all standard checks (same as GitHub workflow)
make check
# Run pre-commit checks on all files
make precommit
# Run specific checks
make lint # Run golangci-lint
make test # Run tests with race detection
make build # Verify build
make format # Check code formatting
make tidy # Check if go.mod and go.sum are tidy
make security # Run gosec security scan
make vulncheck # Run vulnerability check
# Run transport-specific checks
make transport-check # Test transport implementations specifically
# Show available commands
make helpThe transport-check target runs specialized tests for the transport implementations, which is particularly important for verifying:
- StdioTransport with BaseTransport embedding
- HTTPTransport functionality including error handling and security aspects
These tests ensure that all transport mechanisms properly implement the Transport interface and handle edge cases correctly.
The GitHub Actions CI workflow runs the following jobs:
- Lint: Uses golangci-lint to check code quality
- Test: Runs tests with race detection and uploads coverage to Codecov
- Build: Verifies the code builds successfully
- Verify-Formatting: Ensures code is properly formatted with gofmt
The test job runs on multiple OS platforms (Linux, macOS, Windows) and Go versions to ensure broad compatibility.
In case you need to commit changes without running the pre-commit hook (not recommended), you can use:
git commit --no-verify -m "Your commit message"Note: Bypassing checks should only be done in exceptional circumstances as it may lead to failing CI builds.