Skip to content

Commit d302eeb

Browse files
sgillespiekderme
authored andcommitted
doc: Restructure Contributing guide
1 parent 95082a3 commit d302eeb

File tree

1 file changed

+143
-23
lines changed

1 file changed

+143
-23
lines changed

CONTRIBUTING.rst

Lines changed: 143 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,142 @@
1-
***********************************************
2-
Contributing to the ``cardano-db-sync`` project
3-
***********************************************
1+
*******************************
2+
Contributing to Cardano DB Sync
3+
*******************************
44

5-
The ``cardano-db-sync`` development is primarily based on the Nix infrastructure
6-
(https://nixos.org/ ), which enables packaging, CI, development environments and
7-
deployments.
5+
.. contents:: Table of Contents
86

9-
On how to set up Nix for ``cardano-db-sync`` development, please see `Building Cardano
10-
Node with nix
11-
<https://github.com/IntersectMBO/cardano-node/tree/master/doc/getting-started/building-the-node-using-nix.md>`_.
7+
Development Tools
8+
=================
129

13-
Roles and Responsibilities
14-
==========================
10+
Nix
11+
---
1512

16-
We maintain a `CODEOWNERS file <CODEOWNERS_>`_ which provides information who
17-
should review a contributing PR. Note that you might need to get approvals
18-
from all code owners (even though GitHub doesn't give a way to enforce it).
13+
Cardano DB Sync development is primarily based on Nix in order to provision the complete
14+
toolchain needed to build all repository artifacts.
1915

20-
Supplementary Tooling
21-
=====================
16+
For instructions on how to install and configure Nix, please refer to *Configure Nix* in
17+
`Installing With Nix <installing-with-nix_>`_.
18+
19+
Once Nix is installed and configured, enter a development shell by running::
20+
21+
nix develop .
22+
23+
Developing Without Nix
24+
----------------------
25+
26+
It is possible to build and run DB Sync without Nix, but
2227

23-
Fourmolu
28+
* We rely on forked or new versions of system libraries
29+
* Building will use system GHC and libraries
30+
31+
For instruction on how to set up a development environment without Nix, please refer to
32+
*Install Dependencies* in `Installing from Source <installing_>`_.
33+
34+
Building
2435
--------
2536

26-
`Fourmolu <fourmolu_>`_ is our formatter of choice, version 0.10.1.0. We have a
27-
script `scripts/fourmolize.sh` that can be run once fourmolu is installed
28-
locally.
37+
In development shell, DB Sync can be built by running::
38+
39+
cabal build all
40+
41+
Testing
42+
-------
43+
44+
We have to classes of test-suites, unit/property tests and database integration tests. To
45+
run the unit/property tests::
46+
47+
cabal test cardano-db-sync
48+
cabal test cardano-db:test:test
49+
50+
To run the database integration tests::
51+
52+
cabal test cardano-chain-gen:test:cardano-chain-gen
53+
cabal test cardano-db:test:test-db
54+
55+
To run a subset of tests::
56+
57+
cabal run cardano-chain-gen:test:cardano-chaingen -- --pattern "Babbage unit tests.consumed-tx-out"
58+
59+
Profiling
60+
---------
61+
62+
Profiled builds are only available with Nix::
63+
64+
nix build .#profiled.cardano-db-sync
65+
nix build .#profiled.cardano-smash-server
66+
67+
Once this is built, run the executable with profiling::
68+
69+
./result/cardano-db-sync <args> +RTS -p -h -RTS
70+
71+
haskell-language-server
72+
-----------------------
73+
74+
The recommended way to use haskell-language-server is with `direnv`_. The nix
75+
development shell provides the haskell-language-server binary for the correct version of
76+
GHC. direnv allows your editor to use the nix shell.
77+
78+
To enable direnv, run::
79+
80+
echo "use flake" > .envrc
81+
direnv allow
82+
83+
Then use the appropriate editor extension:
84+
85+
* Visual Studio Code: `Nix VS Code Extension Pack <nix-extension-pack_>`_
86+
* Vim: `direnv.vim`_
87+
* Emacs: `direnv-mode`_
88+
89+
Hoogle Server
90+
-------------
91+
92+
To start a local Hoogle with all dependencies, run::
93+
94+
nix develop .#ghc96 --command hoogle server --local --port 8000
95+
96+
Conventions
97+
===========
98+
99+
Formatting
100+
----------
101+
102+
We use `Fourmolu <fourmolu_>_`, version 0.10.1.0, for Haskell code formatting. The
103+
executable is provided by the nix development shell. To apply the formatting rules to all
104+
modifyied files, run::
105+
106+
./script/fourmolize.sh
107+
108+
To run the checks via nix, run::
109+
110+
nix build .#checks.<cpu_arch>.fourmolu
111+
112+
Linting
113+
-------
114+
115+
We use `HLint <hlint_>` for Haskell static code analysis, and `Shellcheck <shellcheck_>`_
116+
for shell scripts. To run the checks via nix, run::
117+
118+
nix build .#checks.<cpu_arch>.hlint
119+
nix build .#checks.<cpu_arch>.shellcheck
120+
121+
Communication
122+
=============
123+
124+
You can discuss development or find help at the following places:
125+
126+
* Intersect Discord `#db-sync <discord_>`_ channel, if new to server invite `here <discord-invite_>`
127+
* `GitHub Issues <issues_>`_
128+
129+
Roles and Responsibilities
130+
==========================
131+
132+
Regular contributors, all of whom can review and merge PRs are:
133+
134+
* @kderme
135+
* @Cmdv
136+
* @sgillespie
137+
138+
In addition, the `CODEOWNERS file <CODEOWNERS_>`_ provides information on who should
139+
review a contributing PR.
29140

30141
Updating Dependencies
31142
=====================
@@ -46,7 +157,7 @@ will also need to pull in the Nix equivalent of the newer ``index-state``. You
46157
can do this by running ``nix flake lock --update-input hackageNix``.
47158

48159
From the Cardano Haskell Package repository
49-
---------------------------------------------
160+
-------------------------------------------
50161

51162
Many Cardano packages are not on Hackage and are instead in the `Cardano Haskell
52163
Package repository <cardano-haskell-packages_>`_ (CHaP), see the README for
@@ -56,7 +167,7 @@ getting them from Hackage. The differences are that it has an independent
56167
afterwards: ``nix flake lock --update-input CHaP``.
57168

58169
Using unreleased versions of dependencies
59-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
170+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
60171

61172
Sometimes we need to use an unreleased version of one of our dependencies,
62173
either to fix an issue in a package that is not under our control, or to
@@ -77,6 +188,15 @@ Releasing a New Version
77188

78189
See `<doc/release-process.md>`__
79190

191+
.. _installing-with-nix: doc/installing-with-nix.md
192+
.. _installing: doc/installing.md#install-dependencies
193+
.. _direnv: https://direnv.net/
194+
.. _direnv-mode: https://github.com/wbolster/emacs-direnv
195+
.. _direnv.vim: https://github.com/direnv/direnv.vim
196+
.. _nix-extension-pack: https://marketplace.visualstudio.com/items?itemName=pinage404.nix-extension-pack
197+
.. _fourmolu: https://github.com/fourmolu/fourmolu
198+
.. _discord: https://discord.com/channels/1136727663583698984/1239888910537064468
199+
.. _discord-invite: https://discord.gg/3DYwebJv
200+
.. _issues: https://github.com/IntersectMBO/cardano-db-sync/issues
80201
.. _CODEOWNERS: https://github.com/IntersectMBO/cardano-db-sync/blob/master/CODEOWNERS
81202
.. _cardano-haskell-packages: https://github.com/IntersectMBO/cardano-haskell-packages
82-
.. _fourmolu: https://github.com/fourmolu/fourmolu

0 commit comments

Comments
 (0)