From a557b3cfb60bbd1d75ffd6dfd8e52c4ceea95167 Mon Sep 17 00:00:00 2001
From: Ryan G <ryanisaacg@users.noreply.github.com>
Date: Sat, 12 Oct 2019 23:44:30 -0400
Subject: [PATCH] Add web targets to travis (#1220)

* Add web targets to travis

* Fix some bash syntax

* Avoid crash on providing no features

* Fix syntax error

* Syntax?

* Fix pleas

* Fix features check

* Add a comment

* Add nightly builds
---
 .travis.yml | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index aaa56d9e..7a73219b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -58,6 +58,21 @@ matrix:
       os: osx
       rust: stable
 
+    # wasm stdweb
+    - env: TARGET=wasm32-unknown-unknown WEB=web FEATURES=stdweb
+      os: linux
+      rust: stable
+    - env: TARGET=wasm32-unknown-unknown WEB=web FEATURES=stdweb
+      os: linux
+      rust: nightly
+    # wasm web-sys
+    - env: TARGET=wasm32-unknown-unknown FEATURES=web-sys
+      os: linux
+      rust: stable
+    - env: TARGET=wasm32-unknown-unknown FEATURES=web-sys
+      os: linux
+      rust: nightly
+
 install:
   - rustup self update
   - rustup target add $TARGET; true
@@ -66,11 +81,19 @@ install:
 
 script:
   - cargo +stable fmt --all -- --check
-  - cargo build --target $TARGET --verbose
-  - cargo build --target $TARGET --features serde --verbose
+  # Install cargo-web to build stdweb
+  - if [[ $WEB = "web" ]]; then cargo install -f cargo-web; fi
+  # Build without serde then with serde
+  - if [[ -z "$FEATURES" ]]; then
+      cargo $WEB build --target $TARGET --verbose;
+    else
+      cargo $WEB build --target $TARGET --features $FEATURES --verbose;
+    fi
+  - cargo $WEB build --target $TARGET --features serde,$FEATURES --verbose
   # Running iOS apps on macOS requires the Simulator so we skip that for now
-  - if [[ $TARGET != *-apple-ios ]]; then cargo test --target $TARGET --verbose; fi
-  - if [[ $TARGET != *-apple-ios ]]; then cargo test --target $TARGET --features serde --verbose; fi
+  # The web targets also don't support running tests
+  - if [[ $TARGET != *-apple-ios && $TARGET != wasm32-* ]]; then cargo test --target $TARGET --verbose; fi
+  - if [[ $TARGET != *-apple-ios && $TARGET != wasm32-* ]]; then cargo test --target $TARGET --features serde --verbose; fi
 
 after_success:
   - |