diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e50eab57..689254ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }} diff --git a/Cargo.toml b/Cargo.toml index 25cf1274..54775e12 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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", ] diff --git a/examples/Cargo.toml b/examples/Cargo.toml new file mode 100644 index 00000000..4802a251 --- /dev/null +++ b/examples/Cargo.toml @@ -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", +] diff --git a/examples/config/Cargo.toml b/examples/config/Cargo.toml index 6489adda..20e6ad1b 100644 --- a/examples/config/Cargo.toml +++ b/examples/config/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "config" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/content_types/Cargo.toml b/examples/content_types/Cargo.toml index 7eb54855..cc63dc2c 100644 --- a/examples/content_types/Cargo.toml +++ b/examples/content_types/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "content_types" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/cookies/Cargo.toml b/examples/cookies/Cargo.toml index bcf93e33..664ae6b4 100644 --- a/examples/cookies/Cargo.toml +++ b/examples/cookies/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "cookies" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/errors/Cargo.toml b/examples/errors/Cargo.toml index 5e6bd16b..dde9a009 100644 --- a/examples/errors/Cargo.toml +++ b/examples/errors/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "errors" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/fairings/Cargo.toml b/examples/fairings/Cargo.toml index ae927777..93e939a7 100644 --- a/examples/fairings/Cargo.toml +++ b/examples/fairings/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "fairings" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/forms/Cargo.toml b/examples/forms/Cargo.toml index 2c9ebe04..67db237a 100644 --- a/examples/forms/Cargo.toml +++ b/examples/forms/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "forms" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/handlebars_templates/Cargo.toml b/examples/handlebars_templates/Cargo.toml index 2620f294..ab3ee8cb 100644 --- a/examples/handlebars_templates/Cargo.toml +++ b/examples/handlebars_templates/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "handlebars_templates" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/hello_2018/Cargo.toml b/examples/hello_2018/Cargo.toml index 23dee942..7c09ed32 100644 --- a/examples/hello_2018/Cargo.toml +++ b/examples/hello_2018/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "hello_2018" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/hello_person/Cargo.toml b/examples/hello_person/Cargo.toml index 99be046f..66d9f256 100644 --- a/examples/hello_person/Cargo.toml +++ b/examples/hello_person/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "hello_person" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/hello_world/Cargo.toml b/examples/hello_world/Cargo.toml index 2c03cf22..ead674ed 100644 --- a/examples/hello_world/Cargo.toml +++ b/examples/hello_world/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "hello_world" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/json/Cargo.toml b/examples/json/Cargo.toml index 183b0d00..a6047eca 100644 --- a/examples/json/Cargo.toml +++ b/examples/json/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "json" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/managed_queue/Cargo.toml b/examples/managed_queue/Cargo.toml index ba8330e9..42d97d19 100644 --- a/examples/managed_queue/Cargo.toml +++ b/examples/managed_queue/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "managed_queue" version = "0.0.0" -workspace = "../.." +workspace = "../" edition = "2018" publish = false diff --git a/examples/manual_routes/Cargo.toml b/examples/manual_routes/Cargo.toml index 8519ae94..fef9e587 100644 --- a/examples/manual_routes/Cargo.toml +++ b/examples/manual_routes/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "manual_routes" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/msgpack/Cargo.toml b/examples/msgpack/Cargo.toml index 5d9e2dc9..91d689bc 100644 --- a/examples/msgpack/Cargo.toml +++ b/examples/msgpack/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "msgpack" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/optional_redirect/Cargo.toml b/examples/optional_redirect/Cargo.toml index f802bd7e..737591e4 100644 --- a/examples/optional_redirect/Cargo.toml +++ b/examples/optional_redirect/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "optional_redirect" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/pastebin/Cargo.toml b/examples/pastebin/Cargo.toml index 7b62d5a5..b567b25e 100644 --- a/examples/pastebin/Cargo.toml +++ b/examples/pastebin/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "pastebin" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/query_params/Cargo.toml b/examples/query_params/Cargo.toml index 66795f79..41c99351 100644 --- a/examples/query_params/Cargo.toml +++ b/examples/query_params/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "query_params" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/ranking/Cargo.toml b/examples/ranking/Cargo.toml index f033e523..286a1edc 100644 --- a/examples/ranking/Cargo.toml +++ b/examples/ranking/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "ranking" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/raw_sqlite/Cargo.toml b/examples/raw_sqlite/Cargo.toml index 67977941..b10c9e26 100644 --- a/examples/raw_sqlite/Cargo.toml +++ b/examples/raw_sqlite/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "raw_sqlite" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/raw_upload/Cargo.toml b/examples/raw_upload/Cargo.toml index 3b3d04d2..17bd5bba 100644 --- a/examples/raw_upload/Cargo.toml +++ b/examples/raw_upload/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "raw_upload" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/redirect/Cargo.toml b/examples/redirect/Cargo.toml index c7a75678..5cd3f4eb 100644 --- a/examples/redirect/Cargo.toml +++ b/examples/redirect/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "redirect" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/request_guard/Cargo.toml b/examples/request_guard/Cargo.toml index ebeeada7..6f7d2eee 100644 --- a/examples/request_guard/Cargo.toml +++ b/examples/request_guard/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "request_guard" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/request_local_state/Cargo.toml b/examples/request_local_state/Cargo.toml index 8322df23..b466ee01 100644 --- a/examples/request_local_state/Cargo.toml +++ b/examples/request_local_state/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "request_local_state" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/session/Cargo.toml b/examples/session/Cargo.toml index 5093ce36..cb00be11 100644 --- a/examples/session/Cargo.toml +++ b/examples/session/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "session" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/state/Cargo.toml b/examples/state/Cargo.toml index b102d637..e2d6d515 100644 --- a/examples/state/Cargo.toml +++ b/examples/state/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "state" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/static_files/Cargo.toml b/examples/static_files/Cargo.toml index a4652463..d104792f 100644 --- a/examples/static_files/Cargo.toml +++ b/examples/static_files/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "static_files" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/stream/Cargo.toml b/examples/stream/Cargo.toml index 96792d90..88d96f05 100644 --- a/examples/stream/Cargo.toml +++ b/examples/stream/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "stream" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/tera_templates/Cargo.toml b/examples/tera_templates/Cargo.toml index 815a3d0c..3126422f 100644 --- a/examples/tera_templates/Cargo.toml +++ b/examples/tera_templates/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tera_templates" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/testing/Cargo.toml b/examples/testing/Cargo.toml index 6ed69497..79d053f1 100644 --- a/examples/testing/Cargo.toml +++ b/examples/testing/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "testing" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/tls/Cargo.toml b/examples/tls/Cargo.toml index 7f9ff337..bb9cb820 100644 --- a/examples/tls/Cargo.toml +++ b/examples/tls/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tls" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/todo/Cargo.toml b/examples/todo/Cargo.toml index 4f9975fc..3fa189ca 100644 --- a/examples/todo/Cargo.toml +++ b/examples/todo/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "todo" version = "0.0.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/examples/uuid/Cargo.toml b/examples/uuid/Cargo.toml index 59fbdf09..1415e6f3 100644 --- a/examples/uuid/Cargo.toml +++ b/examples/uuid/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "uuid" version = "0.1.0" -workspace = "../../" +workspace = "../" edition = "2018" publish = false diff --git a/scripts/test.sh b/scripts/test.sh index 6f99be28..efc52d35 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -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