Skip to content

Commit f01ea88

Browse files
committed
Trim README
1 parent 06a10a8 commit f01ea88

File tree

1 file changed

+22
-265
lines changed

1 file changed

+22
-265
lines changed

README.md

Lines changed: 22 additions & 265 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,14 @@
1-
Multiple [GHC](http://haskell.org/ghc) Versions for [Travis-CI](https://travis-ci.org) [![Build](https://img.shields.io/travis/haskell-CI/haskell-ci.svg)](https://travis-ci.org/haskell-CI/haskell-ci)
2-
============================================================
1+
haskell-ci - CI generator for multiple [GHC](http://haskell.org/ghc) versions
2+
=============================================================================
33

4-
The purpose of this document is to describe how to set up the [`.travis.yml` script](http://about.travis-ci.org/docs/user/build-configuration/) in order to build and test your [cabalized](http://www.haskell.org/cabal) Haskell package with multiple [GHC](http://haskell.org/ghc) configurations.
5-
At time of writing [Travis-CI](https://travis-ci.org/) has [support for building Haskell packages](http://about.travis-ci.org/docs/user/languages/haskell/) but only for a single GHC configuration (i.e. *Haskell Platform 2012.2.0.0 with GHC 7.4.1*). By following this guide, you can set up [Travis-CI](https://travis-ci.org/) jobs which have access to the following GHC versions (all compiled for *Ubuntu Linux 12.04 LTS 64-bit*):
4+
At the moment `haskell-ci` support GitHub Actions workflow generation.
5+
There is also legacy Travis-CI configuration generator, which is unmaintained.
66

7-
- GHC 6.12.3,
8-
- GHC 7.0.1, GHC 7.0.2, GHC 7.0.3, GHC 7.0.4,
9-
- GHC 7.2.1, GHC 7.2.2,
10-
- GHC 7.4.1, GHC 7.4.2,
11-
- GHC 7.6.1, GHC 7.6.2, GHC 7.6.3,
12-
- GHC 7.8.1, GHC 7.8.2, GHC 7.8.3, GHC 7.8.4
13-
- GHC 7.10.1, GHC 7.10.2, GHC 7.10.3
14-
- GHC 8.0.1, GHC 8.0.2
15-
- GHC 8.2.1, GHC 8.2.2
16-
- GHC 8.4.1, GHC 8.4.2, GHC 8.4.3, GHC 8.4.4
17-
- GHC 8.6.1, GHC 8.6.2, GHC 8.6.3, GHC 8.6.4, GHC 8.6.5
18-
- GHC 8.8.1, GHC 8.8.2, GHC 8.8.3, GHC-8.8.4
19-
- GHC 8.10.1, GHC-8.10.2, GHC-8.10.3, GHC-8.10.4
20-
- GHC 9.0.1
21-
- GHC HEAD.
7+
`haskell-ci` relies on [`hvr-ppa`](https://launchpad.net/~hvr/+archive/ubuntu/ghc)
8+
or [`ghcup`](https://www.haskell.org/ghcup/) to install GHC
9+
and `cabal-install`.
2210

23-
Each GHC version is provided in a separate `ghc-<version>` `.deb` package installing into `/opt/ghc/<version>` (thus allowing to be installed at the same time if needed) published in a [PPA](https://launchpad.net/~hvr/+archive/ghc). The easiest way to "activate" a particular GHC version is to prepend its `bin`-folder to the `$PATH` environment variable (see example in next section).
24-
25-
Note: For actually enabling continuous integration for a GitHub hosted project, see section [Getting Started](http://about.travis-ci.org/docs/user/getting-started/) in [Travis-CI](https://travis-ci.org/)'s online documentation.
11+
GHC-7.0.1 &mdash; GHC-9.2.1 are supported.
2612

2713
### Quick-start instructions
2814

@@ -40,9 +26,6 @@ Note: For actually enabling continuous integration for a GitHub hosted project,
4026
cabal new-install haskell-ci
4127
```
4228

43-
*Note:* currently (2019-02-12) released version of `haskell-ci` installs
44-
an executable named `make-travis-yml`
45-
4629
* Step 2: Change directories to your project:
4730

4831
```bash
@@ -60,53 +43,49 @@ Note: For actually enabling continuous integration for a GitHub hosted project,
6043
6144
Add as many or as few GHC versions to test as you want.
6245
63-
* Step 4: Generate a Travis file for your project:
46+
* Step 4: Generate a workflow file for your project:
6447
6548
```bash
6649
$ # You run the following command from your project's directory, even
6750
$ # though it references the script from the `haskell-ci` project
68-
$ haskell-ci your-project.cabal --output .travis.yml
51+
$ haskell-ci github your-project.cabal
6952
```
7053

7154
Note: If you have multiple local Cabal projects that you wish to build together
7255
using a `cabal.project` file, pass that file to haskell-ci instead:
7356
```bash
74-
$ haskell-ci cabal.project --output .travis.yml
57+
$ haskell-ci github cabal.project
7558
```
7659

7760
The `haskell-ci` tool looks at the `Tested-With` line in your
78-
`*.cabal` files and generates a Travis build that tests each compiler
61+
`*.cabal` files and generates a configuration that tests each compiler
7962
version you listed in parallel.
8063

81-
* Step 5: Create a branch with your new Travis file and push your branch:
64+
* Step 5: Create a branch with your new CI configuration file and push your branch:
8265

8366
```bash
8467
$ git checkout master # Check out `master`
8568
$ git pull --ff-only # Get the latest version of `master`
86-
$ git checkout -b new_travis # Create a `new_travis` branch
87-
$ git add .travis.yml
88-
$ git commit -m "New Travis script"
89-
$ git push -u origin new_travis # Push your branch upstream
69+
$ git checkout -b new-ci # Create a `new_travis` branch
70+
$ git add .
71+
$ git commit -m "New CI script"
72+
$ git push -u origin new-ci # Push your branch upstream
9073
```
9174

92-
If you have Travis enabled for your repository this will test your branch
93-
using your newly created Travis file. This lets you test the Travis script
94-
before merging the new script into `master`.
95-
9675
* Step 6: Fix the build
9776

9877
If you're lucky, your repository will build for every compiler version
9978
you listed. If that's the case, then just merge your changes into `master`:
10079

10180
```bash
10281
$ git checkout master
103-
$ git merge new_travis # Update `master` with your new Travis script
82+
$ git merge new-ci # Update `master` with your new CI script
10483
$ git push
10584
```
10685

10786
You can also merge your branch into `master` from Github's pull request view.
10887
109-
If you're not lucky, then your new Travis branch will fail for one or more
88+
If you're not lucky, then your new CI branch will fail for one or more
11089
versions of GHC, which is okay! Look at the build and fix any build failures
11190
you find and commit the fixes to your branch:
11291

@@ -116,231 +95,9 @@ Note: For actually enabling continuous integration for a GitHub hosted project,
11695
$ git push # Push your branch updates upstream
11796
```
11897

119-
Sometimes you may need to regenerate Travis script. for example, to
120-
remove the `cabal check` step (pass `--no-cabal-check` flag to `haskell-ci)
121-
if you know for sure that you need build your project with the `-O2` flag.
122-
123-
Each time you push an update to your branch Travis will run again to see if
124-
any build failures still remain. Repeat this process until your project
125-
builds against each GHC version you listed. Once your project builds against
126-
each target version of GHC you can merge your Travis script into `master`
127-
128-
### Add-on Packages
129-
130-
For convenience, a few add-on packages are available to provide more recent versions of `cabal`, `alex` and `happy` than are available in Ubuntu 12.04.
131-
132-
They install into a respective `/opt/<name>/<version>/bin` folder (see table below) which can be put into the search `$PATH`.
133-
134-
There's also a `/opt/ghc/bin` (& `/opt/cabal/bin`) folder which contains version-suffixed symlinks to installed GHC versions for convenient use with `cabal` (e.g. "`cabal new-build -w ghc-7.8.4`"), as well as symlinks managed by [`update-alternatives(1)`](https://manpages.debian.org/unstable/dpkg/update-alternatives.1.en.html) which can be configured via
135-
136-
sudo update-alternatives --config opt-ghc
137-
sudo update-alternatives --config opt-cabal
138-
139-
Note that `/opt/ghc/bin` also contains a default symlink for `cabal`, so it's enough to include `/opt/ghc/bin` in your PATH to get access to both `cabal` and `ghc`.
140-
141-
| `.deb` Package Name | Executable
142-
| -------------------- | ----------
143-
| `cabal-install-1.16` | `/opt/cabal/1.16/bin/cabal`
144-
| `cabal-install-1.18` | `/opt/cabal/1.18/bin/cabal`
145-
| `cabal-install-1.20` | `/opt/cabal/1.20/bin/cabal`
146-
| `cabal-install-1.22` | `/opt/cabal/1.22/bin/cabal`
147-
| `cabal-install-1.24` | `/opt/cabal/1.24/bin/cabal`
148-
| `cabal-install-2.0` | `/opt/cabal/2.0/bin/cabal`
149-
| `cabal-install-2.2` | `/opt/cabal/2.2/bin/cabal`
150-
| `cabal-install-2.4` | `/opt/cabal/2.4/bin/cabal`
151-
| `cabal-install-head` | `/opt/cabal/head/bin/cabal`
152-
| `alex-3.1.3` | `/opt/alex/3.1.3/bin/alex`
153-
| `alex-3.1.4` | `/opt/alex/3.1.4/bin/alex`
154-
| `alex-3.1.7` | `/opt/alex/3.1.7/bin/alex`
155-
| `happy-1.19.3` | `/opt/happy/1.19.3/bin/happy`
156-
| `happy-1.19.4` | `/opt/happy/1.19.4/bin/happy`
157-
| `happy-1.19.5` | `/opt/happy/1.19.5/bin/happy`
158-
159-
160-
See examples below for how to use those.
161-
162-
`.travis.yml` (for container-based infrastructure)
163-
--------------------------------------------------
164-
165-
Since 2015, Travis-CI is migrating build-jobs towards a [contained-based infrastructure](http://docs.travis-ci.com/user/workers/container-based-infrastructure/) which requires a different way to setup the build-matrix in the first half of the `.travis.yml`.
166-
167-
The following `.travis.yml` snippet shows the different `matrix` and
168-
`before_install` sections (relative to the non-container
169-
`.travis.yml`):
170-
171-
```yaml
172-
language: c
173-
174-
# explicitly request container-based infrastructure
175-
sudo: false
176-
177-
matrix:
178-
include:
179-
- env: CABALVER=1.16 GHCVER=7.6.3
180-
addons: {apt: {packages: [cabal-install-1.16,ghc-7.6.3], sources: [hvr-ghc]}}
181-
- env: CABALVER=1.18 GHCVER=7.8.4
182-
addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4], sources: [hvr-ghc]}}
183-
- env: CABALVER=1.22 GHCVER=7.10.1
184-
addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.1],sources: [hvr-ghc]}}
185-
- env: CABALVER=head GHCVER=head
186-
addons: {apt: {packages: [cabal-install-head,ghc-head], sources: [hvr-ghc]}}
187-
188-
allow_failures:
189-
- env: CABALVER=head GHCVER=head
190-
191-
before_install:
192-
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
193-
```
194-
195-
#### Caching dependencies & `.travis.yml` script generator
196-
197-
The top-level `tested-with:` field has a similiar syntax to the `build-depends:` field but with compilers instead of packages. The script contains a list of known GHC versions and emits entries for all matching versions. Here are a few examples:
198-
199-
```
200-
tested-with: GHC >= 7.4 && < 7.8
201-
-- selects GHC 7.4.1, 7.4.2, 7.6.1, 7.6.2, and 7.6.3
202-
203-
tested-with: GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.11.*
204-
-- selects GHC 7.4.2, 7.6.3, 7.8.4, and GHC HEAD
205-
```
206-
207-
If you need additional Ubuntu packages installed (e.g. `alex-3.1.5` or `libxml-dev`), you can pass the Ubuntu package names as additional commandline arguments after the `.cabal` filename argument.
208-
209-
### Known Issues
210-
211-
- The container environment reports 16 cores, causing `cabal`'s default configuration (`jobs: $ncpus`) to run into the [GHC #9221](https://ghc.haskell.org/trac/ghc/ticket/9221) bug which can result in longer build-times. This can be workarounded by commenting out the `jobs: $ncpus` right after `cabal update` creates that file:
212-
213-
```yaml
214-
install:
215-
# ...
216-
- travis_retry cabal update
217-
- sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
218-
# ...
219-
```
220-
221-
222-
`.travis.yml` Template (for non-container-based infrastructure)
223-
---------------------------------------------------------------
224-
225-
Below is a commented `.travis.yml` example that can be used as a template:
226-
227-
```yaml
228-
# NB: don't set `language: haskell` here
229-
230-
# explicitly request legacy non-sudo based build environment
231-
sudo: required
232-
233-
# The following enables several GHC versions to be tested; often it's enough to test only against the last release in a major GHC version. Feel free to omit lines listings versions you don't need/want testing for.
234-
env:
235-
- CABALVER=1.16 GHCVER=6.12.3
236-
- CABALVER=1.16 GHCVER=7.0.1
237-
- CABALVER=1.16 GHCVER=7.0.2
238-
- CABALVER=1.16 GHCVER=7.0.3
239-
- CABALVER=1.16 GHCVER=7.0.4
240-
- CABALVER=1.16 GHCVER=7.2.1
241-
- CABALVER=1.16 GHCVER=7.2.2
242-
- CABALVER=1.16 GHCVER=7.4.1
243-
- CABALVER=1.16 GHCVER=7.4.2
244-
- CABALVER=1.16 GHCVER=7.6.1
245-
- CABALVER=1.16 GHCVER=7.6.2
246-
- CABALVER=1.18 GHCVER=7.6.3
247-
- CABALVER=1.18 GHCVER=7.8.1 # see note about Alex/Happy for GHC >= 7.8
248-
- CABALVER=1.18 GHCVER=7.8.2
249-
- CABALVER=1.18 GHCVER=7.8.3
250-
- CABALVER=1.18 GHCVER=7.8.4
251-
- CABALVER=1.22 GHCVER=7.10.1
252-
- CABALVER=1.22 GHCVER=7.10.2
253-
- CABALVER=head GHCVER=head # see section about GHC HEAD snapshots
254-
255-
# Note: the distinction between `before_install` and `install` is not important.
256-
before_install:
257-
- travis_retry sudo add-apt-repository -y ppa:hvr/ghc
258-
- travis_retry sudo apt-get update
259-
- travis_retry sudo apt-get install cabal-install-$CABALVER ghc-$GHCVER # see note about happy/alex
260-
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
261-
262-
install:
263-
- cabal --version
264-
- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
265-
- travis_retry cabal update
266-
- cabal install --only-dependencies --enable-tests --enable-benchmarks
267-
268-
# Here starts the actual work to be performed for the package under test; any command which exits with a non-zero exit code causes the build to fail.
269-
script:
270-
- if [ -f configure.ac ]; then autoreconf -i; fi
271-
- cabal configure --enable-tests --enable-benchmarks -v2 # -v2 provides useful information for debugging
272-
- cabal build # this builds all libraries and executables (including tests/benchmarks)
273-
- cabal test
274-
- cabal check
275-
- cabal sdist # tests that a source-distribution can be generated
276-
277-
# Check that the resulting source distribution can be built & installed.
278-
# If there are no other `.tar.gz` files in `dist`, this can be even simpler:
279-
# `cabal install --force-reinstalls dist/*-*.tar.gz`
280-
- SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz &&
281-
(cd dist && cabal install --force-reinstalls "$SRC_TGZ")
282-
283-
```
284-
285-
For more information about the `.travis.yml` script please consult the
286-
[official documentation](http://about.travis-ci.org/docs/user/build-configuration/).
287-
288-
### Haskell Platform Configurations
289-
290-
Basic idea: Generate a `cabal.config` file during the build job (before installing the build-dependencies) constraining to HP package versions, e.g. for HP 2013.2.0.0 the `cabal.config` would need to contain the following constraints definition:
291-
292-
```
293-
constraints: async==2.0.1.4,attoparsec==0.10.4.0,case-insensitive==1.0.0.1,cgi==3001.1.7.5,fgl==5.4.2.4,GLUT==2.4.0.0,GLURaw==1.3.0.0,haskell-src==1.0.1.5,hashable==1.1.2.5,html==1.0.1.2,HTTP==4000.2.8,HUnit==1.2.5.2,mtl==2.1.2,network==2.4.1.2,OpenGL==2.8.0.0,OpenGLRaw==1.3.0.0,parallel==3.2.0.3,parsec==3.1.3,QuickCheck==2.6,random==1.0.1.1,regex-base==0.93.2,regex-compat==0.95.1,regex-posix==0.95.2,split==0.2.2,stm==2.4.2,syb==0.4.0,text==0.11.3.1,transformers==0.3.0.0,unordered-containers==0.2.3.0,vector==0.10.0.1,xhtml==3000.2.1,zlib==0.5.4.1
294-
```
295-
296-
Use [this `.travis.yml` script](.travis.yml) as a template if you want
297-
to test against Haskell Platform configurations.
298-
299-
### Alex & Happy with GHC ≥ 7.8
300-
301-
If your package (or one of its dependencies) contain Alex/Happy generated parsers, GHC 7.8.1 and later require a more recent `alex`/`happy` executable installed (see [Happy, Alex, and GHC 7.8](http://ro-che.info/articles/2014-03-08-happy-alex-ghc-7.8.html) for the gory details). The following snipped (stolen from `lens`'s [`.travis.yaml`](https://github.com/ekmett/lens/blob/master/.travis.yml)) illustrates how to this can be accomplished:
302-
303-
```yaml
304-
- |
305-
if [ $GHCVER = "head" ] || [ ${GHCVER%.*} = "7.8" ] || [ ${GHCVER%.*} = "7.10" ]; then
306-
travis_retry sudo apt-get install happy-1.19.4 alex-3.1.3
307-
export PATH=/opt/alex/3.1.3/bin:/opt/happy/1.19.4/bin:$PATH
308-
else
309-
travis_retry sudo apt-get install happy alex
310-
fi
311-
```
312-
313-
### GHC HEAD Snapshots
314-
315-
- Snapshots of current GHC development snapshots from the `master` branch (aka *GHC HEAD*) are uploaded at irregular intervals to the PPA
316-
- You can select *GHC HEAD* at your own risk by setting `GHCVER=head`
317-
- As GHC HEAD is experimental and likely to cause build failures, you might want to [tolerate failures](http://about.travis-ci.org/docs/user/build-configuration/#Rows-That-are-Allowed-To-Fail) by adding the following snippet to your `.travis.yml`:
318-
319-
```yaml
320-
matrix:
321-
allow_failures:
322-
- env: CABALVER=head GHCVER=head
323-
```
324-
325-
- NB: the line in `matrix.allow_failures.env` must match exactly
326-
(including any whitespace) the line specified in `env`
327-
328-
Ideas for Additional Checks
329-
---------------------------
330-
331-
- Check for `build-depends` excluding latest package versions with [`packdeps`](http://hackage.haskell.org/package/packdeps)
332-
- Check for unused `build-depends` with [`packunused`](http://hackage.haskell.org/package/packunused)
333-
- Check for 100% Haddock coverage
334-
- Check for trailing whitespaces and/or tabs in source files
335-
336-
Random Remarks
337-
--------------
338-
339-
- If you want to know which core library version each GHC used (e.g. for deciding on what upper/lower bounds to declare for `build-depends`), see [GHC Boot Library Version History](http://ghc.haskell.org/trac/ghc/wiki/Commentary/Libraries/VersionHistory)
340-
- Supporting GHC versions prior to 7.0.1 requires more effort:
341-
- GHC 7.0.1 was the first version to support `default-language: Haskell2010`
342-
- Declaring `cabal-version >= 1.10` makes it more difficult to compile with GHC 6.12.3's default `cabal-install`
343-
- `cabal-install` [falls back to top-down solver for GHC < 7](http://stackoverflow.com/questions/16021645/what-does-cabals-warning-falling-back-to-topdown-solver-for-ghc-7-mean) which may require additional tweaks to the build script to compensate for (e.g. installing `QuickCheck` via `cabal install --only-dep` is known to fail)
98+
Sometimes you may need to regenerate CI script, for example, when
99+
adding new compiler version to `tested-with`.
100+
You may simply run `haskell-ci regenerate`.
344101

345102
Real-world Examples
346103
-------------------

0 commit comments

Comments
 (0)