Travis uses [several factors](https://docs.travis-ci.com/user/caching/#caches-and-build-matrices)
to determine whether a given job shares a cache with a different job. In
particular, it uses any environment variables specified in
`.travis.yml`. Previously, integration tests set `INTEGRATION=true`,
which meant that the integration tests did not share a cache with the
non-integration tests, even though the compilation is exactly the same.
This patch fixes that by remvoing the `INTEGRATION` environment variable
and instead using the globally available
[`$TRAVIS_BUILD_STAGE_NAME`](https://docs.travis-ci.com/user/environment-variables/#default-environment-variables)
to run the setup required for integration tests only in stages that run
integration tests (namely integration and coverage). Now, the test and
integration stages share all the parameters that Travis uses to
determine cache identifiers, and so they'll share their cache!
Coverage still uses its own cache because it specifically needs to *not*
cache the compiled crate, but *does* need to cache `cargo-tarpaulin`.
This patch modifies the Travis build pipeline to include multiple
[build stages](https://docs.travis-ci.com/user/build-stages/). CI now
progresses in the following steps:
- First, `cargo check` is run on `stable` only.
If it fails, the build is considered failed.
This is so that we can fail fast for obviously botched commits.
- Then, unit and doc tests are run for all targets.
If any non-nightly tests fail, the build fails.
- Then, integration tests with
[GreenMail](http://www.icegreen.com/greenmail/) are run on Linux for
all Rust targets. We can't run them on macOS because it doesn't
support the Docker service.
If any non-nightly tests fail, the build fails.
- Then, `rustfmt` and `clippy` are both run on *beta* and on nightly.
We use beta instead of stable to try to give ourselves some headroom
for changes coming down the pike. The lints are only run on Linux,
because the platform shouldn't matter.
If any beta lints fail, the build fails.
- And finally, we generate a coverage report on nightly on Linux.
This can only run on nightly because tarpaulin requires nightly.
It's only run on Linux, because we want to include integration tests.
Note that the coverage stage has its own cache
(`CACHE_NAME=coverage`) because the only thing it caches is cargo
tarpaulin (the rust/cargo cache is cleaned before exit).
Fixes#48.