summaryrefslogtreecommitdiffstats
path: root/.travis.yml
blob: 609043ea5c464e2fee4fee4b758e8b9c6e93b828 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
language: rust
# We deliberately do NOT cache with `cache: cargo` because these caches grow to
# gigabytes in size at which point downloading, unpacking and repacking takes
# way longer than just building things fresh every time.

addons:
  apt:
    packages:
      # Install musl for some Linux builds
      - musl-tools

env:
  global:
    - ANSI2HTML_VERSION=1.4.2
before_install:
  # For formatting tests
  - pip install --user ansi2html==${ANSI2HTML_VERSION}
# Default script for test stage
script:
  - cargo build --target $CARGOTARGET $CARGOFLAGS --verbose
  - cargo test --target $CARGOTARGET $CARGOFLAGS --verbose
  # Make sure that we can format w/o panic or error
  - cargo run --target $CARGOTARGET $CARGOFLAGS -- sample/common-mark.md

# Check formatting before running tests, and lint afterwards
stages:
  - formatting
  - test
  - lint
  - release
jobs:
  include:
    # Check formatting on rust stable before anything else
    - name: check rustfmt
      stage: formatting
      os: linux
      rust: stable
      before_script: rustup component add rustfmt
      script: cargo fmt -- --check

    # Our target Rust version.  We test:
    #
    # - A standard linux build
    # - --no-default-features to make sure things build in other configurations
    # - A static musl build
    # - macOS
    # - Windows
    - name: linux (all features)
      stage: test
      os: linux
      rust: stable
      env:
        - CARGOTARGET=x86_64-unknown-linux-gnu
    - name: linux (musl, only terminology)
      stage: test
      os: linux
      rust: stable
      env:
        - CARGOTARGET=x86_64-unknown-linux-musl
        - CARGOFLAGS='--no-default-features --features terminology'
      before_script: rustup target add x86_64-unknown-linux-musl
    - name: macOS (only iterm2)
      stage: test
      os: osx
      rust: stable
      before_script:
        # Add local Python scripts to path for ansi2html
        - export PATH="$HOME/Library/Python/2.7/bin:$PATH"
      env:
        - CARGOTARGET=x86_64-apple-darwin
        - CARGOFLAGS='--no-default-features --features iterm2,remote_resources'
    - name: windows (no features)
      stage: test
      os: windows
      rust: stable
      # Don't install ansi2html on Travis CI: Python isn’t readily available on
      # Windows, so skip these tests
      before_install: ''
      env:
        - CARGOTARGET=x86_64-pc-windows-msvc
        - CARGOFLAGS='--no-default-features'
    # Catch regressions in beta and nightly
    - name: rust beta (all features)
      stage: test
      os: linux
      rust: beta
      env:
        - CARGOTARGET=x86_64-unknown-linux-gnu
    - name: rust nightly (all features)
      stage: test
      os: linux
      rust: nightly
      env:
        - CARGOTARGET=x86_64-unknown-linux-gnu

    # Run clippy after testing, with and without features.
    - &lint-settings
      name: clippy (all features)
      stage: lint
      os: linux
      rust: stable
      before_script: rustup component add clippy
      script: cargo clippy --all-targets $CARGOFLAGS
    - <<: *lint-settings
      name: clippy (no features)
      env:
        - CARGOFLAGS=--no-default-features

    # Deploy binary to GitHub
    - &deploy-settings
      name: Linux binary (static with musl, only terminology)
      stage: release
      # Our release tags start with "mdcat-", so we only build for such tags
      if: tag =~ ^mdcat-
      os: linux
      rust: stable
      before_install: rustup target add x86_64-unknown-linux-musl
      env:
        - CARGOTARGET=x86_64-unknown-linux-musl
        # Exclude iterm2 from release artifacts on Linux, and build against Musl
        - CARGOFLAGS='--no-default-features --features terminology'
      # Inhibit Travis’ default "cargo build --verbose" install step because we
      # make an explicit release build in the "script" phase
      install: ""
      script: cargo build --target "$CARGOTARGET" $CARGOFLAGS --release --verbose
      before_deploy:
        # Strip the binary to reduce its size
        - strip "target/${CARGOTARGET}/release/mdcat"
        # Put all the things into a dedicated directory, as usual with TAR files
        - export ARCHIVE_NAME="${TRAVIS_TAG}-${CARGOTARGET}"
        - echo "Building ${ARCHIVE_NAME}"
        - mkdir "/tmp/${ARCHIVE_NAME}"
        - cp README.md CHANGELOG.md LICENSE "/tmp/${ARCHIVE_NAME}"
        - cp "target/${CARGOTARGET}/release/mdcat" "/tmp/${ARCHIVE_NAME}"
        # Pack the tarball
        - export ARCHIVE_FILE="/tmp/${ARCHIVE_NAME}.tar.gz"
        - tar -czf "${ARCHIVE_FILE}" -C /tmp/ "${ARCHIVE_NAME}"
      deploy:
        skip_cleanup: true
        provider: releases
        api_key:
          secure: "QLjmQJo/ak94aIdyrd6DMiPtAVr06XwjVfm9qZzd0EKbnagBYlVOW+SxpS3juBCifwz1H4eADoAfktWoKiY//BqwUXOTv9uBctQSHDl7xevGdFTOTIpRIuvDtdzk+8j+5tL2fVyPUBWIPOzBu/s+10nyHK8mPsF1Ia+CoTfPfauJPDIAI0x29OBl8vLap/DCh9aua268d8q7R9H32tDGNm9nNF3FXkWS+4yp4F83tkj8/RANOjYJMweCN1fXhziNfe+WdsVZsgnaNVKSXjTACdkXZc3mNRwi9SbtpHur9+R3wPle4m7BeRdcXo38tiWEEZfyEh4h/DpNWe5XaqRIBSR9QUHquWyN8j/KHVJ/UMs1o/yojciH2ylW0K3ak44btkPabkbwszBHvlmFiMOl4tgYsefF9Bo4x5jG8PgO3O040QyJV9ex2UkoUQYOo5xV4OeYtUUdNQRE6F0O3BUY71y0q4b+4F2ClA01gMXW41QfJmPnS8uChLqHw+w3Gzt9v03WR/la5BQixFIfMx4t0aZLGgx63c1u7gdaHc7mAjYRCdiZlWuFQ3r+6/Z4RU7/57QuRM+A0TjwElhjn2hfuFz7hssuwzG9RFYKbsMBinsm+wEWuMhkQ/P7vac3FEmYlKEgfCoUhZmxP9sEV+mxVjXOTzLYkaxNzAS0lLyQDeQ="
        file: "${ARCHIVE_FILE}"
        on:
          tags: true
    - <<: *deploy-settings
      name: macOS binary (only iterm2)
      os: osx
      before_install: ""
      env:
        - CARGOTARGET=x86_64-apple-darwin
        # Only include iterm2 when building for macos, and also enable remote
        # resources for iterm2
        - CARGOFLAGS='--no-default-features --features iterm2,remote_resources'
    - <<: *deploy-settings
      name: Windows binary (no features)
      os: windows
      before_install: ""
      env:
        - CARGOTARGET=x86_64-pc-windows-msvc
        - CARGOFLAGS='--no-default-features'
      before_deploy:
        # Windows likes file extensions :)
        - mv LICENSE LICENSE.txt
        # and ZIP files
        - export ARCHIVE_FILE="${TRAVIS_TAG}-${CARGOTARGET}.zip"
        # The leading dots are important: They make 7z ignore the path part and
        # add the file directly to the archive root.
        - 7z a "${ARCHIVE_FILE}" "./target/${CARGOTARGET}/release/mdcat.exe" ./README.md ./CHANGELOG.md ./LICENSE.txt