Merge pull request #863 from alexcrichton/deploy-examples

Build examples and deploy to gh-pages
This commit is contained in:
Sendil Kumar N 2018-09-21 11:49:59 +02:00 committed by GitHub
commit 9b758767c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 120 additions and 46 deletions

View File

@ -41,6 +41,12 @@ DEPLOY_TO_GITHUB: &DEPLOY_TO_GITHUB
skip_cleanup: true skip_cleanup: true
if: branch = master OR branch =~ /^\d/ 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: matrix:
include: include:
# Tests pass on nightly # Tests pass on nightly
@ -75,16 +81,18 @@ matrix:
env: JOB=examples-build env: JOB=examples-build
install: install:
- *INSTALL_NODE_VIA_NVM - *INSTALL_NODE_VIA_NVM
- *INSTALL_AWS
- npm install - npm install
script: script:
- | - |
for dir in `ls examples | grep -v README | grep -v asm.js | grep -v no_modules`; do for dir in `ls examples | grep -v README | grep -v asm.js | grep -v no_modules`; do
(cd examples/$dir && (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 && sed -i 's/npm install//' build.sh &&
ln -s ../../node_modules . && ln -fs ../../node_modules . &&
./build.sh) || exit 1; ./build.sh) || exit 1;
done 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 if: branch = master
# The `web-sys` crate's tests pass on nightly. # The `web-sys` crate's tests pass on nightly.
@ -170,30 +178,49 @@ matrix:
script: cargo check --manifest-path crates/cli/Cargo.toml script: cargo check --manifest-path crates/cli/Cargo.toml
if: branch = master if: branch = master
# Build documentation for the gh-pages branch # Build mdbook documentation
- rust: nightly - rust: nightly
env: JOB=guide-build-and-deploy env: JOB=guide-build
cache: install:
directories: - mkdir -p $HOME/mdbook
- $HOME/.cargo - 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
before_script: - export PATH=$PATH:$HOME/mdbook
- (test -x $HOME/.cargo/bin/cargo-install-update || cargo install cargo-update) - *INSTALL_AWS
- (test -x $HOME/.cargo/bin/mdbook || cargo install --vers "^0.1" mdbook)
- cargo install-update -a
script: script:
- (cd guide && mdbook build) - (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
- cargo doc --no-deps --manifest-path crates/js-sys/Cargo.toml - 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/futures/Cargo.toml
- cargo doc --no-deps --manifest-path crates/web-sys/Cargo.toml --all-features - 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: deploy:
provider: pages provider: pages
skip-cleanup: true skip-cleanup: true
github-token: $GITHUB_TOKEN # Set in travis-ci.org dashboard, marked secure github-token: $GITHUB_TOKEN # Set in travis-ci.org dashboard, marked secure
local-dir: guide/book local-dir: doc
keep-history: false 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: notifications:
email: email:

View File

@ -1,8 +1,10 @@
# Adding numbers (small wasm files) # 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 [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: You can build the example locally with:

View File

@ -1,7 +1,9 @@
# 2D Canvas # 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 [dox]: https://rustwasm.github.io/wasm-bindgen/examples/2d-canvas.html
You can build the example locally with: You can build the example locally with:

View File

@ -1,7 +1,9 @@
# Working with the `char` type # 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 [dox]: https://rustwasm.github.io/wasm-bindgen/examples/char.html
You can build the example locally with: You can build the example locally with:

View File

@ -1,7 +1,9 @@
# web-sys: Closures # 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 [dox]: https://rustwasm.github.io/wasm-bindgen/examples/closures.html
You can build the example locally with: You can build the example locally with:

View File

@ -1,7 +1,9 @@
# `console.log` # `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 [dox]: https://rustwasm.github.io/wasm-bindgen/examples/console-log.html
You can build the example locally with: You can build the example locally with:

View File

@ -1,7 +1,9 @@
# web-sys: DOM hello world # 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 [dox]: https://rustwasm.github.io/wasm-bindgen/examples/dom.html
You can build the example locally with: You can build the example locally with:

View File

@ -1,7 +1,9 @@
# The `fetch` API # 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 [dox]: https://rustwasm.github.io/wasm-bindgen/examples/fetch.html
You can build the example locally with: You can build the example locally with:

View File

@ -1,7 +1,9 @@
# Hello, World! # 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 [dox]: https://rustwasm.github.io/wasm-bindgen/examples/hello-world.html
You can build the example locally with: You can build the example locally with:

View File

@ -1,7 +1,9 @@
# Importing non-browser JS # 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 [dox]: https://rustwasm.github.io/wasm-bindgen/examples/import-js.html
You can build the example locally with: You can build the example locally with:

View File

@ -1,7 +1,9 @@
# Julia Set # 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 [dox]: https://rustwasm.github.io/wasm-bindgen/examples/julia.html
You can build the example locally with: You can build the example locally with:

View File

@ -1,8 +1,10 @@
# Paint Example # 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: You can build the example locally with:

View File

@ -1,7 +1,9 @@
# web-sys: `performance.now` # 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 [dox]: https://rustwasm.github.io/wasm-bindgen/examples/performance.html
You can build the example locally with: You can build the example locally with:

View File

@ -1,7 +1,9 @@
# js-sys: WebAssembly in WebAssembly # 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 [dox]: https://rustwasm.github.io/wasm-bindgen/examples/wasm-in-wasm.html
You can build the example locally with: You can build the example locally with:

View File

@ -1,7 +1,9 @@
# Converting WebAssembly to JS # 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 [dox]: https://rustwasm.github.io/wasm-bindgen/examples/wasm2js.html
You can build the example locally with: You can build the example locally with:

View File

@ -1,7 +1,9 @@
# WebAudio # 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 [dox]: https://rustwasm.github.io/wasm-bindgen/examples/web-audio.html
You can build the example locally with: You can build the example locally with:

View File

@ -1,7 +1,9 @@
# WebGL Example # 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 [dox]: https://rustwasm.github.io/wasm-bindgen/examples/webgl.html
You can build the example locally with: You can build the example locally with:

View File

@ -1,7 +1,8 @@
# 2D Canvas # 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 [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 Drawing a smiley face with the 2D canvas API. This is a port of part of [this

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -1,7 +1,8 @@
# Small wasm files # 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 [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 One of `wasm-bindgen`'s core goals is a pay-only-for-what-you-use philosophy, so

View File

@ -1,7 +1,8 @@
# Working with the `char` type # 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 [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/char
The `#[wasm_bindgen]` macro will convert the rust `char` type to a single The `#[wasm_bindgen]` macro will convert the rust `char` type to a single

View File

@ -1,7 +1,8 @@
# web-sys: Closures # 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 [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 One of the features of `#[wasm_bindgen]` is that you can pass closures defined

View File

@ -1,7 +1,8 @@
# `console.log` # `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 [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 This example shows off how to use `console.log` in a variety of ways, all the

View File

@ -1,7 +1,8 @@
# web-sys: DOM hello world # 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 [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 Using `web-sys` we're able to interact with all the standard web platform

View File

@ -1,7 +1,8 @@
# The `fetch` API # 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 [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 This example uses the `fetch` API to make an HTTP request to the GitHub API and

View File

@ -1,7 +1,8 @@
# Hello, World! # 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 [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 This is the "Hello, world!" example of `#[wasm_bindgen]` showing how to set up

View File

@ -1,7 +1,8 @@
# Importing non-browser JS # 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 [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/import_js
The `#[wasm_bindgen]` attribute can be used on `extern { .. }` blocks to import The `#[wasm_bindgen]` attribute can be used on `extern { .. }` blocks to import

View File

@ -1,7 +1,8 @@
# Julia Set # 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 [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 While not showing off a lot of `web_sys` API surface area, this example shows a

View File

@ -1,7 +1,8 @@
# Paint Example # 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 [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/paint
A simple painting program. A simple painting program.

View File

@ -1,7 +1,8 @@
# web-sys: `performance.now` # 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 [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 Want to profile some Rust code in the browser? No problem! You can use the

View File

@ -1,7 +1,8 @@
# js-sys: WebAssembly in WebAssembly # 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 [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` Using the `js-sys` crate we can get pretty meta and instantiate `WebAssembly`

View File

@ -1,7 +1,8 @@
# WebAudio # 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 [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/webaudio
This example creates an [FM This example creates an [FM

View File

@ -1,7 +1,8 @@
# WebGL Example # 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 [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/webgl
This example draws a triangle to the screen using the WebGL API. This example draws a triangle to the screen using the WebGL API.