diff --git a/Makefile b/Makefile index be8c7e6..ccaea6d 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,13 @@ test: $(call _print_step,Running unit tests) go test -race -cover ./... +.PHONY: test/coverage +## Produce test coverage report and inspect it in browser. +test/coverage: + $(call _print_step,Running test coverage report) + go test -coverprofile=coverage.out ./... + go tool cover -html=coverage.out + .PHONY: check check/vet check/lint check/gosec check/spell check/trailing check/markdown check/format check/generate check/vulns ## Run all checks. check: check/vet check/lint check/gosec check/spell check/trailing check/markdown check/format check/generate check/vulns diff --git a/README.md b/README.md index a769d8c..e2cd491 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,26 @@ to change, breaking changes may be introduced with new versions until v1 is released. Checkout [roadmap](./docs/ROADMAP.md) for upcoming, planned features. +## Legend + +1. [Getting started](#getting-started) + 1. [Use cases](#use-cases) +2. [Building blocks](#building-blocks) + 1. [Errors](#errors) +3. [Features](#features) + 1. [Type safety](#type-safety) + 2. [Immutability](#immutability) + 3. [Verbose error messages](#verbose-error-messages) + 4. [Predefined rules](#predefined-rules) + 5. [Custom rules](#custom-rules) + 6. [Validation plan](#validation-plan) + 7. [Properties name inference](#properties-name-inference) +4. [Rationale](#rationale) + 1. [Reflection](#reflection) + 2. [Trivia](#trivia) +5. [Development](#development) +6. [Acknowledgments](#acknowledgments) + ## Getting started In order to add the library to your project, run: @@ -565,6 +585,11 @@ were associated with given property was tedious to say the least. Around the same time, Go 1.18 was released with generics support, we started playing with them, and the idea for `govy` was born. +## Development + +Checkout both [contributing guidelines](./docs/CONTRIBUTING.md) and +[development instructions](./docs/DEVELOPMENT.md). + ## Acknowledgments The API along with the accompanying nomenclature was heavily inspired by the diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md new file mode 100644 index 0000000..d23598c --- /dev/null +++ b/docs/CONTRIBUTING.md @@ -0,0 +1,32 @@ +# Contributing to govy + +If you're here, chances are you want to contribute ;) +Thanks a lot for that! + +Your pull request will be reviewed by one of the maintainers. +We encourage and welcome any and all feedback. + +## Before you contribute + +The goal of this project is to develop a validation library with +functional interface which is strongly-typed, produces information rich errors +and has API that is easy to understand and use. + +Make sure you're familiarized with +[development instructions](./DEVELOPMENT.md). + +## Making a pull request + +Please make a fork of this repo and submit a PR from there. +More information can be found +[here](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request). + +## Merge Request title + +Try to be as descriptive as you can in your PR title. +Note that the title must adhere to the rules defined in +[this workflow](./.github/workflows/pr-title.yml). + +## License + +Govy is licensed under Mozilla Public License Version 2.0, see [LICENSE](../LICENSE). diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md new file mode 100644 index 0000000..9709fe0 --- /dev/null +++ b/docs/DEVELOPMENT.md @@ -0,0 +1,78 @@ +# Development + +This document describes the intricacies of govy development workflow. +If you see anything missing, feel free to contribute to this document :) + +## Pull requests + +[Pull request template](../.github/pull_request_template.md) +is provided when you create new PR. +Section worth noting and getting familiar with is located under +`## Release Notes` header. + +## Makefile + +Govy ships with a Makefile which is well documented and should cover most if +not all development cycle needs. +Run `make help` to display short description for each target. + +## CI + +Continuous integration pipelines utilize the same Makefile commands which +you run locally within reproducible `devbox` environment. +This ensures consistent behavior of the executed checks +and makes local debugging easier. + +## Testing + +You can run all unit tests with `make test`. +We also encourage inspecting test coverage during development, you can verify +if the paths you're interested in are covered with `make test/coverage`. + +## Releases + +Govy adheres to the Go's official release workflow recommendations and +requirements. Refer to the official +[Go docs](https://go.dev/doc/modules/release-workflow) for more details. + +### Release automation + +We're using [Release Drafter](https://github.com/release-drafter/release-drafter) +to automate release notes creation. Drafter also does its best to propose +the next release version based on commit messages from `main` branch. + +Release Drafter is also responsible for auto-labeling pull requests. +It checks both title and body of the pull request and adds appropriate labels. \ +**NOTE:** The auto-labeling mechanism will not remove labels once they're +created. For example, If you end up changing PR title from `sec:` to `fix:` +you'll have to manually remove `security` label. + +On each commit to `main` branch, Release Drafter will update the next release +draft. + +In addition to Release Drafter, we're also running a script which extracts +explicitly listed release notes and breaking changes which are optionally +defined in `## Release Notes` and `## Breaking Changes` headers. +It also performs a cleanup of the PR draft mitigating Release Drafter +shortcomings. + +## Code generation + +Some parts of the codebase are automatically generated. +We use the following tools to do that: + +- [gomarkdoc](https://github.com/princjef/gomarkdoc) + for generating Markdown docs from Go code docs. +- [embed-example-in-readme.bash](../scripts/embed-example-in-readme.bash) + for embedding tested examples in [README.md](../README.md). + +## Validation + +We're using our own validation library to write validation for all objects. +Refer to this [README.md](../internal/validation/README.md) for more information. + +## Dependencies + +Renovate is configured to automatically merge minor and patch updates. +For major versions, which sadly includes GitHub Actions, manual approval +is required.