Since this is a Go library, there is no application to run.
To run all tests:
go test ./...
We use the built-in mock library and use mockgen to generate the mock implementation of Interfaces for testing.
To generate mocks:
go generate ./...
We make use of go:generate
comments to instruct which mockgen
commands should be run.
goimports
is enforced via a CI step.
It is up to the individual developer to ensure their change complies with this.
Static analysis tools and linters are run as part of CI. They come from golangci-lint. To run this locally:
# Must be in a directory with a go.mod file
cd <directory_with_go_module>
golangci-lint run ./...
A pre-commit hook configuration is provided to enforce some tasks on git commit
.
Run pre-commit install
to install pre-commit into your git hooks. pre-commit will now run on every commit.
If you want to manually run all pre-commit hooks on a repository without creating hooks, run pre-commit run --all-files
.
To run individual hooks use pre-commit run <hook_id>
.
Code Climate is integrated with our GitHub flow. Failing the configured rules will yield a pull request not mergeable.
If you prefer to view the Code Climate report on your machine, prior to sending a pull request, you can use the cli provided by Code Climate.
Plugins for various tools are also available:
For dependency upgrades, dependabot is relied upon and news files are auto-generated in order to document such change.
The CI supports three release flows:
development
for snapshot releasesrelease
for stable releasesbeta
for pre-releases
Type | Purpose | Version Number Format | GitHub Release | News Files Deleted |
---|---|---|---|---|
Release | General Availability | <minor>.<major>.<patch> |
Yes | Yes |
Beta | Integration Testing | <minor>.<major>.<patch>-beta.<commit number> |
Yes | No |
Development | Development Testing | <minor>.<major>.<patch>-dev+<git hash> |
No | No |
⚠️ releases can be made from any branches but it is recommended that they are only made from themain
branch.
- Navigate to the GitHub Actions page.
- Select the Run Workflow button and type which kind of release you would like to make (i.e. release, beta or development).
The version number will be automatically calculated, based on the news files.
So that no secrets are committed back to the repository, a combination of two tools are run in CI:
- GitLeaks : Scans the git history for usual secrets (e.g. AWS keys, etc.)
- detect-secrets: Scans only the current state of the repository for anything which can look like secrets (strings with high entropy)
For the latter, False positive keys are stored in the baseline which detect-secrets
checks against when it runs
To flag individual false positives add comment # pragma: allowlist secret
to line with secret
To add all suspected secrets in the repository (excluding ones with an allow secret comment), run detect-secrets scan --all-files --exclude-files '.*go\.sum$' --exclude-files '.*\.html$' --exclude-files '.*\.properties$' --exclude-files 'ci.yml' --exclude-files '\.git' > .secrets.baseline
If on Windows: then change the encoding of the .secrets.baseline file to UTF-8 then convert all \
to /
in the .secrets.baseline file