From 22e0300275830cf4bd66b2a0ca33eca2f063f9d4 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Tue, 14 Aug 2018 21:53:35 -0400 Subject: [PATCH] Test adding WASM support --- .gitignore | 3 ++- .travis.yml | 6 ++++++ Cargo.toml | 2 +- ci/script.sh | 24 ++++++++++++++++++++++-- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 3ea4a60..4916daa 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ Cargo.lock .vscode *.pyc -.idea/ \ No newline at end of file +.idea/ +*.swp diff --git a/.travis.yml b/.travis.yml index 22ee447..0c1961f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,8 @@ dist: trusty language: rust services: docker sudo: required +addons: + chrome: stable env: global: @@ -89,6 +91,10 @@ matrix: rust: 1.26.0 - env: TARGET=x86_64-unknown-linux-gnu rust: 1.27.0 + + # WASM support + - env: TARGET=asmjs-unknown-empscripten USE_CARGO_WEB=true + rust: nightly before_install: diff --git a/Cargo.toml b/Cargo.toml index c17b949..8438c5d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,4 +20,4 @@ name = "dtparse" chrono = "0.4" lazy_static = "1.1" num-traits = "0.2" -rust_decimal = "0.10" +rust_decimal = "^0.10.1" diff --git a/ci/script.sh b/ci/script.sh index 5549e97..4c501e0 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -14,7 +14,27 @@ main() { cross test --target $TARGET --release } +main_web() { + CARGO_WEB_RELEASE="$(curl -L -s -H 'Accept: application/json' https://github.com/koute/cargo-web/releases/latest)" + CARGO_WEB_VERSION="$(echo $CARGO_WEB_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')" + CARGO_WEB_URL="https://github.com/koute/cargo-web/releases/download/$CARGO_WEB_VERSION/cargo-web-x86_64-unknown-linux-gnu.gz" + + echo "Downloading cargo-web from: $CARGO_WEB_URL" + curl -L "$CARGO_WEB_URL" | gzip -d > cargo-web + chmod +x cargo-web + + mkdir -p ~/.cargo/bin + mv cargo-web ~/.cargo/bin + + cargo web build --target $TARGET + cargo web test --target $TARGET --release +} + # we don't run the "test phase" when doing deploys if [ -z $TRAVIS_TAG ]; then - main -fi \ No newline at end of file + if [ -z "$USE_CARGO_WEB" ]; then + main + else + main_web + fi +fi