From 1eab9c8375ddca44659c839e6dfb992422a129a8 Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Sat, 24 Nov 2018 11:14:22 -0500 Subject: [PATCH 1/9] Refine Travis CI build and add rustfmt/clippy 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. --- .travis.yml | 96 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 70 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index afab053..46dee65 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,38 +14,82 @@ rust: os: - linux - osx -matrix: - allow_failures: - - rust: nightly services: - docker -before_install: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then +before_script: + - if [[ "$INTEGRATION" == "true" ]]; then docker pull greenmail/standalone:1.5.8 && docker run -d -e GREENMAIL_OPTS='-Dgreenmail.setup.test.all -Dgreenmail.hostname=0.0.0.0 -Dgreenmail.auth.disabled -Dgreenmail.verbose' -p 3025:3025 -p 3110:3110 -p 3143:3143 -p 3465:3465 -p 3993:3993 -p 3995:3995 greenmail/standalone:1.5.8; fi -script: - - cargo clean - - cargo check --all-targets - - cargo test --doc - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - cargo test --tests; - else - cargo test --lib; - fi -before_cache: | - if [[ "$TRAVIS_OS_NAME" == "linux" && "$TRAVIS_RUST_VERSION" == nightly ]]; then - RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install cargo-tarpaulin - fi +# an entry in stage=test will be generated for each rust/os combination. +# each entry will run these commands. +script: + - cargo test --examples + - cargo test --doc + - cargo test --lib +jobs: + allow_failures: + - rust: nightly + include: + - stage: check # do a pre-screen to make sure this is even worth testing + script: cargo check --all-targets + rust: stable + os: linux + - stage: integration # make integration tests its own stage + script: cargo test --tests + env: INTEGRATION=true + rust: stable + os: linux + - script: cargo test --tests # it's a little sad we have to enumerate here + env: INTEGRATION=true + rust: beta + os: linux + - script: cargo test --tests + env: INTEGRATION=true + rust: nightly + os: linux + - stage: lint # we lint on beta to future-proof + name: "Rust: beta, rustfmt" + rust: beta + os: linux + script: + - rustup component add rustfmt-preview + - cargo fmt -v -- --check + - name: "Rust: nightly, rustfmt" # and on nightly with allow_fail + rust: nightly + os: linux + script: + - rustup component add rustfmt-preview + - cargo fmt -v -- --check + - name: "Rust: beta, clippy" + rust: beta + os: linux + script: + - rustup component add clippy-preview + - touch ./src/lib.rs && cargo clippy -- -D warnings + - name: "Rust: nightly, clippy" + rust: nightly + os: linux + script: + - rustup component add clippy-preview + - touch ./src/lib.rs && cargo clippy -- -D warnings + - stage: coverage + rust: nightly + os: linux + env: CACHE_NAME=coverage INTEGRATION=true + script: + - RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install cargo-tarpaulin + - cargo tarpaulin --out Xml + - bash <(curl -s https://codecov.io/bash) + - cargo clean # ensure we don't cache build for coverage +stages: + - check + - test + - integration + - lint + - coverage after_failure: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker logs (docker ps -q); fi - -after_success: | - if [[ "$TRAVIS_OS_NAME" == "linux" && "$TRAVIS_RUST_VERSION" == nightly ]]; then - docker restart -t 1 (docker ps -q); - cargo tarpaulin --out Xml; - bash <(curl -s https://codecov.io/bash); - fi + - if [[ "$INTEGRATION" == "true" ]]; then docker logs (docker ps -q); fi From 481ace22a6cd3f5efad4f10fac5b58886e877eaa Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Sat, 24 Nov 2018 12:39:18 -0500 Subject: [PATCH 2/9] Also test on Windows! --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 46dee65..f9a83c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ rust: os: - linux - osx + - windows services: - docker From d5076883c59c9963f25ca2f2e2ef3c6975cbaea5 Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Sat, 24 Nov 2018 12:39:30 -0500 Subject: [PATCH 3/9] Only require sudo for integration tests --- .travis.yml | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index f9a83c4..0b4b649 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,4 @@ language: rust -sudo: required -dist: trusty -addons: - apt: - packages: - - libssl-dev - cache: cargo rust: - stable @@ -16,8 +9,6 @@ os: - osx - windows -services: - - docker before_script: - if [[ "$INTEGRATION" == "true" ]]; then docker pull greenmail/standalone:1.5.8 && @@ -38,19 +29,23 @@ jobs: script: cargo check --all-targets rust: stable os: linux - - stage: integration # make integration tests its own stage + - &integration + stage: integration # make integration tests its own stage script: cargo test --tests + sudo: required + services: + - docker + addons: + apt: + packages: + - libssl-dev env: INTEGRATION=true rust: stable os: linux - - script: cargo test --tests # it's a little sad we have to enumerate here - env: INTEGRATION=true + - <<: *integration rust: beta - os: linux - - script: cargo test --tests - env: INTEGRATION=true + - <<: *integration rust: nightly - os: linux - stage: lint # we lint on beta to future-proof name: "Rust: beta, rustfmt" rust: beta @@ -76,9 +71,9 @@ jobs: script: - rustup component add clippy-preview - touch ./src/lib.rs && cargo clippy -- -D warnings - - stage: coverage + - <<: *integration + stage: coverage rust: nightly - os: linux env: CACHE_NAME=coverage INTEGRATION=true script: - RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install cargo-tarpaulin From 64b968cd16b7814ec317a5bd575d03cd2b127dad Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Sat, 24 Nov 2018 13:31:40 -0500 Subject: [PATCH 4/9] Don't worry that tarpaulin is already installed --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0b4b649..975cd2a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -76,7 +76,7 @@ jobs: rust: nightly env: CACHE_NAME=coverage INTEGRATION=true script: - - RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install cargo-tarpaulin + - RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install cargo-tarpaulin || true - cargo tarpaulin --out Xml - bash <(curl -s https://codecov.io/bash) - cargo clean # ensure we don't cache build for coverage From cdbc330d77d133c34cea5aae28136b0684a719cc Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Sat, 24 Nov 2018 13:29:45 -0500 Subject: [PATCH 5/9] Just test stable on non-linux Let's not waste Travis' cycles unnecessarily --- .travis.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 975cd2a..f41fe14 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,10 +4,6 @@ rust: - stable - beta - nightly -os: - - linux - - osx - - windows before_script: - if [[ "$INTEGRATION" == "true" ]]; then @@ -29,6 +25,11 @@ jobs: script: cargo check --all-targets rust: stable os: linux + - stage: test + rust: stable + os: osx + - rust: stable + os: windows - &integration stage: integration # make integration tests its own stage script: cargo test --tests From a2b07736224f81afee5c39c79f58b6f5d342a3f9 Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Sat, 24 Nov 2018 13:48:34 -0500 Subject: [PATCH 6/9] Remove AppVeyor now that Travis does Windows [skip ci] --- Cargo.toml | 1 - README.md | 1 - README.tpl | 1 - appveyor.yml | 71 ---------------------------------------------------- 4 files changed, 74 deletions(-) delete mode 100644 appveyor.yml diff --git a/Cargo.toml b/Cargo.toml index 31ba1a1..d2f5d7d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,6 @@ categories = ["email", "network-programming"] [badges] travis-ci = { repository = "jonhoo/rust-imap" } -appveyor = { repository = "jonhoo/rust-imap", branch = "master", service = "github" } codecov = { repository = "jonhoo/rust-imap", branch = "master", service = "github" } maintenance = { status = "actively-developed" } is-it-maintained-issue-resolution = { repository = "jonhoo/rust-imap" } diff --git a/README.md b/README.md index 4ac8b7a..7253875 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ [![Documentation](https://docs.rs/imap/badge.svg)](https://docs.rs/imap/) [![Crate License](https://img.shields.io/crates/l/imap.svg)](https://crates.io/crates/imap) [![Build Status](https://travis-ci.org/jonhoo/rust-imap.svg)](https://travis-ci.org/jonhoo/rust-imap) -[![Build Status](https://ci.appveyor.com/api/projects/status/github/jonhoo/rust-imap?svg=true)](https://ci.appveyor.com/api/projects/status/github/jonhoo/rust-imap) [![Coverage Status](https://codecov.io/gh/jonhoo/rust-imap/branch/master/graph/badge.svg)](https://codecov.io/gh/jonhoo/rust-imap) This crate lets you connect to and interact with servers that implement the IMAP protocol ([RFC diff --git a/README.tpl b/README.tpl index dd57edf..ea74f40 100644 --- a/README.tpl +++ b/README.tpl @@ -7,7 +7,6 @@ [![Documentation](https://docs.rs/imap/badge.svg)](https://docs.rs/imap/) [![Crate License](https://img.shields.io/crates/l/imap.svg)](https://crates.io/crates/imap) [![Build Status](https://travis-ci.org/jonhoo/rust-imap.svg)](https://travis-ci.org/jonhoo/rust-imap) -[![Build Status](https://ci.appveyor.com/api/projects/status/github/jonhoo/rust-imap?svg=true)](https://ci.appveyor.com/api/projects/status/github/jonhoo/rust-imap) [![Coverage Status](https://codecov.io/gh/jonhoo/rust-imap/branch/master/graph/badge.svg)](https://codecov.io/gh/jonhoo/rust-imap) {{readme}} diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 7e1300f..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,71 +0,0 @@ -# inspired by https://github.com/starkat99/appveyor-rust/blob/master/appveyor.yml - -environment: - matrix: - -### MSVC Toolchains ### - - # Stable 64-bit MSVC - - channel: stable - target: x86_64-pc-windows-msvc - # Stable 32-bit MSVC - - channel: stable - target: i686-pc-windows-msvc - # Beta 64-bit MSVC - - channel: beta - target: x86_64-pc-windows-msvc - # Beta 32-bit MSVC - - channel: beta - target: i686-pc-windows-msvc - -### GNU Toolchains ### - - # Stable 64-bit GNU - - channel: stable - target: x86_64-pc-windows-gnu - # Stable 32-bit GNU - - channel: stable - target: i686-pc-windows-gnu - # Beta 64-bit GNU - - channel: beta - target: x86_64-pc-windows-gnu - # Beta 32-bit GNU - - channel: beta - target: i686-pc-windows-gnu - -### MinGW Toolchains ### - - # Stable 64-bit MinGW - - channel: stable - target: x86_64-pc-windows-msvc - MSYS_BITS: 64 - # Stable 32-bit MinGW - - channel: stable - target: i686-pc-windows-msvc - MSYS_BITS: 32 - # Beta 64-bit MinGW - - channel: beta - target: x86_64-pc-windows-msvc - MSYS_BITS: 64 - # Beta 32-bit MinGW - - channel: beta - target: i686-pc-windows-msvc - MSYS_BITS: 32 - -install: - # install Rust - - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe - - rustup-init -yv --default-toolchain %channel% --default-host %target% - - set PATH=%PATH%;%USERPROFILE%\.cargo\bin - - rustc -vV - - cargo -vV - -# Building is done in the test phase, so we disable Appveyor's build phase. -build: false - -test_script: - - cargo check --all-targets - - cargo test --lib - - cargo test --doc - - cargo test --examples -# note that we are not running integration tests! From f25b9995eb3c2ae9c7c52a1f2de1d3d94fc45b88 Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Sat, 24 Nov 2018 13:57:57 -0500 Subject: [PATCH 7/9] Let's see what Rust version we support --- .travis.yml | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f41fe14..05e255e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,10 +21,75 @@ jobs: allow_failures: - rust: nightly include: - - stage: check # do a pre-screen to make sure this is even worth testing + - &check + stage: check # do a pre-screen to make sure this is even worth testing script: cargo check --all-targets rust: stable os: linux + - <<: *check + rust: 1.0.0 + - <<: *check + rust: 1.1.0 + - <<: *check + rust: 1.2.0 + - <<: *check + rust: 1.3.0 + - <<: *check + rust: 1.4.0 + - <<: *check + rust: 1.5.0 + - <<: *check + rust: 1.6.0 + - <<: *check + rust: 1.7.0 + - <<: *check + rust: 1.8.0 + - <<: *check + rust: 1.0.0 + - <<: *check + rust: 1.10.0 + - <<: *check + rust: 1.11.0 + - <<: *check + rust: 1.12.1 + - <<: *check + rust: 1.13.0 + - <<: *check + rust: 1.14.0 + - <<: *check + rust: 1.15.1 + - <<: *check + rust: 1.16.0 + - <<: *check + rust: 1.17.0 + - <<: *check + rust: 1.18.0 + - <<: *check + rust: 1.19.0 + - <<: *check + rust: 1.20.0 + - <<: *check + rust: 1.21.0 + - <<: *check + rust: 1.22.1 + - <<: *check + rust: 1.23.0 + - <<: *check + rust: 1.24.1 + - <<: *check + rust: 1.25.0 + - <<: *check + rust: 1.26.2 + - <<: *check + rust: 1.27.2 + - <<: *check + rust: 1.28.0 + - <<: *check + rust: 1.29.2 + - <<: *check + rust: 1.30.1 + - <<: *check + rust: 1.31.0 - stage: test rust: stable os: osx From 2d28884da726143624ed28f06334c7ccf6fc7721 Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Sat, 24 Nov 2018 14:13:24 -0500 Subject: [PATCH 8/9] Also test minimum supported Rust version See https://travis-ci.org/jonhoo/rust-imap/builds/459198148. Since b6e9ea080b1bf648c3bac41ad00d421d94e7a9c3, the `crate` issue is fixed, so >=1.26.2 will work. --- .travis.yml | 66 +++-------------------------------------------------- 1 file changed, 3 insertions(+), 63 deletions(-) diff --git a/.travis.yml b/.travis.yml index 05e255e..4616538 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,70 +26,10 @@ jobs: script: cargo check --all-targets rust: stable os: linux - - <<: *check - rust: 1.0.0 - - <<: *check - rust: 1.1.0 - - <<: *check - rust: 1.2.0 - - <<: *check - rust: 1.3.0 - - <<: *check - rust: 1.4.0 - - <<: *check - rust: 1.5.0 - - <<: *check - rust: 1.6.0 - - <<: *check - rust: 1.7.0 - - <<: *check - rust: 1.8.0 - - <<: *check - rust: 1.0.0 - - <<: *check - rust: 1.10.0 - - <<: *check - rust: 1.11.0 - - <<: *check - rust: 1.12.1 - - <<: *check - rust: 1.13.0 - - <<: *check - rust: 1.14.0 - - <<: *check - rust: 1.15.1 - - <<: *check - rust: 1.16.0 - - <<: *check - rust: 1.17.0 - - <<: *check - rust: 1.18.0 - - <<: *check - rust: 1.19.0 - - <<: *check - rust: 1.20.0 - - <<: *check - rust: 1.21.0 - - <<: *check - rust: 1.22.1 - - <<: *check - rust: 1.23.0 - - <<: *check - rust: 1.24.1 - - <<: *check - rust: 1.25.0 - - <<: *check + # <1.24 doesn't work because of lazy-static 1.2.0 + # <1.26.2 doesn't work because of nom 4.1.1 + - <<: *check # also test oldest known-good stable rust: 1.26.2 - - <<: *check - rust: 1.27.2 - - <<: *check - rust: 1.28.0 - - <<: *check - rust: 1.29.2 - - <<: *check - rust: 1.30.1 - - <<: *check - rust: 1.31.0 - stage: test rust: stable os: osx From 1e9ac02b696eeaaff4c47fea97dce42eefe1cee3 Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Sat, 24 Nov 2018 14:32:51 -0500 Subject: [PATCH 9/9] Don't run CI on push except on master This avoids double-testing PRs that are made from branches on jonhoo/rust-imap. --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 4616538..e4cbf9a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,10 @@ rust: - beta - nightly +# only test master on push +# always test things that aren't pushes (like PRs) +if: type != push OR branch = master + before_script: - if [[ "$INTEGRATION" == "true" ]]; then docker pull greenmail/standalone:1.5.8 &&