1 # Contributing to Cabal
3 Building Cabal for hacking
4 --------------------------
6 The current recommended way of developing Cabal is to use the
7 `v2-build` feature which [shipped in cabal-install-1.24](http://blog.ezyang.com/2016/05/announcing-cabal-new-build-nix-style-local-builds/). Assuming
8 that you have a sufficiently recent cabal-install (see above),
9 it is sufficient to run:
15 To build a local, development copy of cabal-install. The location
16 of your build products will vary depending on which version of
17 cabal-install you use to build; see the documentation section
18 [Where are my build products?](http://cabal.readthedocs.io/en/latest/nix-local-build.html#where-are-my-build-products)
19 to find the binary (or just run `find -type f -executable -name cabal`).
21 Here are some other useful variations on the commands:
24 cabal v2-build Cabal # build library only
25 cabal v2-build Cabal-tests:unit-tests # build Cabal's unit test suite
26 cabal v2-build cabal-tests # etc...
32 **Using Github Actions.**
33 If you are not in a hurry, the most convenient way to run tests on Cabal
34 is to make a branch on GitHub and then open a pull request; our
35 continuous integration service on Github Actions builds and
36 tests your code. Title your PR with WIP so we know that it does not need
39 Some tips for using Github Actions effectively:
41 * Github Actions builds take a long time. Use them when you are pretty
42 sure everything is OK; otherwise, try to run relevant tests locally
45 * Watch over your jobs on the [Github Actions website](http://github.org/haskell/cabal/actions).
46 If you know a build of yours is going to fail (because one job has
47 already failed), be nice to others and cancel the rest of the jobs,
48 so that other commits on the build queue can be processed.
50 **How to debug a failing CI test.**
51 One of the annoying things about running tests on CI is when they
52 fail, there is often no easy way to further troubleshoot the broken
53 build. Here are some guidelines for debugging continuous integration
56 1. Can you tell what the problem is by looking at the logs? The
57 `cabal-testsuite` tests run with `-v` logging by default, which
58 is dumped to the log upon failure; you may be able to figure out
59 what the problem is directly this way.
61 2. Can you reproduce the problem by running the test locally?
62 See the next section for how to run the various test suites
63 on your local machine.
65 3. Is the test failing only for a specific version of GHC, or
66 a specific operating system? If so, try reproducing the
67 problem on the specific configuration.
69 4. Is the test failing on a Github Actions per-GHC build.
70 In this case, if you click on "Branch", you can get access to
71 the precise binaries that were built by Github Actions that are being
72 tested. If you have an Ubuntu system, you can download
73 the binaries and run them directly.
75 If none of these let you reproduce, there might be some race condition
76 or continuous integration breakage; please file a bug.
78 **Running tests locally.**
79 To run tests locally with `v2-build`, you will need to know the
80 name of the test suite you want. Cabal and cabal-install have
81 several. Also, you'll want to read [Where are my build products?](http://cabal.readthedocs.io/en/latest/nix-local-build.html#where-are-my-build-products)
83 The most important test suite is `cabal-testsuite`: most user-visible
84 changes to Cabal should come with a test in this framework. See
85 [cabal-testsuite/README.md](cabal-testsuite/README.md) for more
86 information about how to run tests and write new ones. Quick
87 start: use `cabal-tests` to run `Cabal` tests, and `cabal-tests
88 --with-cabal=/path/to/cabal` to run `cabal-install` tests
89 (don't forget `--with-cabal`! Your cabal-install tests won't
92 There are also other test suites:
94 * `Cabal-tests:unit-tests` are small, quick-running unit tests
95 on small pieces of functionality in Cabal. If you are working
96 on some utility functions in the Cabal library you should run this
99 * `cabal-install:unit-tests` are small, quick-running unit tests on
100 small pieces of functionality in cabal-install. If you are working
101 on some utility functions in cabal-install you should run this test
104 * `cabal-install:long-tests` are QuickCheck tests on
105 cabal-install's dependency solver, VCS, and file monitoring code.
106 If you are working on the solver you should run this test suite.
108 * `cabal-install:integration-tests2` are integration tests on some
109 top-level API functions inside the `cabal-install` source code.
111 For these test executables, `-p` which applies a regex filter to the test
112 names. When running `cabal-install` test suites, one need only use `cabal test` or
113 `cabal run <test-target>` in order to test locally.
121 * Try to follow style conventions of a file you are modifying, and
122 avoid gratuitous reformatting (it makes merges harder!)
124 * Format your commit messages [in the standard way](https://chris.beams.io/posts/git-commit/#seven-rules).
126 * A lot of Cabal does not have top-level comments. We are trying to
127 fix this. If you add new top-level definitions, please Haddock them;
128 and if you spend some time understanding what a function does, help
129 us out and add a comment. We'll try to remind you during code review.
131 * If you do something tricky or non-obvious, add a comment.
133 * For local imports (Cabal module importing Cabal module), import lists
134 are NOT required (although you may use them at your discretion.) For
135 third-party and standard library imports, please use either qualified imports
136 or explicit import lists.
138 * You can use basically any GHC extension supported by a GHC in our
139 support window, except Template Haskell, which would cause
140 bootstrapping problems in the GHC compilation process.
142 * Our GHC support window is five years for the Cabal library and three
143 years for cabal-install: that is, the Cabal library must be
144 buildable out-of-the-box with the dependencies that shipped with GHC
145 for at least five years. The Travis CI checks this, so most
146 developers submit a PR to see if their code works on all these
147 versions of GHC. `cabal-install` must also be buildable on all
148 supported GHCs, although it does not have to be buildable
149 out-of-the-box. Instead, the `cabal-install/bootstrap.sh` script
150 must be able to download and install all of the dependencies (this
151 is also checked by CI). Also, self-upgrade to the latest version
152 (i.e. `cabal install cabal-install`) must work with all versions of
153 `cabal-install` released during the last three years.
155 * `Cabal` has its own Prelude, in `Distribution.Compat.Prelude`,
156 that provides a compatibility layer and exports some commonly
157 used additional functions. Use it in all new modules.
159 * As far as possible, please do not use CPP. If you must use it,
160 try to put it in a `Compat` module, and minimize the amount of code
161 that is enclosed by CPP. For example, prefer:
164 #ifdef mingw32_HOST_OS
173 #ifdef mingw32_HOST_OS
182 We like [this style guide][guide].
184 [guide]: https://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.md
189 Each major `Cabal`/`cabal-install` release (e.g. 3.4, 3.6, etc.) has a
190 corresponding GitHub Project and milestone. A ticket is included in a release's
191 project if the release managers are tenatively planning on including a fix for
192 the ticket in the release, i.e. if they are actively seeking someone to work on
195 By contrast, a ticket is milestoned to a given release if we are open to
196 accepting a fix in that release, i.e. we would very much appreciate someone
197 working on it, but are not committing to actively sourcing someone to work on
203 When opening a pull request, you should write a changelog entry
204 (or more in case of multiple independent changes).
205 This is done by adding files in the `changelog.d` directory.
207 The files follow a simple key-value format similar to the one for .cabal files.
209 Here's an exhaustive example:
212 synopsis: Add feature xyz
213 packages: cabal-install
216 significance: significant
226 Only the `synopsis` field is actually required, but you should also set the others where applicable.
228 | Field | Description |
229 | ----- | ----------- |
230 | `synopsis` | Brief description of the change. Often just the pr title. |
231 | `description` | Longer description, with a list of sub-changes. Not needed for small/atomic changes. |
232 | `packages` | Packages affected by the change (`cabal-install`, `Cabal`...). Omit if it's an overarching or non-package change. |
233 | `prs` | Space-separated hash-prefixed pull request numbers containing the change (usually just one). |
234 | `issues` | Space-separated hash-prefixed issue numbers that the change fixes/closes/affects. |
235 | `significance` | Set to `significant` if the change is significant, that is if it warrants being put near the top of the changelog. |
237 You can find a large number of real-world examples of changelog files
238 [here](https://github.com/haskell/cabal/tree/bc83de27569fda22dbe1e10be1a921bebf4d3430/changelog.d).
240 At release time, the entries will be merged with
241 [this tool](https://github.com/phadej/changelog-d).
243 In addition, if you're changing the .cabal file format specification you should
244 add an entry in `doc/file-format-changelog.rst`.
249 There are a few main venues of communication:
251 * Most developers subscribe to receive messages from [all issues](https://github.com/haskell/cabal/issues); issues can be used to [open discussion](https://github.com/haskell/cabal/issues?q=is%3Aissue+is%3Aopen+custom+label%3A%22type%3A+discussion%22). If you know someone who should hear about a message, CC them explicitly using the @username GitHub syntax.
253 * For more organizational concerns, the [mailing
254 list](http://www.haskell.org/mailman/listinfo/cabal-devel) is used.
256 * Many developers idle on `#hackage` on [`irc.libera.chat`](https://libera.chat). The `#ghc` channel is also a decently good bet.
257 * You can join the channel using a web client, even anonymously: https://web.libera.chat/#hackage
258 * Alternatively you can join it using [matrix](https://matrix.org/): https://matrix.to/#/#hackage:libera.chat
263 Notes for how to make a release are at the
264 wiki page ["Making a release"](https://github.com/haskell/cabal/wiki/Making-a-release).
265 Currently, [@emilypi](https://github.com/emilypi), [@fgaz](https://github.com/fgaz) and [@Mikolaj](https://github.com/Mikolaj) have access to
266 `haskell.org/cabal`, and [@Mikolaj](https://github.com/Mikolaj) is the point of contact for getting
272 Auto-generated API documentation for the `master` branch of Cabal is automatically uploaded here: http://haskell.github.io/cabal-website/doc/html/Cabal/.
274 ## Issue triage [![Open Source Helpers](https://www.codetriage.com/haskell/cabal/badges/users.svg)](https://www.codetriage.com/haskell/cabal)
276 You can contribute by triaging issues which may include reproducing bug reports or asking for vital information, such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to cabal on CodeTriage](https://www.codetriage.com/haskell/cabal).