Skip to content

Commit

Permalink
Fix examples (#1093)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
wathiede committed Apr 20, 2020
1 parent b62e4da commit 6c16c8c
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 14 deletions.
41 changes: 29 additions & 12 deletions ci/check_examples.sh
Expand Up @@ -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
4 changes: 4 additions & 0 deletions examples/futures/src/lib.rs
Expand Up @@ -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) => {
Expand Down
4 changes: 4 additions & 0 deletions examples/minimal/src/lib.rs
Expand Up @@ -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 => {}
Expand Down
4 changes: 4 additions & 0 deletions examples/nested_list/src/app.rs
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions examples/nested_list/src/header.rs
Expand Up @@ -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
}
Expand Down
4 changes: 4 additions & 0 deletions examples/nested_list/src/item.rs
Expand Up @@ -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
}
Expand Down
10 changes: 8 additions & 2 deletions examples/nested_list/src/list.rs
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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(),
}
}
}

0 comments on commit 6c16c8c

Please sign in to comment.