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.
This commit is contained in:
Alex Crichton 2018-09-20 17:54:06 -07:00
parent f871cf6354
commit e353c1cf6f
33 changed files with 120 additions and 46 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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

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
[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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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`

View File

@ -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

View File

@ -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.