Move examples to their own workspace.

This allows us to test all of the "core" crates (and the guide) by
testing the root workspace, and all of the examples by testing in the
examples workspace.
This commit is contained in:
Sergio Benitez 2021-03-09 15:32:04 -08:00
parent 4e06ee64aa
commit 17dd8dafd0
36 changed files with 84 additions and 104 deletions

View File

@ -19,6 +19,7 @@ jobs:
test:
- { name: Debug, flag: }
- { name: Contrib, flag: "--contrib" }
- { name: Examples, flag: "--examples" }
toolchain: [stable]
allow-failures: [false]
include:
@ -32,11 +33,7 @@ jobs:
allow-failures: false
- toolchain: nightly
os: { name: Linux, distro: ubuntu-latest }
test: { name: Debug, flag: }
allow-failures: true
- toolchain: nightly
os: { name: Linux, distro: ubuntu-latest }
test: { name: Contrib, flag: "--contrib" }
test: { name: Debug, flag: "--all" }
allow-failures: true
continue-on-error: ${{ matrix.allow-failures }}

View File

@ -6,36 +6,4 @@ members = [
"contrib/lib",
"contrib/codegen",
"site/tests",
"examples/cookies",
"examples/errors",
"examples/forms",
"examples/hello_person",
"examples/query_params",
"examples/hello_world",
"examples/manual_routes",
"examples/optional_redirect",
"examples/redirect",
"examples/static_files",
"examples/todo",
"examples/content_types",
"examples/ranking",
"examples/testing",
"examples/request_local_state",
"examples/request_guard",
"examples/stream",
"examples/json",
"examples/msgpack",
"examples/handlebars_templates",
"examples/tera_templates",
"examples/config",
"examples/raw_upload",
"examples/pastebin",
"examples/state",
"examples/managed_queue",
"examples/uuid",
"examples/session",
"examples/raw_sqlite",
"examples/tls",
"examples/fairings",
"examples/hello_2018",
]

35
examples/Cargo.toml Normal file
View File

@ -0,0 +1,35 @@
[workspace]
members = [
"cookies",
"errors",
"forms",
"hello_person",
"query_params",
"hello_world",
"manual_routes",
"optional_redirect",
"redirect",
"static_files",
"todo",
"content_types",
"ranking",
"testing",
"request_local_state",
"request_guard",
"stream",
"json",
"msgpack",
"handlebars_templates",
"tera_templates",
"config",
"raw_upload",
"pastebin",
"state",
"managed_queue",
"uuid",
"session",
"raw_sqlite",
"tls",
"fairings",
"hello_2018",
]

View File

@ -1,7 +1,7 @@
[package]
name = "config"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "content_types"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "cookies"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "errors"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "fairings"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "forms"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "handlebars_templates"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "hello_2018"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "hello_person"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "hello_world"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "json"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "managed_queue"
version = "0.0.0"
workspace = "../.."
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "manual_routes"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "msgpack"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "optional_redirect"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "pastebin"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "query_params"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "ranking"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "raw_sqlite"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "raw_upload"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "redirect"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "request_guard"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "request_local_state"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "session"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "state"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "static_files"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "stream"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "tera_templates"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "testing"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "tls"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "todo"
version = "0.0.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -1,7 +1,7 @@
[package]
name = "uuid"
version = "0.1.0"
workspace = "../../"
workspace = "../"
edition = "2018"
publish = false

View File

@ -73,14 +73,12 @@ function test_contrib() {
echo ":: Building and testing contrib [default]..."
pushd "${CONTRIB_LIB_ROOT}" > /dev/null 2>&1
$CARGO test $@
for feature in "${FEATURES[@]}"; do
echo ":: Building and testing contrib [${feature}]..."
$CARGO test --no-default-features --features "${feature}" $@
done
popd > /dev/null 2>&1
}
@ -91,7 +89,6 @@ function test_core() {
)
pushd "${CORE_LIB_ROOT}" > /dev/null 2>&1
echo ":: Building and testing core [no features]..."
$CARGO test --no-default-features $@
@ -99,36 +96,27 @@ function test_core() {
echo ":: Building and testing core [${feature}]..."
$CARGO test --no-default-features --features "${feature}" $@
done
popd > /dev/null 2>&1
}
function test_examples() {
for dir in $(find "${EXAMPLES_DIR}" -maxdepth 1 -mindepth 1 -type d); do
echo ":: Building and testing example [${dir#"${EXAMPLES_DIR}/"}]..."
echo ":: Building and testing examples..."
pushd "${dir}" > /dev/null 2>&1
$CARGO test $@
popd > /dev/null 2>&1
done
}
function test_guide() {
echo ":: Building and testing guide..."
pushd "${GUIDE_TESTS_ROOT}" > /dev/null 2>&1
$CARGO test $@
pushd "${EXAMPLES_DIR}" > /dev/null 2>&1
# Rust compiles Rocket once with the `secrets` feature enabled, so when run
# in production, we need a secret key or tests will fail needlessly. We
# ensure in core that secret key failing/not failing works as expected.
ROCKET_SECRET_KEY="itlYmFR2vYKrOmFhupMIn/hyB6lYCCTXz4yaQX89XVg=" \
$CARGO test --all $@
popd > /dev/null 2>&1
}
function test_default() {
for project in "${ALL_PROJECT_DIRS[@]}"; do
echo ":: Building and testing ${project#"${PROJECT_ROOT}/"}..."
echo ":: Building and testing core libraries..."
pushd "${project}" > /dev/null 2>&1
$CARGO test --all-features $@
popd > /dev/null 2>&1
done
pushd "${PROJET_ROOT}" > /dev/null 2>&1
$CARGO test --all --all-features $@
popd > /dev/null 2>&1
}
if [[ $1 == +* ]]; then
@ -138,7 +126,7 @@ fi
# The kind of test we'll be running.
TEST_KIND="default"
KINDS=("contrib" "core" "examples" "guide" "all")
KINDS=("contrib" "core" "examples" "default" "all")
if [[ " ${KINDS[@]} " =~ " ${1#"--"} " ]]; then
TEST_KIND=${1#"--"}
@ -165,24 +153,16 @@ if ! $CARGO update ; then
fi
case $TEST_KIND in
contrib) test_contrib $@ ;;
core) test_core $@ ;;
contrib) test_contrib $@ ;;
examples) test_examples $@ ;;
guide) test_guide $@ ;;
default)
test_examples $@ & examples=$!
test_default $@ & default=$!
test_guide $@ & guide=$!
wait $examples && wait $default && wait $guide
;;
default) test_default $@ ;;
all)
test_core $@ & core=$!
test_contrib $@ & contrib=$!
test_examples $@ & examples=$!
test_default $@ & default=$!
test_guide $@ & guide=$!
wait $core && wait $contrib && wait $examples && wait $default && wait $guide
wait $core && wait $contrib && wait $examples && wait $default
;;
esac