Contributing to Bark
Thank you for your interest in contributing to Bark! This guide will help you get started with the development environment and contribution workflow.Development Environment
Nix (Recommended)
You can use the Nix package manager to prepare a development environment with all necessary dependencies already packaged. We provide a Nix Flake which is tested against Linux and macOS. Use it with one of the following methods in the root directory of the bark repository: Option 1: Direct activation- Create a
.envrcfile with the following content:
- Allow direnv to load the environment:
Manual Setup
A good starting point for the dev dependencies for bark and the server is to look at the CI Dockerfile. The dependencies for Debian should be listed there.The commands below might be outdated. The Dockerfile linked above is the better reference.
Running Tests
If you’re using the Nix flake then just will come preinstalled. If you aren’t using Nix then you must manually installjust and ensure that you have bitcoind and clightning with the hold plugin in your PATH variable.
Alternatively, you can set the following environment variables:
BITCOIND_EXEC: e.g.export BITCOIND_EXEC="${PATH_TO_BITCOIND}/bin/bitcoind"LIGHTNINGD_EXEC: e.g.export LIGHTNINGD_EXEC="${PATH_TO_LIGHTNINGD}/bin/lightningd"HOLD_INVOICE_PLUGIN: e.g.export HOLD_INVOICE_PLUGIN="/hold/target/debug/hold"
PostgreSQL Setup
You also need a working PostgreSQL installation. There are two options to run the tests:Test Managed Host (Default)
The test framework will launch a new host for every test. This approach requires that the postgres-binaries such asinitdb and pg_ctl are installed on your system.
You should either add the binaries to your path or set the POSTGRES_BINS environment variable to the folder that contains them.
The nix-flake in this repository will ensure all binaries are installed correctly.
External Host (CI)
If you are running a PostgreSQL database it can be used as well. You can point theTEST_POSTGRES_HOST environment variable to your server.
The testing framework will connect using the following credentials and create a new database on the host for every test:
Running the Test Suite
Unit and integration tests are configured in the justfile and can be run using the following command:macOS Differences
On macOS we use Docker for running Core Lightning. If Docker is not installed then the lightning tests will fail. If you are not using the Nix Flake then you must set environmental variable for the Docker image to pull:Static Files
Bark Database Migrations
CI is dumping the resulting DDL into a file, and it’s comparing it withbark/schema.sql. So if you add a database migration you should also update this file.
There is a just command to generate this file:
Server Database Migrations
Just like for bark, CI is also dumping and comparing the DDL for the server database in fileserver/schema.sql. So if you add a database migration you should also update this file.
There is an equivalent just command to generate this file:
Server Default Configuration
CI is also dumping and comparing the default configuration parameters for the server using fileserver/config.default.toml. So whenever you change or add a configuration of the server you should change this file accordingly.
There is a just command to generate this file:
Code Hygiene
We use various coding conventions throughout the project which we expect contributors to follow to the best of their ability. You can view the dedicated style guide which contains the philosophy behind how we write code along with guidelines on our coding conventions.Key Principles
- Tabs for indentation
- No strict rustfmt - format for readability
- No blind clippy fixes - they can introduce bugs
- Follow bitcoin patterns and naming conventions
- Imports should be at the top of a module
- Look at surrounding code to match style
Commit Hygiene
We care about our commit history, both for historic purposes and to aid with reviewing.Commit Guidelines
- Group changes into commits that make logical sense - smaller is better than bigger
- Use descriptive commit messages:
- Prefix the title line with the subsystem you’re changing (bark, server, ci, testing, …)
- Feel free to use the body to add extra information and motivation
- Try to make all your commits individually compile (pass
just check), or even pass all tests (you can usegit rebase --interactiveto check this efficiently) - Avoid fixup commits, but prefer to squash fixups into the original commits
- Reviewers can use
git range-diffto review the fixups to each individual commit this way
- Reviewers can use
Example Commit Message
Getting Help
If you run into any issues at all, let us know:Next Steps
- Check out the Testing Guide for detailed testing instructions
- Review the Style Guide for code conventions
- Browse existing issues to find something to work on