mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
Adopt cargo-make (#1541)
* format and cleanup * remove bash scripts * update pr template * ignore router examples * add pr-flow task * I really don't know what I'm doing * add wasm_bench feature * well that explains one of my issues also, that Geckodriver issue seems to be resolved * run macro tests on 1.45.2 * update the documentation * test flags no longer necessary * remove benchmark instructions * finishing touch
This commit is contained in:
parent
69016bb990
commit
b6e98adac0
26
.github/PULL_REQUEST_TEMPLATE.md
vendored
26
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -1,25 +1,15 @@
|
||||
#### Description
|
||||
|
||||
<!-- Please include a summary of the change and which issue is fixed. -->
|
||||
<!-- Please include a summary of the change. -->
|
||||
|
||||
Fixes # (issue)
|
||||
Fixes #0000 <!-- replace with issue number or remove if not applicable -->
|
||||
|
||||
#### Checklist:
|
||||
#### Checklist
|
||||
|
||||
- [ ] I have run `./ci/run_stable_checks.sh`
|
||||
<!-- For further details, please read CONTRIBUTING.md -->
|
||||
|
||||
- [ ] I have run `cargo make pr-flow`
|
||||
- [ ] I have reviewed my own code
|
||||
- [ ] I have added tests
|
||||
<!-- If this is a bug fix, these tests will fail if the bug is present (to stop it from cropping up again) -->
|
||||
<!-- If this is a feature, my tests prove that the feature works -->
|
||||
|
||||
<!-- Testing instructions -->
|
||||
<!-- Check out the link below on how to setup and run tests -->
|
||||
<!-- https://github.com/yewstack/yew/blob/master/CONTRIBUTING.md#test -->
|
||||
<!-- If you're not sure how to test, let us know and we can provide guidance :) -->
|
||||
|
||||
<!-- Benchmark instructions -->
|
||||
<!-- 1. Fork and clone https://github.com/yewstack/js-framework-benchmark -->
|
||||
<!-- 2. Update `frameworks/yew/Cargo.toml` with your fork of Yew and the branch for this PR -->
|
||||
<!-- 3. Open a new PR with your `Cargo.toml` changes -->
|
||||
<!-- 4. Paste a link to the benchmark results: -->
|
||||
<!-- - [ ] I have opened a PR against https://github.com/yewstack/js-framework-benchmark -->
|
||||
<!-- If this is a bug fix, these tests will fail if the bug is present (to stop it from cropping up again) -->
|
||||
<!-- If this is a feature, my tests prove that the feature works -->
|
||||
|
||||
9
.github/workflows/pull-request.yml
vendored
9
.github/workflows/pull-request.yml
vendored
@ -160,15 +160,6 @@ jobs:
|
||||
restore-keys: |
|
||||
cargo-${{ runner.os }}-
|
||||
|
||||
# FIXME: Only needed because of <https://github.com/rustwasm/wasm-bindgen/issues/2261>
|
||||
- name: Install geckodriver
|
||||
run: |
|
||||
cd ~
|
||||
mkdir geckodriver
|
||||
curl --retry 5 -LO https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz
|
||||
tar -xzf geckodriver-*-linux64.tar.gz -C geckodriver
|
||||
echo "::add-path::$HOME/geckodriver"
|
||||
|
||||
- name: Run tests - yew
|
||||
env:
|
||||
HTTPBIN_URL: "http://localhost:8080"
|
||||
|
||||
110
CONTRIBUTING.md
110
CONTRIBUTING.md
@ -2,18 +2,26 @@
|
||||
|
||||
## Setting up your local development environment
|
||||
|
||||
### Add the wasm target
|
||||
### Add the WASM target
|
||||
|
||||
```bash
|
||||
rustup target add wasm32-unknown-unknown
|
||||
```
|
||||
|
||||
### Build
|
||||
### Install [cargo-make](https://github.com/sagiegurari/cargo-make)
|
||||
|
||||
```bash
|
||||
cargo build --target wasm32-unknown-unknown
|
||||
cargo install cargo-make
|
||||
```
|
||||
|
||||
You can use the following command to list all available tasks for Yew:
|
||||
|
||||
```bash
|
||||
cargo make --list-all-steps
|
||||
```
|
||||
|
||||
The most important tasks are outlined below.
|
||||
|
||||
#### stdweb
|
||||
|
||||
To run the examples in `./yew-stdweb`, you may wish to install [cargo-web](https://github.com/koute/cargo-web):
|
||||
@ -24,92 +32,64 @@ cargo install cargo-web
|
||||
|
||||
## Tests
|
||||
|
||||
Yew has unit tests which run via `cargo test`. However, a browser is required to run a large portion of the tests.
|
||||
This section will guide you through the process of running these tests locally.
|
||||
|
||||
### Integration Tests
|
||||
|
||||
First, install `wasm-pack`.
|
||||
[Instructions](https://rustwasm.github.io/wasm-pack/installer/)
|
||||
|
||||
`wasm-pack` automatically takes care of installing the correct `wasm-bindgen` version and downloading a WebDriver for the browser.
|
||||
|
||||
The following command is all you need to run the tests:
|
||||
To run all tests, use the following command:
|
||||
|
||||
```bash
|
||||
wasm-pack test --firefox --headless -- --features wasm_test
|
||||
cargo make tests
|
||||
```
|
||||
|
||||
You can replace `--firefox` with `--chrome` or `--safari` if you want to run the tests in a different browser. Currently, Yew's CI tests use Firefox.
|
||||
### Browser tests
|
||||
|
||||
Make sure to run the command in the directory of the crate you wish to test (e.g. `yew` or `yewtil`).
|
||||
If you run the command in the repository root you will get an error like this:
|
||||
`cargo make tests` will automatically download Geckodriver to a temporary location if it isn't in the PATH.
|
||||
|
||||
```bash
|
||||
Error: failed to parse manifest: yew/Cargo.toml
|
||||
Caused by: missing field `package`
|
||||
```
|
||||
### Fetch service tests
|
||||
|
||||
#### Manually installing a WebDriver
|
||||
The tests for the fetch service require a local [httpbin](https://httpbin.org/) server.
|
||||
If you have [Docker](https://www.docker.com/) installed,
|
||||
`cargo make tests` will automatically run httpbin in a container for you.
|
||||
|
||||
`wasm-pack` automatically downloads the selected WebDriver for you.
|
||||
If desired, you can download a WebDriver manually. For instructions, please consult the documentation of the WebDriver you wish to install.
|
||||
Alternatively, you can manually run an httpbin instance however you want and set the `HTTPBIN_URL` environment variable to the URL.
|
||||
|
||||
You might want to pass the argument `--mode no-install` to `wasm-pack` to make sure it doesn't try to install something.
|
||||
If the WebDriver binary is in the path, you can use the same command as above to run the tests.
|
||||
If not, you need to tell `wasm-pack test` where to find it using the `--geckodriver`, `--chromedriver`, or `--safaridriver` option.
|
||||
Run `wasm-pack test --help` to learn more.
|
||||
|
||||
#### Running all tests
|
||||
|
||||
You can use the `/ci/run_tests.sh` script to run all tests, which is the same script that is used by Yew's CI to run the whole test suite.
|
||||
The script currently always runs the tests in Firefox.
|
||||
|
||||
#### Fetch service tests
|
||||
|
||||
The following only applies to the `yew` (and `yew-stdweb`) crate.
|
||||
|
||||
The tests for the fetch service require a local httpbin server. We recommend running this with [Docker](https://www.docker.com/):
|
||||
|
||||
```bash
|
||||
docker run -p 8000:80 kennethreitz/httpbin
|
||||
```
|
||||
|
||||
Before running the tests, you need to set the `HTTPBIN_URL` environment variable to the URL of your httpbin instance.
|
||||
If you used the previous command to start the server the value should be "http://localhost:8000" (You mustn't add a trailing slash).
|
||||
|
||||
```shell
|
||||
# Unix-like
|
||||
export HTTPBIN_URL="http://localhost:8000"
|
||||
|
||||
# Windows
|
||||
set HTTPBIN_URL=http://localhost:8000
|
||||
```
|
||||
|
||||
You also need to activate the `httpbin_test` feature for the tests to run:
|
||||
|
||||
```bash
|
||||
wasm-pack test --firefox --headless -- --features wasm_test,httpbin_test
|
||||
```
|
||||
|
||||
If you're using the `/ci/run_tests.sh` script you only need to set the environment variable. The script will automatically add the feature.
|
||||
Please note that the public httpbin instance can't be used for these tests.
|
||||
|
||||
### Macro tests
|
||||
|
||||
When adding or updating tests, please make sure you have updated the appropriate `stderr` file, which you can find [here](https://github.com/yewstack/yew/tree/master/yew-macro/tests/macro) for the `html!` macro. These files ensure that macro compilation errors are correct and easy to understand.
|
||||
When adding or updating tests, please make sure to update the appropriate `stderr` file, which you can find [here](https://github.com/yewstack/yew/tree/master/yew-macro/tests/macro) for the `html!` macro.
|
||||
These files ensure that macro compilation errors are correct and easy to understand.
|
||||
These errors can change with each release of the compiler so they should be generated with the MSRV (currently 1.45).
|
||||
|
||||
To update or generate a new `stderr` file you can run `TRYBUILD=overwrite cargo test --test macro_test` or `TRYBUILD=overwrite cargo test --test derive_props_test` from the `yew-macro` directory.
|
||||
To update or generate a new `stderr` file you can run `TRYBUILD=overwrite cargo +1.45.2 test` in the `yew-macro` directory.
|
||||
|
||||
## Linting
|
||||
|
||||
The following command checks the code using Rustfmt and Clippy:
|
||||
|
||||
```bash
|
||||
cargo make lint
|
||||
```
|
||||
|
||||
To automatically fix formatting issues, run `cargo fmt` first.
|
||||
|
||||
## Benchmarks
|
||||
|
||||
If you wish to improve the performance of Yew, we ask you to prove the improvements of your changes through benchmarking.
|
||||
|
||||
Some components of Yew have dedicated benchmarks which can be run with the following command:
|
||||
|
||||
```bash
|
||||
cargo make benchmarks
|
||||
```
|
||||
|
||||
There's also a benchmark for the framework as a whole. Running it is a bit more involved:
|
||||
|
||||
1. Fork and clone [yewstack/js-framework-benchmark](https://github.com/yewstack/js-framework-benchmark)
|
||||
2. Update `frameworks/yew/Cargo.toml` with your fork of Yew and the branch for your changes
|
||||
3. Open a new PR with your `Cargo.toml` changes
|
||||
|
||||
Feel free to add new benchmark tests if the current benchmark coverage is insufficient!
|
||||
|
||||
> See #1453 for a discussion on how to make this easier.
|
||||
|
||||
## Writing APIs
|
||||
|
||||
When building new APIs, think about what it would be like to use them. Would this API cause confusing and hard to pin error mesages? Would this API integrate well with other APIs? Is it intuitive to use this API?
|
||||
|
||||
224
Makefile.toml
224
Makefile.toml
@ -1,12 +1,14 @@
|
||||
|
||||
######################
|
||||
#
|
||||
# public tasks:
|
||||
# * stable-checks
|
||||
# * run-tests
|
||||
# * pr-flow
|
||||
# * lint
|
||||
# * tests
|
||||
# * benchmarks
|
||||
#
|
||||
# Run `cargo make --list-all-steps` for more details.
|
||||
#
|
||||
######################
|
||||
|
||||
[config]
|
||||
min_version = "0.32.4"
|
||||
default_to_workspace = false
|
||||
@ -14,23 +16,44 @@ default_to_workspace = false
|
||||
[env]
|
||||
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
|
||||
CARGO_MAKE_CLIPPY_ARGS = "-- --deny=warnings"
|
||||
CARGO_MAKE_CARGO_BUILD_TEST_FLAGS = ""
|
||||
|
||||
[config.modify_core_tasks]
|
||||
private = true
|
||||
namespace = "core"
|
||||
|
||||
[tasks.stable-checks]
|
||||
description = "Runs all validations for both workspaces on rust stable only."
|
||||
condition = { channels = [ "stable" ] }
|
||||
run_task = { name = [ "stable-checks-flow", "stable-checks-stdweb" ], fork = true }
|
||||
[tasks.pr-flow]
|
||||
category = "Checks"
|
||||
description = "Lint and test"
|
||||
run_task = { name = ["lint", "tests"], fork = true }
|
||||
|
||||
[tasks.run-tests]
|
||||
[tasks.lint]
|
||||
category = "Checks"
|
||||
description = "Check formatting and run Clippy"
|
||||
run_task = { name = ["lint-flow", "lint-stdweb"], fork = true }
|
||||
|
||||
[tasks.tests]
|
||||
category = "Testing"
|
||||
description = "Run all tests"
|
||||
dependencies = ["tests-setup"]
|
||||
env = { CARGO_MAKE_WORKSPACE_SKIP_MEMBERS = ["examples/*", "yewtil/examples/*"] }
|
||||
run_task = { name = [ "run-tests-flow", "run-tests-stdweb" ], fork = true, cleanup_task = "tests-cleanup" }
|
||||
env = { CARGO_MAKE_WORKSPACE_SKIP_MEMBERS = ["**/examples/*"] }
|
||||
run_task = { name = [
|
||||
"test-flow",
|
||||
"tests-stdweb",
|
||||
"doc-test-flow",
|
||||
], fork = true, cleanup_task = "tests-cleanup" }
|
||||
|
||||
[tasks.stable-checks-stdweb]
|
||||
[tasks.benchmarks]
|
||||
category = "Testing"
|
||||
description = "Run benchmarks"
|
||||
env = { CARGO_MAKE_WORKSPACE_SKIP_MEMBERS = ["**/examples/*"] }
|
||||
run_task = { name = "bench-flow", fork = true }
|
||||
|
||||
[tasks.lint-flow]
|
||||
private = true
|
||||
workspace = true
|
||||
dependencies = ["core::check-format-flow", "core::clippy-flow"]
|
||||
|
||||
[tasks.lint-stdweb]
|
||||
private = true
|
||||
cwd = "yew-stdweb"
|
||||
command = "cargo"
|
||||
@ -40,115 +63,96 @@ args = [
|
||||
"${CARGO_MAKE_LOG_LEVEL}",
|
||||
"--profile",
|
||||
"${CARGO_MAKE_PROFILE}",
|
||||
"stable-checks-flow"
|
||||
"lint-flow",
|
||||
]
|
||||
|
||||
[tasks.stable-checks-flow]
|
||||
private = true
|
||||
workspace = true
|
||||
dependencies = [
|
||||
"core::check-format-flow",
|
||||
"core::check-flow",
|
||||
"core::clippy-flow",
|
||||
"post-stable-checks"
|
||||
]
|
||||
|
||||
[tasks.post-stable-checks]
|
||||
|
||||
[tasks.web-check]
|
||||
command = "cargo"
|
||||
args = ["web", "check", "--target", "wasm32-unknown-unknown"]
|
||||
|
||||
[tasks.tests-setup]
|
||||
private = true
|
||||
script_runner = "@duckscript"
|
||||
script = [
|
||||
'''
|
||||
#!@duckscript
|
||||
test_flags= array --headless --firefox
|
||||
yew_test_features= set wasm_test
|
||||
"""
|
||||
test_flags = array --headless --firefox
|
||||
yew_test_features = set wasm_test
|
||||
|
||||
fn set_httpbin_test_features
|
||||
HTTPBIN_URL = get_env HTTPBIN_URL
|
||||
echo INFO: using ${HTTPBIN_URL} for fetch service tests
|
||||
yew_test_features = set "${yew_test_features},httpbin_test"
|
||||
end
|
||||
fn set_httpbin_test_features
|
||||
HTTPBIN_URL = get_env HTTPBIN_URL
|
||||
echo INFO: using ${HTTPBIN_URL} for fetch service tests
|
||||
yew_test_features = set "${yew_test_features},httpbin_test"
|
||||
end
|
||||
|
||||
if is_defined HTTPBIN_URL
|
||||
set_httpbin_test_features
|
||||
else
|
||||
# only enable docker if docker executable is available
|
||||
# and --skip-httpbin cli argument not provided to cargo make
|
||||
docker_path = which docker
|
||||
start_docker = is_defined docker_path
|
||||
args_provided = not is_empty ${CARGO_MAKE_TASK_ARGS}
|
||||
if ${args_provided}
|
||||
args = split ${CARGO_MAKE_TASK_ARGS} ;
|
||||
for arg in ${args}
|
||||
if eq ${arg} --skip-httpbin
|
||||
start_docker = set false
|
||||
release ${args}
|
||||
if is_defined HTTPBIN_URL
|
||||
set_httpbin_test_features
|
||||
else
|
||||
# only enable docker if docker executable is available
|
||||
# and --skip-httpbin cli argument not provided to cargo make
|
||||
docker_path = which docker
|
||||
start_docker = is_defined docker_path
|
||||
args_provided = not is_empty ${CARGO_MAKE_TASK_ARGS}
|
||||
if ${args_provided}
|
||||
args = split ${CARGO_MAKE_TASK_ARGS} ;
|
||||
for arg in ${args}
|
||||
if eq ${arg} --skip-httpbin
|
||||
start_docker = set false
|
||||
release ${args}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if ${start_docker}
|
||||
echo Starting httpbin docker image...
|
||||
mkdir ./target
|
||||
cidfile = set ./target/httpbin_container.cid
|
||||
if ${start_docker}
|
||||
echo Starting httpbin docker image...
|
||||
mkdir ./target
|
||||
cidfile = set ./target/httpbin_container.cid
|
||||
|
||||
# if container already running, stop it
|
||||
if is_file ${cidfile}
|
||||
# if container already running, stop it
|
||||
if is_file ${cidfile}
|
||||
container_id = readfile ${cidfile}
|
||||
rm ${cidfile}
|
||||
set_env HTTPBIN_CONTAINER_ID ${container_id}
|
||||
cm_run_task tests-cleanup
|
||||
end
|
||||
|
||||
# get local port
|
||||
docker_port = get_env YEW_HTTPBIN_PORT
|
||||
if not is_defined docker_port
|
||||
docker_port = set 7117
|
||||
end
|
||||
|
||||
exec --fail-on-error docker run -d --cidfile ${cidfile} -p "${docker_port}:80" kennethreitz/httpbin
|
||||
container_id = readfile ${cidfile}
|
||||
rm ${cidfile}
|
||||
container_id = trim ${container_id}
|
||||
set_env HTTPBIN_CONTAINER_ID ${container_id}
|
||||
cm_run_task tests-cleanup
|
||||
end
|
||||
|
||||
# get local port
|
||||
docker_port = get_env YEW_HTTPBIN_PORT
|
||||
if not is_defined docker_port
|
||||
docker_port = set 7117
|
||||
end
|
||||
set_env HTTPBIN_URL http://localhost:${docker_port}
|
||||
set_httpbin_test_features
|
||||
|
||||
# bind to a random free port
|
||||
exec docker run -d --cidfile ${cidfile} -p "${docker_port}:80" kennethreitz/httpbin
|
||||
container_id = readfile ${cidfile}
|
||||
container_id = trim ${container_id}
|
||||
set_env HTTPBIN_CONTAINER_ID ${container_id}
|
||||
|
||||
set_env HTTPBIN_URL http://localhost:${docker_port}
|
||||
set_httpbin_test_features
|
||||
|
||||
# wait for docker container to boot before running tests
|
||||
if is_defined HTTPBIN_WAIT
|
||||
sleep ${HTTPBIN_WAIT}
|
||||
# wait for docker container to boot before running tests
|
||||
if is_defined HTTPBIN_WAIT
|
||||
sleep ${HTTPBIN_WAIT}
|
||||
else
|
||||
sleep 500
|
||||
end
|
||||
else
|
||||
sleep 500
|
||||
echo "INFO: HTTPBIN_URL isn't set, won't run fetch service tests"
|
||||
echo " please see the CONTRIBUTING.md file for instructions"
|
||||
end
|
||||
else
|
||||
echo INFO: HTTPBIN_URL isn't set, won't run fetch service tests
|
||||
echo " please see the CONTRIBUTING.md file for instructions"
|
||||
end
|
||||
end
|
||||
|
||||
yew_test_flags = array_join ${test_flags} " "
|
||||
echo "running tests with flags: ${yew_test_flags} and features: ${yew_test_features}"
|
||||
yew_test_flags = array_join ${test_flags} " "
|
||||
echo "running tests with flags: ${yew_test_flags} and features: ${yew_test_features}"
|
||||
|
||||
set_env YEW_TEST_FLAGS ${yew_test_flags}
|
||||
set_env YEW_TEST_FEATURES ${yew_test_features}
|
||||
'''
|
||||
set_env YEW_TEST_FLAGS ${yew_test_flags}
|
||||
set_env YEW_TEST_FEATURES ${yew_test_features}
|
||||
""",
|
||||
]
|
||||
|
||||
[tasks.tests-cleanup]
|
||||
private = true
|
||||
condition = { env_set = ["HTTPBIN_CONTAINER_ID"] }
|
||||
ignore_errors = true
|
||||
command = "docker"
|
||||
args = ["rm", "--force", "${HTTPBIN_CONTAINER_ID}"]
|
||||
|
||||
[tasks.run-tests-flow]
|
||||
workspace = true
|
||||
dependencies = [ "test" ]
|
||||
|
||||
[tasks.run-tests-stdweb]
|
||||
[tasks.tests-stdweb]
|
||||
private = true
|
||||
extend = "core::wasm-pack-base"
|
||||
cwd = "yew-stdweb"
|
||||
@ -157,9 +161,35 @@ args = [
|
||||
"@@split(YEW_TEST_FLAGS, )",
|
||||
"--",
|
||||
"--features",
|
||||
"${YEW_TEST_FEATURES}"
|
||||
"${YEW_TEST_FEATURES}",
|
||||
]
|
||||
|
||||
[tasks.test-flow]
|
||||
private = true
|
||||
workspace = true
|
||||
dependencies = ["test"]
|
||||
|
||||
[tasks.test]
|
||||
private = true
|
||||
command = "cargo"
|
||||
args = ["test"]
|
||||
args = ["test", "--all-targets"]
|
||||
|
||||
[tasks.doc-test-flow]
|
||||
private = true
|
||||
workspace = true
|
||||
dependencies = ["doc-test"]
|
||||
|
||||
[tasks.doc-test]
|
||||
private = true
|
||||
command = "cargo"
|
||||
args = ["test", "--doc"]
|
||||
|
||||
[tasks.bench-flow]
|
||||
private = true
|
||||
workspace = true
|
||||
dependencies = ["bench"]
|
||||
|
||||
[tasks.bench]
|
||||
private = true
|
||||
command = "cargo"
|
||||
args = ["bench"]
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
|
||||
|
||||
# SETUP
|
||||
|
||||
test_flags=("--headless" "--firefox")
|
||||
test_features="wasm_bench"
|
||||
|
||||
echo "running benchmarks with flags: ${test_flags[*]} and features: ${test_features}"
|
||||
|
||||
# TESTS
|
||||
|
||||
set -x
|
||||
|
||||
(cd yew &&
|
||||
wasm-pack test "${test_flags[@]}" --release \
|
||||
-- --features "${test_features}" bench
|
||||
)
|
||||
@ -1,28 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo "$(rustup default)" | grep -q "stable"
|
||||
if [ "$?" != "0" ]; then
|
||||
# only run checks on stable
|
||||
exit 0
|
||||
fi
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
cargo fmt --all -- --check
|
||||
cargo clippy --all -- --deny=warnings
|
||||
cargo check --all
|
||||
|
||||
# Enable all optional features
|
||||
(cd yew \
|
||||
&& cargo check --features cbor,msgpack,toml,yaml \
|
||||
&& cargo clippy --features cbor,msgpack,toml,yaml -- --deny=warnings)
|
||||
|
||||
# Check stdweb
|
||||
pushd yew-stdweb
|
||||
cargo fmt --all -- --check
|
||||
cargo clippy --all -- --deny=warnings
|
||||
cargo check --all --target wasm32-unknown-unknown
|
||||
|
||||
# webgl_stdweb doesn't play nice with wasm-bindgen
|
||||
(cd examples/webgl && cargo web check --target wasm32-unknown-unknown)
|
||||
popd
|
||||
@ -1,46 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
|
||||
|
||||
# SETUP
|
||||
|
||||
test_flags=("--headless" "--firefox")
|
||||
test_features="wasm_test"
|
||||
|
||||
if [[ -z "${HTTPBIN_URL-}" ]]; then
|
||||
echo "INFO: HTTPBIN_URL isn't set, won't run fetch service tests"
|
||||
echo " please see the CONTRIBUTING.md file for instructions"
|
||||
else
|
||||
echo "INFO: using '$HTTPBIN_URL' for fetch service tests"
|
||||
test_features+=",httpbin_test"
|
||||
fi
|
||||
|
||||
echo "running tests with flags: ${test_flags[*]} and features: ${test_features}"
|
||||
|
||||
# TESTS
|
||||
|
||||
set -x
|
||||
|
||||
(cd yew &&
|
||||
wasm-pack test "${test_flags[@]}" -- --features "${test_features}" &&
|
||||
cargo test --doc --features doc_test,wasm_test,yaml,msgpack,cbor,toml &&
|
||||
cargo test --doc --features doc_test,wasm_test,yaml,msgpack,cbor,toml \
|
||||
--features std_web,agent,services --no-default-features)
|
||||
|
||||
(cd yew-functional && wasm-pack test "${test_flags[@]}")
|
||||
|
||||
(cd yew-macro &&
|
||||
cargo test --test macro_test &&
|
||||
cargo test --test derive_props_test &&
|
||||
cargo test --doc)
|
||||
|
||||
(cd yew-router && cargo test)
|
||||
(cd yew-router-macro && cargo test)
|
||||
(cd yew-router-route-parser && cargo test)
|
||||
|
||||
(cd yew-stdweb && wasm-pack test "${test_flags[@]}" -- --features "${test_features}")
|
||||
|
||||
(cd yewtil && cargo test)
|
||||
|
||||
(cd yew-components && cargo test)
|
||||
|
||||
(cd yew-validation && cargo test)
|
||||
@ -1,8 +1,4 @@
|
||||
|
||||
[tasks.test]
|
||||
clear = true
|
||||
extend = "core::wasm-pack-base"
|
||||
args = [
|
||||
"test",
|
||||
"@@split(YEW_TEST_FLAGS, )"
|
||||
]
|
||||
command = "wasm-pack"
|
||||
args = ["test", "@@split(YEW_TEST_FLAGS, )"]
|
||||
|
||||
@ -1,16 +1,25 @@
|
||||
[env]
|
||||
MSRV = "1.45.2"
|
||||
|
||||
[tasks.install-msrv-toolchain]
|
||||
script_runner = "@duckscript"
|
||||
script = [
|
||||
"""
|
||||
output = exec --fail-on-error rustup toolchain list
|
||||
stdout = set ${output.stdout}
|
||||
already_installed = contains ${stdout} ${MSRV}
|
||||
if not ${already_installed}
|
||||
echo "Installing toolchain for ${MSRV} (Yew MSRV) to run macro compilation tests"
|
||||
exec --fail-on-error rustup toolchain install --profile minimal ${MSRV}
|
||||
end
|
||||
"""
|
||||
]
|
||||
|
||||
[tasks.test]
|
||||
clear = true
|
||||
dependencies = ["test-macro", "test-derive-props", "test-doc"]
|
||||
|
||||
[tasks.test-macro]
|
||||
command = "cargo"
|
||||
args = ["test", "--test", "macro_test"]
|
||||
|
||||
[tasks.test-derive-props]
|
||||
command = "cargo"
|
||||
args = ["test", "--test", "derive_props_test"]
|
||||
|
||||
[tasks.test-doc]
|
||||
command = "cargo"
|
||||
args = ["test", "--doc"]
|
||||
dependencies = ["install-msrv-toolchain"]
|
||||
script = [
|
||||
"""
|
||||
cargo +${MSRV} test
|
||||
"""
|
||||
]
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
|
||||
[tasks.post-stable-checks]
|
||||
alias = "web-check"
|
||||
@ -1,29 +1,50 @@
|
||||
|
||||
[env]
|
||||
CARGO_MAKE_CLIPPY_ARGS = "--features cbor,msgpack,toml,yaml -- --deny=warnings"
|
||||
|
||||
[tasks."core::check"]
|
||||
args = ["check", "--features", "cbor,msgpack,toml,yaml"]
|
||||
|
||||
[tasks.test]
|
||||
clear = true
|
||||
dependencies = ["test-wasm", "test-doc-partial-features", "test-doc-all-features"]
|
||||
|
||||
[tasks.test-wasm]
|
||||
private = true
|
||||
extend = "core::wasm-pack-base"
|
||||
command = "wasm-pack"
|
||||
args = [
|
||||
"test",
|
||||
"@@split(YEW_TEST_FLAGS, )",
|
||||
"--",
|
||||
"--features",
|
||||
"${YEW_TEST_FEATURES}"
|
||||
"${YEW_TEST_FEATURES}",
|
||||
]
|
||||
|
||||
[tasks.test-doc-partial-features]
|
||||
command = "cargo"
|
||||
args = ["test", "--doc", "--features", "doc_test,wasm_test,yaml,msgpack,cbor,toml"]
|
||||
[tasks.doc-test]
|
||||
clear = true
|
||||
run_task = { name = ["doc-test-normal", "doc-test-stdweb"], fork = true }
|
||||
|
||||
[tasks.test-doc-all-features]
|
||||
[tasks.doc-test-normal]
|
||||
command = "cargo"
|
||||
args = ["test", "--doc", "--features", "doc_test,wasm_test,yaml,msgpack,cbor,toml,std_web,agent,services", "--no-default-features"]
|
||||
args = [
|
||||
"test",
|
||||
"--doc",
|
||||
"--features",
|
||||
"doc_test,wasm_test,yaml,msgpack,cbor,toml",
|
||||
]
|
||||
|
||||
[tasks.doc-test-stdweb]
|
||||
command = "cargo"
|
||||
args = [
|
||||
"test",
|
||||
"--doc",
|
||||
"--features",
|
||||
"doc_test,wasm_test,yaml,msgpack,cbor,toml,std_web,agent,services",
|
||||
"--no-default-features",
|
||||
]
|
||||
|
||||
[tasks.bench]
|
||||
extend = "core::wasm-pack-base"
|
||||
command = "wasm-pack"
|
||||
args = [
|
||||
"test",
|
||||
"--release",
|
||||
"--firefox",
|
||||
"--headless",
|
||||
"--",
|
||||
"--features",
|
||||
"wasm_bench",
|
||||
"bench",
|
||||
]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user