1 # Contributing to Cabal
3 Building Cabal for hacking
4 --------------------------
6 If you use the latest version of cabal published on Hackage, it is sufficient to run:
12 If not, you aren't able to build the testsuite, so you need to disable the default `cabal.project` that implies configuring the testsuite, e.g., with:
15 cabal build --project-file=cabal.project.release cabal
18 The location of your build products will vary depending on which version of
19 cabal-install you use to build; see the documentation section
20 [Where are my build products?](http://cabal.readthedocs.io/en/latest/nix-local-build.html#where-are-my-build-products)
21 to find the binary (or just run `find -type f -executable -name cabal`).
23 Here are some other useful variations on the commands:
26 cabal build Cabal # build library only
27 cabal build Cabal-tests:unit-tests # build Cabal's unit test suite
28 cabal build cabal-tests # etc...
34 **Using Github Actions.**
35 If you are not in a hurry, the most convenient way to run tests on Cabal
36 is to make a branch on GitHub and then open a pull request; our
37 continuous integration service on Github Actions builds and
38 tests your code. Title your PR with WIP so we know that it does not need
41 Some tips for using Github Actions effectively:
43 * Github Actions builds take a long time. Use them when you are pretty
44 sure everything is OK; otherwise, try to run relevant tests locally
47 * Watch over your jobs on the [Github Actions website](http://github.org/haskell/cabal/actions).
48 If you know a build of yours is going to fail (because one job has
49 already failed), be nice to others and cancel the rest of the jobs,
50 so that other commits on the build queue can be processed.
52 **How to debug a failing CI test.**
53 One of the annoying things about running tests on CI is when they
54 fail, there is often no easy way to further troubleshoot the broken
55 build. Here are some guidelines for debugging continuous integration
58 1. Can you tell what the problem is by looking at the logs? The
59 `cabal-testsuite` tests run with `-v` logging by default, which
60 is dumped to the log upon failure; you may be able to figure out
61 what the problem is directly this way.
63 2. Can you reproduce the problem by running the test locally?
64 See the next section for how to run the various test suites
65 on your local machine.
67 3. Is the test failing only for a specific version of GHC, or
68 a specific operating system? If so, try reproducing the
69 problem on the specific configuration.
71 4. Is the test failing on a Github Actions per-GHC build.
72 In this case, if you click on "Branch", you can get access to
73 the precise binaries that were built by Github Actions that are being
74 tested. If you have an Ubuntu system, you can download
75 the binaries and run them directly.
77 If none of these let you reproduce, there might be some race condition
78 or continuous integration breakage; please file a bug.
80 **Running tests locally.**
81 To run tests locally with `cabal`, you will need to know the
82 name of the test suite you want. Cabal and cabal-install have
83 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)
85 The most important test suite is `cabal-testsuite`: most user-visible
86 changes to Cabal should come with a test in this framework. See
87 [cabal-testsuite/README.md](cabal-testsuite/README.md) for more
88 information about how to run tests and write new ones. Quick
89 start: use `cabal-tests` to run `Cabal` tests, and `cabal-tests
90 --with-cabal=/path/to/cabal` to run `cabal-install` tests
91 (don't forget `--with-cabal`! Your cabal-install tests won't
94 There are also other test suites:
96 * `Cabal-tests:unit-tests` are small, quick-running unit tests
97 on small pieces of functionality in Cabal. If you are working
98 on some utility functions in the Cabal library you should run this
101 * `cabal-install:unit-tests` are small, quick-running unit tests on
102 small pieces of functionality in cabal-install. If you are working
103 on some utility functions in cabal-install you should run this test
106 * `cabal-install:long-tests` are QuickCheck tests on
107 cabal-install's dependency solver, VCS, and file monitoring code.
108 If you are working on the solver you should run this test suite.
110 * `cabal-install:integration-tests2` are integration tests on some
111 top-level API functions inside the `cabal-install` source code.
113 For these test executables, `-p` which applies a regex filter to the test
114 names. When running `cabal-install` test suites, one need only use `cabal test` or
115 `cabal run <test-target>` in order to test locally.
120 Manual Quality Assurance (QA) is performed to ensure that the changes impacting
121 the command-line interface, whether adding or modifying a behaviour,
122 are tested before being released. This allows us to catch UX regressions and put
123 a human perspective into testing.
125 Contributions that touch `cabal-install` are expected to include notes for the QA team.
126 They are a description of an expected result upon calling `cabal-install` with certain parameters,
127 and should be written in the body of the ticket or PR under their own heading, like this:
133 > Calling `cabal haddock-project` should produce documentation for the whole cabal project with the following defaults enabled:
134 > * Documentation lives in ./haddocks
135 > * The file `./haddocks/index.html` should exist
137 Manual QA is not expected to find every possible bug, but to really challenge the assumptions of the contributor, and to verify that their own testing
138 of their patch is not influenced by their setup or implicit knowledge of the system.
144 We use automated formatting with Fourmolu to enforce a unified style across the code bases. It is checked in the CI process.
145 After installing Fourmolu 0.12, you can automatically format the code bases with `make style` at the top level of the project.
146 You can also use `make style-modified` to only format modified files.
151 * Format your commit messages [in the standard way](https://chris.beams.io/posts/git-commit/#seven-rules).
153 * A lot of Cabal does not have top-level comments. We are trying to
154 fix this. If you add new top-level definitions, please Haddock them;
155 and if you spend some time understanding what a function does, help
156 us out and add a comment. We'll try to remind you during code review.
158 * If you do something tricky or non-obvious, add a comment.
160 * For local imports (Cabal module importing Cabal module), import lists
161 are NOT required (although you may use them at your discretion.) For
162 third-party and standard library imports, please use either qualified imports
163 or explicit import lists.
165 * You can use basically any GHC extension supported by a GHC in our
166 support window, except Template Haskell, which would cause
167 bootstrapping problems in the GHC compilation process.
169 * Our GHC support window is five years for the Cabal library and three
170 years for cabal-install: that is, the Cabal library must be
171 buildable out-of-the-box with the dependencies that shipped with GHC
172 for at least five years. The Travis CI checks this, so most
173 developers submit a PR to see if their code works on all these
174 versions of GHC. `cabal-install` must also be buildable on all
175 supported GHCs, although it does not have to be buildable
176 out-of-the-box. Instead, the `cabal-install/bootstrap.sh` script
177 must be able to download and install all of the dependencies (this
178 is also checked by CI). Also, self-upgrade to the latest version
179 (i.e. `cabal install cabal-install`) must work with all versions of
180 `cabal-install` released during the last three years.
182 * `Cabal` has its own Prelude, in `Distribution.Compat.Prelude`,
183 that provides a compatibility layer and exports some commonly
184 used additional functions. Use it in all new modules.
186 * As far as possible, please do not use CPP. If you must use it,
187 try to put it in a `Compat` module, and minimize the amount of code
188 that is enclosed by CPP. For example, prefer:
191 #ifdef mingw32_HOST_OS
200 #ifdef mingw32_HOST_OS
209 GitHub Ticket Conventions
212 Each major `Cabal`/`cabal-install` release (e.g. 3.4, 3.6, etc.) has a
213 corresponding GitHub Project and milestone. A ticket is included in a release's
214 project if the release managers are tenatively planning on including a fix for
215 the ticket in the release, i.e. if they are actively seeking someone to work on
218 By contrast, a ticket is milestoned to a given release if we are open to
219 accepting a fix in that release, i.e. we would very much appreciate someone
220 working on it, but are not committing to actively sourcing someone to work on
223 GitHub Pull Request Conventions
226 Every (non-backport) pull request has to go through a review and get 2
227 approvals. After this is done, the author of the pull request is expected to add
228 any final touches they deem important and put the `merge me` label on the pull
229 request. If the author lacks permissions to apply labels, they are welcome to
230 explicitly signal the merge intent on the discussion thread of the pull request,
231 at which point others (e.g., reviewers) apply the label. Merge buttons are
232 reserved for exceptional situations, e.g., CI fixes being iterated on or
233 backports/patches that need to be expedited for a release.
235 Currently there is a 2 day buffer for potential extra feedback between the last
236 update of a pull request (e.g. a commit, a rebase, an addition of the `merge me`
237 label) and the moment the Mergify bot picks up the pull request for a merge.
239 If your pull request consists of several commits, consider using `squash+merge
240 me` instead of `merge me`: the Mergify bot will squash all the commits into one
241 and concatenate the commit messages of the commits before merging.
246 When opening a pull request with a user-visible change, you should write one changelog entry
247 (or more in case of multiple independent changes) — the information will end up in
250 Changelogs for the next release are stored in the `changelog.d` directory.
251 The files follow a simple key-value format similar to the one for `.cabal` files.
252 Free-form text fields (`synopsis` and `description`) allow Markdown markup — please,
253 use markup to make our release notes more readable.
258 synopsis: Add feature xyz
259 packages: cabal-install
262 significance: significant
272 Only the `synopsis` field is actually required, but you should also set the others where applicable.
274 | Field | Description |
275 | ----- | ----------- |
276 | `synopsis` | Brief description of the change. Often just the pr title. |
277 | `description` | Longer description, with a list of sub-changes. Not needed for small/atomic changes. |
278 | `packages` | Packages affected by the change (`cabal-install`, `Cabal`...). Omit if it's an overarching or non-package change. |
279 | `prs` | Space-separated hash-prefixed pull request numbers containing the change (usually just one). |
280 | `issues` | Space-separated hash-prefixed issue numbers that the change fixes/closes/affects. |
281 | `significance` | Set to `significant` if the change is significant, that is if it warrants being put near the top of the changelog. |
283 You can find a large number of real-world examples of changelog files
284 [here](https://github.com/haskell/cabal/tree/bc83de27569fda22dbe1e10be1a921bebf4d3430/changelog.d).
286 At release time, the entries will be merged with
287 [this tool](https://github.com/fgaz/changelog-d).
289 In addition, if you're changing the `.cabal` file format specification you should
290 add an entry in `doc/file-format-changelog.rst`.
295 There are a few main venues of communication:
297 * 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.
299 * For more organizational concerns, the [mailing
300 list](http://www.haskell.org/mailman/listinfo/cabal-devel) is used.
302 * Many developers idle on `#hackage` on [`irc.libera.chat`](https://libera.chat). The `#ghc` channel is also a decently good bet.
303 * You can join the channel using a web client, even anonymously: https://web.libera.chat/#hackage
304 * Alternatively you can join it using [matrix](https://matrix.org/): https://matrix.to/#/#hackage:libera.chat
309 Notes for how to make a release are at the
310 wiki page ["Making a release"](https://github.com/haskell/cabal/wiki/Making-a-release).
311 Currently, [@emilypi](https://github.com/emilypi), [@fgaz](https://github.com/fgaz) and [@Mikolaj](https://github.com/Mikolaj) have access to
312 `haskell.org/cabal`, and [@Mikolaj](https://github.com/Mikolaj) is the point of contact for getting
318 Auto-generated API documentation for the `master` branch of Cabal is automatically uploaded here: http://haskell.github.io/cabal-website/doc/html/Cabal/.
320 ## Issue triage [![Open Source Helpers](https://www.codetriage.com/haskell/cabal/badges/users.svg)](https://www.codetriage.com/haskell/cabal)
322 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).