Skip to content

Instantly share code, notes, and snippets.

@tlvince
Last active August 19, 2017 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlvince/e723a147366f00c9ca6641f412fd4bb3 to your computer and use it in GitHub Desktop.
Save tlvince/e723a147366f00c9ca6641f412fd4bb3 to your computer and use it in GitHub Desktop.
Methods of running Pandoc in TravisCI

1. sudo & apt-get

Using Travis' standard infrastructure, you can simply use apt-get:

sudo: true
before_install:
  - sudo apt-get -qq update
  - sudo apt-get install -y pandoc

Depending on what Travis' current Linux environment is (Ubuntu Trusty at the time of writing), this may be all you need. However, you may be limited to an old version of Pandoc (Trusty currently has v1.12.2).

2. Without sudo & APT addon

Using Travis' container infrastructure (Docker), as pandoc is in the APT addon whitelist, you can do:

addons:
  apt:
    packages:
      - pandoc

However, as before, this limits you to the version of pandoc currently in the Ubuntu repos.

3. With sudo, without an APT repo

As pandoc helpfully ships .deb packages in its GitHub releases, you can download the .deb and install it manually.

sudo: true
before_install:
  - curl -L https://github.com/jgm/pandoc/releases/download/1.19.2.1/pandoc-1.19.2.1-1-amd64.deb > pandoc.deb
  - sudo dpkg -i pandoc.deb

The benefit here being you can choose any version of Pandoc, so long as they continue to ship a .deb for the right architecture.

4. Without sudo, without an APT repo

Taking the above further, we manually extract the .deb without sudo and thereby have faster job startup times (sudo/non-container based infrastructure jobs take ~20 secs to spin up).

before_install:
  - curl -L https://github.com/jgm/pandoc/releases/download/1.19.2.1/pandoc-1.19.2.1-1-amd64.deb > pandoc.deb
  - dpkg -x pandoc.deb .
  - export PATH="$PWD/usr/bin:$PATH"

Note, this only works as Pandoc is built statically and is liable to break. However, coupled with caching, this method produces the fastest builds with arbitary Pandoc versions.

See tlvince/talks/.travis.yml for a version with caching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment