From 636bbc7c8f88585bc4aa22aabea47373fe92aa59 Mon Sep 17 00:00:00 2001
From: "Lilian A. Moraru" <lilian.moraru90@gmail.com>
Date: Tue, 19 Dec 2017 01:04:49 +0200
Subject: [PATCH] Speeding CI builds

---
 .travis.yml         |  2 ++
 Cargo.toml          |  3 +++
 appveyor.yml        | 29 +++++++++++++++++++++--------
 ci/script.sh        | 14 ++------------
 ignore/Cargo.toml   |  3 ---
 wincolor/src/lib.rs |  3 +++
 6 files changed, 31 insertions(+), 23 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 6fa631e7..fd329d75 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,4 +1,5 @@
 language: rust
+cache:    cargo
 
 env:
   global:
@@ -12,6 +13,7 @@ addons:
       - zsh
 
 matrix:
+  fast_finish: true
   include:
     # Nightly channel.
     # (All *nix releases are done on the nightly channel to take advantage
diff --git a/Cargo.toml b/Cargo.toml
index f66cc17b..dcc2227a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -29,6 +29,9 @@ name = "rg"
 name = "integration"
 path = "tests/tests.rs"
 
+[workspace]
+members = [ "grep", "globset", "ignore", "termcolor", "wincolor" ]
+
 [dependencies]
 atty = "0.2.2"
 bytecount = "0.2"
diff --git a/appveyor.yml b/appveyor.yml
index 2aa4c526..6f9d73cb 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,4 +1,20 @@
+# Inspired from https://github.com/habitat-sh/habitat/blob/master/appveyor.yml
+cache:
+  - c:\cargo\registry
+  - c:\cargo\git
+  - c:\projects\ripgrep\target
+
+init:
+  - mkdir c:\cargo
+  - mkdir c:\rustup
+  - SET PATH=c:\cargo\bin;%PATH%
+
+clone_folder: c:\projects\ripgrep
+
 environment:
+  CARGO_HOME: "c:\\cargo"
+  RUSTUP_HOME: "c:\\rustup"
+  CARGO_TARGET_DIR: "c:\\projects\\ripgrep\\target"
   global:
     PROJECT_NAME: ripgrep
     RUST_BACKTRACE: full
@@ -12,12 +28,14 @@ environment:
     - TARGET: x86_64-pc-windows-msvc
       CHANNEL: stable
 
+matrix:
+  fast_finish: true
+
 # Install Rust and Cargo
 # (Based on from https://github.com/rust-lang/libc/blob/master/appveyor.yml)
 install:
   - curl -sSf -o rustup-init.exe https://win.rustup.rs/
-  - rustup-init.exe -y --default-host %TARGET%
-  - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
+  - rustup-init.exe -y --default-host %TARGET% --no-modify-path
   - if defined MSYS2_BITS set PATH=%PATH%;C:\msys64\mingw%MSYS2_BITS%\bin
   - rustc -V
   - cargo -V
@@ -28,12 +46,7 @@ build: false
 # Equivalent to Travis' `script` phase
 # TODO modify this phase as you see fit
 test_script:
-  - cargo test --verbose
-  - cargo test --verbose --manifest-path grep/Cargo.toml
-  - cargo test --verbose --manifest-path globset/Cargo.toml
-  - cargo test --verbose --manifest-path ignore/Cargo.toml
-  - cargo test --verbose --manifest-path wincolor/Cargo.toml
-  - cargo test --verbose --manifest-path termcolor/Cargo.toml
+  - cargo test --verbose --all
 
 before_deploy:
   # Generate artifacts for release
diff --git a/ci/script.sh b/ci/script.sh
index 299f562f..32aef003 100644
--- a/ci/script.sh
+++ b/ci/script.sh
@@ -4,9 +4,6 @@ set -ex
 
 . $(dirname $0)/utils.sh
 
-# "." - dot is for the current directory(ripgrep itself)
-components=( . grep globset ignore termcolor )
-
 # NOTE Workaround for rust-lang/rust#31907 - disable doc tests when cross compiling
 # This has been fixed in the nightly channel but it would take a while to reach the other channels
 disable_cross_doctests() {
@@ -18,18 +15,11 @@ disable_cross_doctests() {
     fi
 }
 
-run_cargo() {
-    for component in "${components[@]}"; do
-        cargo "${1:?}" --target $TARGET --verbose --manifest-path "${component}/Cargo.toml"
-    done
-}
-
 main() {
     # disable_cross_doctests
-    run_cargo clean
-    run_cargo build
+    cargo build --target "${TARGET}" --verbose --all
     if [ "$(architecture)" = "amd64" ] || [ "$(architecture)" = "i386" ]; then
-        run_cargo test
+        cargo test --target "${TARGET}" --verbose --all
         "$( dirname "${0}" )/test_complete.sh"
     fi
 
diff --git a/ignore/Cargo.toml b/ignore/Cargo.toml
index 14a07a90..fbdbc5e0 100644
--- a/ignore/Cargo.toml
+++ b/ignore/Cargo.toml
@@ -33,6 +33,3 @@ tempdir = "0.3.5"
 
 [features]
 simd-accel = ["globset/simd-accel"]
-
-[profile.release]
-debug = true
diff --git a/wincolor/src/lib.rs b/wincolor/src/lib.rs
index 44c9e410..457f33ae 100644
--- a/wincolor/src/lib.rs
+++ b/wincolor/src/lib.rs
@@ -8,6 +8,8 @@ Note that on non-Windows platforms, this crate is empty but will compile.
 # Example
 
 ```no_run
+# #[cfg(windows)]
+# {
 use wincolor::{Console, Color, Intense};
 
 let mut con = Console::stdout().unwrap();
@@ -15,6 +17,7 @@ con.fg(Intense::Yes, Color::Cyan).unwrap();
 println!("This text will be intense cyan.");
 con.reset().unwrap();
 println!("This text will be normal.");
+# }
 ```
 */