Fix examples (#1093)

* ci: verify all examples build.

Using examples/showcase masked breakages in multiple examples.

* examples/future: add change implementation.

* examples/minimal: add change implementation.

* examples/nested_list: add change implementation.

* ci: add block lists to skip some examples.
This commit is contained in:
Bill 2020-04-20 00:42:50 -07:00 committed by GitHub
parent b62e4daf47
commit 6c16c8c134
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 57 additions and 14 deletions

View File

@ -3,19 +3,36 @@ echo "$(rustup default)" | grep -q "1.39.0"
emscripten_supported=$?
set -euxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
# Showcase includes all other examples
cd examples/showcase
# Some examples are known not to work with some builds, i.e. futures with the
# std_web feature. Other items in the examples/ directory are helpers, i.e.
# pub_sub and server. These block lists allow us to exempt some examples but
# default opt-in any new examples to CI testing.
COMMON_SKIP_EXAMPLES="examples/static examples/pub_sub examples/server \
examples/target examples/web_sys examples/std_web"
STD_WEB_SKIP_EXAMPLES="${COMMON_SKIP_EXAMPLES:?} examples/futures"
WEB_SYS_SKIP_EXAMPLES="${COMMON_SKIP_EXAMPLES:?}"
# TODO Can't build some demos with release, need fix
# Make sure all examples are buildable with stdweb and web-sys.
for ex in $(find examples -maxdepth 1 -mindepth 1 -type d); do
pushd $ex
if [ "$emscripten_supported" == "0" ]; then
# TODO - Emscripten builds are broken on rustc > 1.39.0
cargo web build --target asmjs-unknown-emscripten --features std_web
cargo web build --target wasm32-unknown-emscripten --features std_web
fi
# TODO Can't build some demos with release, need fix
cargo web build --target wasm32-unknown-unknown --features std_web
cargo build --target wasm32-unknown-unknown --features web_sys
if [ "$emscripten_supported" == "0" ]; then
if [[ ! " ${STD_WEB_SKIP_EXAMPLES[@]} " =~ " ${ex} " ]]; then
# TODO - Emscripten builds are broken on rustc > 1.39.0
cargo web build --target asmjs-unknown-emscripten --features std_web
cargo web build --target wasm32-unknown-emscripten --features std_web
fi
fi
# Reset cwd
cd ../..
if [[ ! " ${STD_WEB_SKIP_EXAMPLES[@]} " =~ " ${ex} " ]]; then
cargo web build --target wasm32-unknown-unknown --features std_web
fi
if [[ ! " ${WEB_SYS_SKIP_EXAMPLES[@]} " =~ " ${ex} " ]]; then
cargo build --target wasm32-unknown-unknown --features web_sys
fi
# Reset cwd
popd
done

View File

@ -101,6 +101,10 @@ impl Component for Model {
}
}
fn change(&mut self, _: Self::Properties) -> bool {
false
}
fn update(&mut self, msg: Self::Message) -> ShouldRender {
match msg {
Msg::SetMarkdownFetchState(fetch_state) => {

View File

@ -16,6 +16,10 @@ impl Component for Model {
Model { link }
}
fn change(&mut self, _: Self::Properties) -> bool {
false
}
fn update(&mut self, msg: Self::Message) -> ShouldRender {
match msg {
Msg::Click => {}

View File

@ -24,6 +24,10 @@ impl Component for App {
}
}
fn change(&mut self, _: Self::Properties) -> bool {
false
}
fn update(&mut self, msg: Self::Message) -> ShouldRender {
match msg {
Msg::Hover(hovered) => self.hovered = hovered,

View File

@ -21,6 +21,10 @@ impl Component for ListHeader {
ListHeader { props }
}
fn change(&mut self, _: Self::Properties) -> bool {
false
}
fn update(&mut self, _: Self::Message) -> ShouldRender {
false
}

View File

@ -24,6 +24,10 @@ impl Component for ListItem {
ListItem { props }
}
fn change(&mut self, _: Self::Properties) -> bool {
false
}
fn update(&mut self, _msg: Self::Message) -> ShouldRender {
false
}

View File

@ -56,6 +56,10 @@ impl Component for List {
}
}
fn change(&mut self, _: Self::Properties) -> bool {
false
}
fn update(&mut self, msg: Self::Message) -> ShouldRender {
match msg {
Msg::HeaderClick => {
@ -122,8 +126,10 @@ where
impl Into<VNode> for ListVariant {
fn into(self) -> VNode {
match self.props {
Variants::Header(props) => VComp::new::<ListHeader>(props, NodeRef::default()).into(),
Variants::Item(props) => VComp::new::<ListItem>(props, NodeRef::default()).into(),
Variants::Header(props) => {
VComp::new::<ListHeader>(props, NodeRef::default(), None).into()
}
Variants::Item(props) => VComp::new::<ListItem>(props, NodeRef::default(), None).into(),
}
}
}