See README.md.
In cli
, writing tests is important to ensure the quality and correctness of the code. It can catch bugs early in the development process and prevent regressions when making changes to the codebase.
There are two kinds of tests in cli
:
- specific pkg test:
cd xxx && go test ./...
orcd xxx && ginkgo .
- specific test:
cd xxx && ginkgo -focus xxx
(xxx isDescribe
name)
Once you have written your tests, you should run them before committing your code. For unit tests, you can do this by running the go test
command in the directory containing your test files, and this command will run all the tests in your package and report any errors. For system tests, you can check if it works by running ./zbpack [folder path]
manually.
- Write the tests for every new feature you add.
- Run the tests by running
make test
. - Format your code by running
gofumpt -w .
. You may need to install gofumpt before running this command. - Lint your code before committing by running
make lint
. You may need to install golangci-lint before running this command.
We use the Conventional Commits format for our commit messages. It makes the commit message clear for readability.
Each commit message should have a type, a scope, and a subject. Here is an example:
feat(cmd/service): Optimization for user experience
This commit add multiple selectors for user to select services interactively.
The scope, for example, can be:
cmd
: The command-line interface.api
: The api interface of zeabur cli. (pkg/api/*
)component
: The library exposed to the users. (pkg/*
)model
: The model definition of api interface. (pkg/model/*
)util
: The utility functions. (internal/utils, pkg/util, intermal/cmdutil
)lint
: The configuration of linters, formatters,.editerconfig
, etc.docs
: The documentation for zeabur cli. (docs/*
)- (feel free to add your own scope if these can not fulfill your changes)
You can contain subscopes in your scope. For example, cmd/service
.
- Create a new branch for your changes.
- Make your changes and commit them with clear commit messages following the guidelines above.
- Push your branch to your fork of the repository.
- Open a pull request against the
main
branch of the original repository. - Wait for a maintainer to review and merge your changes.
Thank you for your contributions!