From e353c1cf6f5fd1f194b1a37ef06061dd9519fd13 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 20 Sep 2018 17:54:06 -0700 Subject: [PATCH] Build examples and deploy to gh-pages Rejigger Travis slightly to take advantage of build stages to build the `gh-pages` branch amongst a set of builders, and then when they're all done we synchronize and deploy the site. For now use S3 as a backing store for data between jobs. --- .travis.yml | 55 +++++++++++++++++++++-------- examples/add/README.md | 4 ++- examples/canvas/README.md | 4 ++- examples/char/README.md | 4 ++- examples/closures/README.md | 4 ++- examples/console_log/README.md | 4 ++- examples/dom/README.md | 4 ++- examples/fetch/README.md | 4 ++- examples/hello_world/README.md | 4 ++- examples/import_js/README.md | 4 ++- examples/julia_set/README.md | 4 ++- examples/paint/README.md | 6 ++-- examples/performance/README.md | 4 ++- examples/wasm-in-wasm/README.md | 4 ++- examples/wasm2js/README.md | 4 ++- examples/webaudio/README.md | 4 ++- examples/webgl/README.md | 4 ++- guide/src/examples/2d-canvas.md | 3 +- guide/src/examples/2d-canvas.png | Bin 3799 -> 3800 bytes guide/src/examples/add.md | 3 +- guide/src/examples/char.md | 3 +- guide/src/examples/closures.md | 3 +- guide/src/examples/console-log.md | 3 +- guide/src/examples/dom.md | 3 +- guide/src/examples/fetch.md | 3 +- guide/src/examples/hello-world.md | 3 +- guide/src/examples/import-js.md | 3 +- guide/src/examples/julia.md | 3 +- guide/src/examples/paint.md | 3 +- guide/src/examples/performance.md | 3 +- guide/src/examples/wasm-in-wasm.md | 3 +- guide/src/examples/web-audio.md | 3 +- guide/src/examples/webgl.md | 3 +- 33 files changed, 120 insertions(+), 46 deletions(-) diff --git a/.travis.yml b/.travis.yml index 354a0f5f..1d045516 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,6 +41,12 @@ DEPLOY_TO_GITHUB: &DEPLOY_TO_GITHUB skip_cleanup: true if: branch = master OR branch =~ /^\d/ +INSTALL_AWS: &INSTALL_AWS + | + pip install --user awscli + export PATH=$HOME/.local/bin:$PATH + mkdir -p ~/$TRAVIS_BUILD_NUMBER + matrix: include: # Tests pass on nightly @@ -75,16 +81,18 @@ matrix: env: JOB=examples-build install: - *INSTALL_NODE_VIA_NVM + - *INSTALL_AWS - npm install script: - | for dir in `ls examples | grep -v README | grep -v asm.js | grep -v no_modules`; do (cd examples/$dir && - sed -i 's/: "webpack-dev-server"/: "webpack"/' package.json && + sed -i "s|: \"webpack-dev-server\"|: \"webpack --output-path $HOME/$TRAVIS_BUILD_NUMBER/exbuild/$dir\"|" package.json && sed -i 's/npm install//' build.sh && - ln -s ../../node_modules . && + ln -fs ../../node_modules . && ./build.sh) || exit 1; done + - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then aws s3 sync --quiet ~/$TRAVIS_BUILD_NUMBER s3://wasm-bindgen-ci/$TRAVIS_BUILD_NUMBER; fi if: branch = master # The `web-sys` crate's tests pass on nightly. @@ -170,30 +178,49 @@ matrix: script: cargo check --manifest-path crates/cli/Cargo.toml if: branch = master - # Build documentation for the gh-pages branch + # Build mdbook documentation - rust: nightly - env: JOB=guide-build-and-deploy - cache: - directories: - - $HOME/.cargo - before_script: - - (test -x $HOME/.cargo/bin/cargo-install-update || cargo install cargo-update) - - (test -x $HOME/.cargo/bin/mdbook || cargo install --vers "^0.1" mdbook) - - cargo install-update -a + env: JOB=guide-build + install: + - mkdir -p $HOME/mdbook + - curl -L https://github.com/rust-lang-nursery/mdBook/releases/download/v0.2.1/mdbook-v0.2.1-x86_64-unknown-linux-musl.tar.gz | tar xzf - -C $HOME/mdbook + - export PATH=$PATH:$HOME/mdbook + - *INSTALL_AWS script: - (cd guide && mdbook build) + - rm -rf ~/$TRAVIS_BUILD_NUMBER + - mv guide/book ~/$TRAVIS_BUILD_NUMBER + - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then aws s3 sync --quiet ~/$TRAVIS_BUILD_NUMBER s3://wasm-bindgen-ci/$TRAVIS_BUILD_NUMBER; fi + if: branch = master + + # Build API documentation + - rust: nightly + env: JOB=api-docs + install: *INSTALL_AWS + script: - cargo doc --no-deps - cargo doc --no-deps --manifest-path crates/js-sys/Cargo.toml - cargo doc --no-deps --manifest-path crates/futures/Cargo.toml - cargo doc --no-deps --manifest-path crates/web-sys/Cargo.toml --all-features - - mv target/doc guide/book/api + - mv target/doc ~/$TRAVIS_BUILD_NUMBER/api + - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then aws s3 sync --quiet ~/$TRAVIS_BUILD_NUMBER s3://wasm-bindgen-ci/$TRAVIS_BUILD_NUMBER; fi + if: branch = master + + # Take compiled examples and mdbook/API docs and deploy them to gh-pages + - stage: deploy-gh-pages + install: *INSTALL_AWS + script: + - aws s3 sync --quiet s3://wasm-bindgen-ci/$TRAVIS_BUILD_NUMBER ~/$TRAVIS_BUILD_NUMBER + - mv ~/$TRAVIS_BUILD_NUMBER doc deploy: provider: pages skip-cleanup: true github-token: $GITHUB_TOKEN # Set in travis-ci.org dashboard, marked secure - local-dir: guide/book + local-dir: doc keep-history: false - if: branch = master + after_deploy: + - aws s3 rm --recursive s3://rust-lang-ci-sccache2/$TRAVIS_BUILD_NUMBER + if: branch = master AND type != pull_request notifications: email: diff --git a/examples/add/README.md b/examples/add/README.md index 5bf9743b..57c508e8 100644 --- a/examples/add/README.md +++ b/examples/add/README.md @@ -1,8 +1,10 @@ # Adding numbers (small wasm files) -[View documentation for this example online][dox] +[View documentation for this example online][dox] or [View compiled example +online][compiled] [dox]: https://rustwasm.github.io/wasm-bindgen/examples/add.html +[compiled]: https://rustwasm.github.io/wasm-bindgen/exbuild/add/ You can build the example locally with: diff --git a/examples/canvas/README.md b/examples/canvas/README.md index 914f1b69..2ab89e80 100644 --- a/examples/canvas/README.md +++ b/examples/canvas/README.md @@ -1,7 +1,9 @@ # 2D Canvas -[View documentation for this example online][dox] +[View documentation for this example online][dox] or [View compiled example +online][compiled] +[compiled]: https://rustwasm.github.io/wasm-bindgen/exbuild/canvas/ [dox]: https://rustwasm.github.io/wasm-bindgen/examples/2d-canvas.html You can build the example locally with: diff --git a/examples/char/README.md b/examples/char/README.md index f61c5371..884d9a62 100644 --- a/examples/char/README.md +++ b/examples/char/README.md @@ -1,7 +1,9 @@ # Working with the `char` type -[View documentation for this example online][dox] +[View documentation for this example online][dox] or [View compiled example +online][compiled] +[compiled]: https://rustwasm.github.io/wasm-bindgen/exbuild/char/ [dox]: https://rustwasm.github.io/wasm-bindgen/examples/char.html You can build the example locally with: diff --git a/examples/closures/README.md b/examples/closures/README.md index 7489e6e5..5782c28a 100644 --- a/examples/closures/README.md +++ b/examples/closures/README.md @@ -1,7 +1,9 @@ # web-sys: Closures -[View documentation for this example online][dox] +[View documentation for this example online][dox] or [View compiled example +online][compiled] +[compiled]: https://rustwasm.github.io/wasm-bindgen/exbuild/closures/ [dox]: https://rustwasm.github.io/wasm-bindgen/examples/closures.html You can build the example locally with: diff --git a/examples/console_log/README.md b/examples/console_log/README.md index ab99aaad..c72b418c 100644 --- a/examples/console_log/README.md +++ b/examples/console_log/README.md @@ -1,7 +1,9 @@ # `console.log` -[View documentation for this example online][dox] +[View documentation for this example online][dox] or [View compiled example +online][compiled] +[compiled]: https://rustwasm.github.io/wasm-bindgen/exbuild/console_log/ [dox]: https://rustwasm.github.io/wasm-bindgen/examples/console-log.html You can build the example locally with: diff --git a/examples/dom/README.md b/examples/dom/README.md index ac836931..6fd6c372 100644 --- a/examples/dom/README.md +++ b/examples/dom/README.md @@ -1,7 +1,9 @@ # web-sys: DOM hello world -[View documentation for this example online][dox] +[View documentation for this example online][dox] or [View compiled example +online][compiled] +[compiled]: https://rustwasm.github.io/wasm-bindgen/exbuild/dom/ [dox]: https://rustwasm.github.io/wasm-bindgen/examples/dom.html You can build the example locally with: diff --git a/examples/fetch/README.md b/examples/fetch/README.md index 1ca63780..c3392896 100644 --- a/examples/fetch/README.md +++ b/examples/fetch/README.md @@ -1,7 +1,9 @@ # The `fetch` API -[View documentation for this example online][dox] +[View documentation for this example online][dox] or [View compiled example +online][compiled] +[compiled]: https://rustwasm.github.io/wasm-bindgen/exbuild/fetch/ [dox]: https://rustwasm.github.io/wasm-bindgen/examples/fetch.html You can build the example locally with: diff --git a/examples/hello_world/README.md b/examples/hello_world/README.md index e6f5d18d..74eda63c 100644 --- a/examples/hello_world/README.md +++ b/examples/hello_world/README.md @@ -1,7 +1,9 @@ # Hello, World! -[View documentation for this example online][dox] +[View documentation for this example online][dox] or [View compiled example +online][compiled] +[compiled]: https://rustwasm.github.io/wasm-bindgen/exbuild/hello_world/ [dox]: https://rustwasm.github.io/wasm-bindgen/examples/hello-world.html You can build the example locally with: diff --git a/examples/import_js/README.md b/examples/import_js/README.md index abb1599b..a8badf7a 100644 --- a/examples/import_js/README.md +++ b/examples/import_js/README.md @@ -1,7 +1,9 @@ # Importing non-browser JS -[View documentation for this example online][dox] +[View documentation for this example online][dox] or [View compiled example +online][compiled] +[compiled]: https://rustwasm.github.io/wasm-bindgen/exbuild/import_js/ [dox]: https://rustwasm.github.io/wasm-bindgen/examples/import-js.html You can build the example locally with: diff --git a/examples/julia_set/README.md b/examples/julia_set/README.md index fcf1145e..64d37e23 100644 --- a/examples/julia_set/README.md +++ b/examples/julia_set/README.md @@ -1,7 +1,9 @@ # Julia Set -[View documentation for this example online][dox] +[View documentation for this example online][dox] or [View compiled example +online][compiled] +[compiled]: https://rustwasm.github.io/wasm-bindgen/exbuild/julia_set/ [dox]: https://rustwasm.github.io/wasm-bindgen/examples/julia.html You can build the example locally with: diff --git a/examples/paint/README.md b/examples/paint/README.md index 255f1250..c1909b2e 100644 --- a/examples/paint/README.md +++ b/examples/paint/README.md @@ -1,8 +1,10 @@ # Paint Example -[View documentation for this example online][dox] +[View documentation for this example online][dox] or [View compiled example +online][compiled] -[dox]: https://rustwasm.github.io/wasm-bindgen/examples/console-log.html +[compiled]: https://rustwasm.github.io/wasm-bindgen/exbuild/paint/ +[dox]: https://rustwasm.github.io/wasm-bindgen/examples/paint.html You can build the example locally with: diff --git a/examples/performance/README.md b/examples/performance/README.md index c1ee03b3..f328264d 100644 --- a/examples/performance/README.md +++ b/examples/performance/README.md @@ -1,7 +1,9 @@ # web-sys: `performance.now` -[View documentation for this example online][dox] +[View documentation for this example online][dox] or [View compiled example +online][compiled] +[compiled]: https://rustwasm.github.io/wasm-bindgen/exbuild/performance/ [dox]: https://rustwasm.github.io/wasm-bindgen/examples/performance.html You can build the example locally with: diff --git a/examples/wasm-in-wasm/README.md b/examples/wasm-in-wasm/README.md index fc46936b..ab17ae81 100644 --- a/examples/wasm-in-wasm/README.md +++ b/examples/wasm-in-wasm/README.md @@ -1,7 +1,9 @@ # js-sys: WebAssembly in WebAssembly -[View documentation for this example online][dox] +[View documentation for this example online][dox] or [View compiled example +online][compiled] +[compiled]: https://rustwasm.github.io/wasm-bindgen/exbuild/wasm-in-wasm/ [dox]: https://rustwasm.github.io/wasm-bindgen/examples/wasm-in-wasm.html You can build the example locally with: diff --git a/examples/wasm2js/README.md b/examples/wasm2js/README.md index b87905a7..c3d2950f 100644 --- a/examples/wasm2js/README.md +++ b/examples/wasm2js/README.md @@ -1,7 +1,9 @@ # Converting WebAssembly to JS -[View documentation for this example online][dox] +[View documentation for this example online][dox] or [View compiled example +online][compiled] +[compiled]: https://rustwasm.github.io/wasm-bindgen/exbuild/wasm2js/ [dox]: https://rustwasm.github.io/wasm-bindgen/examples/wasm2js.html You can build the example locally with: diff --git a/examples/webaudio/README.md b/examples/webaudio/README.md index 73465f63..14d4b50f 100644 --- a/examples/webaudio/README.md +++ b/examples/webaudio/README.md @@ -1,7 +1,9 @@ # WebAudio -[View documentation for this example online][dox] +[View documentation for this example online][dox] or [View compiled example +online][compiled] +[compiled]: https://rustwasm.github.io/wasm-bindgen/exbuild/web-audio/ [dox]: https://rustwasm.github.io/wasm-bindgen/examples/web-audio.html You can build the example locally with: diff --git a/examples/webgl/README.md b/examples/webgl/README.md index c57db471..e6de7fb3 100755 --- a/examples/webgl/README.md +++ b/examples/webgl/README.md @@ -1,7 +1,9 @@ # WebGL Example -[View documentation for this example online][dox] +[View documentation for this example online][dox] or [View compiled example +online][compiled] +[compiled]: https://rustwasm.github.io/wasm-bindgen/exbuild/webgl/ [dox]: https://rustwasm.github.io/wasm-bindgen/examples/webgl.html You can build the example locally with: diff --git a/guide/src/examples/2d-canvas.md b/guide/src/examples/2d-canvas.md index 69527cbf..baf378ad 100644 --- a/guide/src/examples/2d-canvas.md +++ b/guide/src/examples/2d-canvas.md @@ -1,7 +1,8 @@ # 2D Canvas -[View full source code][code] +[View full source code][code] or [view the compiled example online][online] +[online]: https://rustwasm.github.io/wasm-bindgen/exbuild/canvas/ [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/canvas Drawing a smiley face with the 2D canvas API. This is a port of part of [this diff --git a/guide/src/examples/2d-canvas.png b/guide/src/examples/2d-canvas.png index 394081092aee119f31456ea1a3fa846642623b16..6369748471304498ac299c049610832a27aca8e8 100644 GIT binary patch delta 9 QcmcaEdqZ}^bv{Ne02UYniU0rr delta 7 Ocmca1dtG+Jbv^(O5CeYz diff --git a/guide/src/examples/add.md b/guide/src/examples/add.md index 12f903f3..79fea0e1 100644 --- a/guide/src/examples/add.md +++ b/guide/src/examples/add.md @@ -1,7 +1,8 @@ # Small wasm files -[View full source code][code] +[View full source code][code] or [view the compiled example online][online] +[online]: https://rustwasm.github.io/wasm-bindgen/exbuild/add/ [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/add One of `wasm-bindgen`'s core goals is a pay-only-for-what-you-use philosophy, so diff --git a/guide/src/examples/char.md b/guide/src/examples/char.md index a2d4669f..f2447dca 100644 --- a/guide/src/examples/char.md +++ b/guide/src/examples/char.md @@ -1,7 +1,8 @@ # Working with the `char` type -[View full source code][code] +[View full source code][code] or [view the compiled example online][online] +[online]: https://rustwasm.github.io/wasm-bindgen/exbuild/char/ [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/char The `#[wasm_bindgen]` macro will convert the rust `char` type to a single diff --git a/guide/src/examples/closures.md b/guide/src/examples/closures.md index 7ab76d69..d9a60bfd 100644 --- a/guide/src/examples/closures.md +++ b/guide/src/examples/closures.md @@ -1,7 +1,8 @@ # web-sys: Closures -[View full source code][code] +[View full source code][code] or [view the compiled example online][online] +[online]: https://rustwasm.github.io/wasm-bindgen/exbuild/closures/ [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/closures One of the features of `#[wasm_bindgen]` is that you can pass closures defined diff --git a/guide/src/examples/console-log.md b/guide/src/examples/console-log.md index 94b665de..78004b85 100644 --- a/guide/src/examples/console-log.md +++ b/guide/src/examples/console-log.md @@ -1,7 +1,8 @@ # `console.log` -[View full source code][code] +[View full source code][code] or [view the compiled example online][online] +[online]: https://rustwasm.github.io/wasm-bindgen/exbuild/console_log/ [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/console_log This example shows off how to use `console.log` in a variety of ways, all the diff --git a/guide/src/examples/dom.md b/guide/src/examples/dom.md index db2915d1..358c0e3e 100644 --- a/guide/src/examples/dom.md +++ b/guide/src/examples/dom.md @@ -1,7 +1,8 @@ # web-sys: DOM hello world -[View full source code][code] +[View full source code][code] or [view the compiled example online][online] +[online]: https://rustwasm.github.io/wasm-bindgen/exbuild/dom/ [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/dom Using `web-sys` we're able to interact with all the standard web platform diff --git a/guide/src/examples/fetch.md b/guide/src/examples/fetch.md index fdd03c1f..521e8dd7 100644 --- a/guide/src/examples/fetch.md +++ b/guide/src/examples/fetch.md @@ -1,7 +1,8 @@ # The `fetch` API -[View full source code][code] +[View full source code][code] or [view the compiled example online][online] +[online]: https://rustwasm.github.io/wasm-bindgen/exbuild/fetch/ [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/fetch This example uses the `fetch` API to make an HTTP request to the GitHub API and diff --git a/guide/src/examples/hello-world.md b/guide/src/examples/hello-world.md index 457c95ac..2efc9256 100644 --- a/guide/src/examples/hello-world.md +++ b/guide/src/examples/hello-world.md @@ -1,7 +1,8 @@ # Hello, World! -[View full source code][code] +[View full source code][code] or [view the compiled example online][online] +[online]: https://rustwasm.github.io/wasm-bindgen/exbuild/hello_world/ [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/hello_world This is the "Hello, world!" example of `#[wasm_bindgen]` showing how to set up diff --git a/guide/src/examples/import-js.md b/guide/src/examples/import-js.md index 3cd6f17c..c4ae9712 100644 --- a/guide/src/examples/import-js.md +++ b/guide/src/examples/import-js.md @@ -1,7 +1,8 @@ # Importing non-browser JS -[View full source code][code] +[View full source code][code] or [view the compiled example online][online] +[online]: https://rustwasm.github.io/wasm-bindgen/exbuild/import_js/ [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/import_js The `#[wasm_bindgen]` attribute can be used on `extern { .. }` blocks to import diff --git a/guide/src/examples/julia.md b/guide/src/examples/julia.md index 0a57ddfb..dc338803 100644 --- a/guide/src/examples/julia.md +++ b/guide/src/examples/julia.md @@ -1,7 +1,8 @@ # Julia Set -[View full source code][code] +[View full source code][code] or [view the compiled example online][online] +[online]: https://rustwasm.github.io/wasm-bindgen/exbuild/julia_set/ [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/julia_set While not showing off a lot of `web_sys` API surface area, this example shows a diff --git a/guide/src/examples/paint.md b/guide/src/examples/paint.md index 2651aea8..f69017d7 100644 --- a/guide/src/examples/paint.md +++ b/guide/src/examples/paint.md @@ -1,7 +1,8 @@ # Paint Example -[View full source code][code] +[View full source code][code] or [view the compiled example online][online] +[online]: https://rustwasm.github.io/wasm-bindgen/exbuild/paint/ [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/paint A simple painting program. diff --git a/guide/src/examples/performance.md b/guide/src/examples/performance.md index e5deffe6..6ff65d2c 100644 --- a/guide/src/examples/performance.md +++ b/guide/src/examples/performance.md @@ -1,7 +1,8 @@ # web-sys: `performance.now` -[View full source code][code] +[View full source code][code] or [view the compiled example online][online] +[online]: https://rustwasm.github.io/wasm-bindgen/exbuild/performance/ [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/performance Want to profile some Rust code in the browser? No problem! You can use the diff --git a/guide/src/examples/wasm-in-wasm.md b/guide/src/examples/wasm-in-wasm.md index 8ce0572e..355f567c 100644 --- a/guide/src/examples/wasm-in-wasm.md +++ b/guide/src/examples/wasm-in-wasm.md @@ -1,7 +1,8 @@ # js-sys: WebAssembly in WebAssembly -[View full source code][code] +[View full source code][code] or [view the compiled example online][online] +[online]: https://rustwasm.github.io/wasm-bindgen/exbuild/wasm-in-wasm/ [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/wasm-in-wasm Using the `js-sys` crate we can get pretty meta and instantiate `WebAssembly` diff --git a/guide/src/examples/web-audio.md b/guide/src/examples/web-audio.md index 8b8b80c2..ed41f7a0 100644 --- a/guide/src/examples/web-audio.md +++ b/guide/src/examples/web-audio.md @@ -1,7 +1,8 @@ # WebAudio -[View full source code][code] +[View full source code][code] or [view the compiled example online][online] +[online]: https://rustwasm.github.io/wasm-bindgen/exbuild/webaudio/ [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/webaudio This example creates an [FM diff --git a/guide/src/examples/webgl.md b/guide/src/examples/webgl.md index 82ac2471..8086a875 100644 --- a/guide/src/examples/webgl.md +++ b/guide/src/examples/webgl.md @@ -1,7 +1,8 @@ # WebGL Example -[View full source code][code] +[View full source code][code] or [view the compiled example online][online] +[online]: https://rustwasm.github.io/wasm-bindgen/exbuild/webgl/ [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/webgl This example draws a triangle to the screen using the WebGL API.