1
- ***********************************************
2
- Contributing to the `` cardano-db-sync `` project
3
- ***********************************************
1
+ *******************************
2
+ Contributing to Cardano DB Sync
3
+ *******************************
4
4
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
8
6
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
+ =================
12
9
13
- Roles and Responsibilities
14
- ==========================
10
+ Nix
11
+ ---
15
12
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.
19
15
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
22
27
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
24
35
--------
25
36
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.
29
140
30
141
Updating Dependencies
31
142
=====================
@@ -46,7 +157,7 @@ will also need to pull in the Nix equivalent of the newer ``index-state``. You
46
157
can do this by running ``nix flake lock --update-input hackageNix ``.
47
158
48
159
From the Cardano Haskell Package repository
49
- ---------------------------------------------
160
+ -------------------------------------------
50
161
51
162
Many Cardano packages are not on Hackage and are instead in the `Cardano Haskell
52
163
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
56
167
afterwards: ``nix flake lock --update-input CHaP ``.
57
168
58
169
Using unreleased versions of dependencies
59
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
170
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
60
171
61
172
Sometimes we need to use an unreleased version of one of our dependencies,
62
173
either to fix an issue in a package that is not under our control, or to
@@ -77,6 +188,15 @@ Releasing a New Version
77
188
78
189
See `<doc/release-process.md >`__
79
190
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
80
201
.. _CODEOWNERS : https://github.com/IntersectMBO/cardano-db-sync/blob/master/CODEOWNERS
81
202
.. _cardano-haskell-packages : https://github.com/IntersectMBO/cardano-haskell-packages
82
- .. _fourmolu : https://github.com/fourmolu/fourmolu
0 commit comments