Thank you for your interest in making FerretDB better!
We are interested in all contributions, big or small, in code or documentation. But unless you are fixing a very small issue like a typo, we kindly ask you first to create an issue, to leave a comment on an existing issue if you want to work on it, or to join our Slack chat and leave a message for us there. This way, you will get help from us and avoid wasted efforts if something can't be worked on right now or someone is already working on it.
You can find a list of good issues for first-time contributors there.
The easiest way to run GitHub Actions is to run them remotely on the repository. However, we encourage everyone to write tests that can check the implemented functionality and can be run locally.
You will need the latest version of Go on the host. If your package manager doesn't provide it yet, please install it from go.dev.
You will also need git
installed; the version provided by your package manager should do.
On Windows, the simplest way to install it might be https://gitforwindows.org.
Fork the FerretDB/github-actions repository on GitHub.
To have all the tags in the repository and what they point to, copy all branches by removing checkmark for copy the main branch only
before forking.
After forking FerretDB/github-actions
on GitHub, you can clone the repository:
git clone [email protected]:<YOUR_GITHUB_USERNAME>/github-actions.git
cd github-actions
git remote add upstream https://github.com/FerretDB/github-actions.git
To run development commands, you should first install the task
tool.
You can do this by changing the directory to tools
(cd tools
) and running go generate -x
.
That will install task
into the bin
directory (bin/task
on Linux and macOS, bin\task.exe
on Windows).
You can then add ./bin
to $PATH
either manually (export PATH=./bin:$PATH
in bash
)
or using something like direnv
(.envrc
files),
or replace every invocation of task
with explicit bin/task
.
You can also install task
globally,
but that might lead to the version skew.
With task
installed,
you should install development tools with task init
.
If something does not work correctly,
you can clean whole cache and re-install all development
tools with task init-clean
.
You can see all available task
tasks with task -l
.
With task
installed (see above), you may do the following:
- Format code with
task fmt
. - Run linters against code with
task lint
. - Run godocs server at 127.0.0.1:6060 to check documentation formatting with
task godocs
.
Most of the directories contains specific files for certain github actions.
The internal
directory contains some shared files for all actions.
The package tools
uses "tools.go" approach to fix tools versions.
They are installed into bin/
by cd tools; go generate -x
.
Above everything else, we value consistency in the source code. If you see some code that doesn't follow some best practice but is consistent, please keep it that way; but please also tell us about it, so we can improve all of it. If, on the other hand, you see code that is inconsistent without apparent reason (or comment), please improve it as you work on it.
Our code most of the standard Go conventions, documented on CodeReviewComments wiki page.
If you want to run unit tests locally (we highly encourage to create tests for every new functionality), please follow these steps:
- Visit https://github.com/settings/tokens and generate new personal access token (classic) with
read:org
andread:project
permissions. It will be needed to run a couple of the tests in repository. - Copy the token and use
export CONFORM_TOKEN=<token>
to set the the environment variable with your token. - Use
task test
to run all tests. Alteratively you can skip step 2 and set the variable specifically for running command:CONFORM_TOKEN=<token> task test
To test the changes on chosen repository (in this example FerretDB) you need to take a couple of steps:
- Create the PR for your change or at least push a branch for it on the forked github-actions repository.
- Fork FerretDB repository (if it's not forked yet).
- Make sure that the forked FerretDB repository has enabled github actions by going into actions tab.
- Create a branch on your forked FerretDB repository.
In
.github
directory import your actions by settinguses:
fields to "<user>/github-actions@<your-branch-name>". - Make a Pull Request for the freshly created branch. Please remember to direct it to the fork's main and not FerretDB/FerretDB's main. This Branch is only created for temporary testing and should not be placed between branches related strictly to development.
- Now you can go to the created Pull Request and see all checks in action!
Same steps can be reproduced for dance repository.
Before submitting a pull request, please make sure that:
- Tests are added for new functionality or fixed bugs.
task all
passes.- Comments are added or updated for all new and changed top-level declarations (functions, types, etc). Both exported and unexported declarations should have comments.
- Comments are rendered correctly in the
task godocs
output.