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:unit-tests # build Cabal's unit test suite
26 cabal v2-build cabal-tests # etc...
32 **Using Github Actions and AppVeyor.**
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 and AppVeyor will build and
36 test 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 5. Is the test failing on AppVeyor? Consider logging in via
76 Remote Desktop to the build VM:
77 https://www.appveyor.com/docs/how-to/rdp-to-build-worker/
79 If none of these let you reproduce, there might be some race condition
80 or continuous integration breakage; please file a bug.
82 **Running tests locally.**
83 To run tests locally with `v2-build`, you will need to know the
84 name of the test suite you want. Cabal and cabal-install have
85 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)
87 The most important test suite is `cabal-testsuite`: most user-visible
88 changes to Cabal should come with a test in this framework. See
89 [cabal-testsuite/README.md](cabal-testsuite/README.md) for more
90 information about how to run tests and write new ones. Quick
91 start: use `cabal-tests` to run `Cabal` tests, and `cabal-tests
92 --with-cabal=/path/to/cabal` to run `cabal-install` tests
93 (don't forget `--with-cabal`! Your cabal-install tests won't
96 There are also other test suites:
98 * `Cabal:unit-tests` are small, quick-running unit tests
99 on small pieces of functionality in Cabal. If you are working
100 on some utility functions in the Cabal library you should run this
103 * `cabal-install:unit-tests` are small, quick-running unit tests on
104 small pieces of functionality in cabal-install. If you are working
105 on some utility functions in cabal-install you should run this test
108 * `cabal-install:long-tests` are QuickCheck tests on
109 cabal-install's dependency solver, VCS, and file monitoring code.
110 If you are working on the solver you should run this test suite.
112 * `cabal-install:integration-tests2` are integration tests on some
113 top-level API functions inside the `cabal-install` source code.
115 For these test executables, `-p` which applies a regex filter to the test
116 names. When running `cabal-install` test suites, one need only use `cabal test` or
117 `cabal run <test-target>` in order to test locally.
125 * Try to follow style conventions of a file you are modifying, and
126 avoid gratuitous reformatting (it makes merges harder!)
128 * Format your commit messages [in the standard way](https://chris.beams.io/posts/git-commit/#seven-rules).
130 * A lot of Cabal does not have top-level comments. We are trying to
131 fix this. If you add new top-level definitions, please Haddock them;
132 and if you spend some time understanding what a function does, help
133 us out and add a comment. We'll try to remind you during code review.
135 * If you do something tricky or non-obvious, add a comment.
137 * If your commit only touches comments, you can use `[ci skip]`
138 anywhere in the body of the commit message to avoid needlessly
139 triggering the build bots.
141 * For local imports (Cabal module importing Cabal module), import lists
142 are NOT required (although you may use them at your discretion.) For
143 third-party and standard library imports, please use either qualified imports
144 or explicit import lists.
146 * You can use basically any GHC extension supported by a GHC in our
147 support window, except Template Haskell, which would cause
148 bootstrapping problems in the GHC compilation process.
150 * Our GHC support window is five years for the Cabal library and three
151 years for cabal-install: that is, the Cabal library must be
152 buildable out-of-the-box with the dependencies that shipped with GHC
153 for at least five years. The Travis CI checks this, so most
154 developers submit a PR to see if their code works on all these
155 versions of GHC. `cabal-install` must also be buildable on all
156 supported GHCs, although it does not have to be buildable
157 out-of-the-box. Instead, the `cabal-install/bootstrap.sh` script
158 must be able to download and install all of the dependencies (this
159 is also checked by CI). Also, self-upgrade to the latest version
160 (i.e. `cabal install cabal-install`) must work with all versions of
161 `cabal-install` released during the last three years.
163 * `Cabal` has its own Prelude, in `Distribution.Compat.Prelude`,
164 that provides a compatibility layer and exports some commonly
165 used additional functions. Use it in all new modules.
167 * As far as possible, please do not use CPP. If you must use it,
168 try to put it in a `Compat` module, and minimize the amount of code
169 that is enclosed by CPP. For example, prefer:
172 #ifdef mingw32_HOST_OS
181 #ifdef mingw32_HOST_OS
190 We like [this style guide][guide].
192 [guide]: https://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.md
197 When opening a pull request, you should write a changelog entry.
198 This is done by adding a file in the `changelog.d` directory.
200 The files follow a simple key-value format similar to the one for .cabal files.
202 Here's an exhaustive example:
205 synopsis: Add feature xyz
206 packages: cabal-install
209 significance: significant
219 Only the `synopsis` field is actually required, but you should also set the others where applicable.
221 | Field | Description |
222 | ----- | ----------- |
223 | `synopsis` | Brief description of the change. Often just the pr title. |
224 | `description` | Longer description, with a list of sub-changes. Not needed for small/atomic changes. |
225 | `packages` | Packages affected by the change (`cabal-install`, `Cabal`...). Omit if it's an overarching or non-package change. |
226 | `prs` | Space-separated hash-prefixed pull request numbers containing the change (usually just one). |
227 | `issues` | Space-separated hash-prefixed issue numbers that the change fixes/closes/affects. |
228 | `significance` | Set to `significant` if the change is significant, that is if it warrants being put near the top of the changelog. |
230 You can find a large number of real-world examples of changelog files
231 [here](https://github.com/haskell/cabal/tree/bc83de27569fda22dbe1e10be1a921bebf4d3430/changelog.d).
233 At release time, the entries will be merged with
234 [this tool](https://github.com/phadej/changelog-d).
239 There are a few main venues of communication:
241 * 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.
243 * For more organizational concerns, the [mailing
244 list](http://www.haskell.org/mailman/listinfo/cabal-devel) is used.
246 * Many developers idle on `#hackage` on `irc.freenode.net` ([archives](http://ircbrowse.net/browse/hackage)). `#ghc` ([archives](http://ircbrowse.net/browse/ghc)) is also a decently good bet.
251 Notes for how to make a release are at the
252 wiki page ["Making a release"](https://github.com/haskell/cabal/wiki/Making-a-release).
253 Currently, @23Skidoo, @rthomas, @tibbe and @dcoutts have access to
254 `haskell.org/cabal`, and @davean is the point of contact for getting
260 Auto-generated API documentation for the `master` branch of Cabal is automatically uploaded here: http://haskell.github.io/cabal-website/doc/html/Cabal/.
262 ## Issue triage [![Open Source Helpers](https://www.codetriage.com/haskell/cabal/badges/users.svg)](https://www.codetriage.com/haskell/cabal)
264 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).