Skip to content

Quality of life on stable channel #1084

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
- release-check
- rustfmt
- test
- test-book
- wasm
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -60,7 +61,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: stable
components: rustfmt

- run: make cargo.fmt check=yes
Expand Down Expand Up @@ -171,7 +172,6 @@ jobs:
- juniper_graphql_ws
- juniper_integration_tests
- juniper_codegen_tests
- juniper_book_tests
- juniper_actix
- juniper_hyper
- juniper_iron
Expand All @@ -194,13 +194,6 @@ jobs:
os: macOS
- crate: juniper_codegen_tests
os: windows
- crate: juniper_book_tests
toolchain: beta
- crate: juniper_book_tests
toolchain: nightly
# TODO: LLVM ERROR: out of memory
- crate: juniper_integration_tests
os: windows

runs-on: ${{ matrix.os }}-latest
steps:
Expand All @@ -213,6 +206,29 @@ jobs:

- run: make test.cargo crate=${{ matrix.crate }}

test-book:
strategy:
fail-fast: false
matrix:
os:
- ubuntu
- macOS
- windows
toolchain:
- stable
- beta
- nightly

runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
override: true
- run: cargo install mdbook
- run: make test.book

wasm:
strategy:
fail-fast: false
Expand Down Expand Up @@ -281,6 +297,7 @@ jobs:
- package
- rustfmt
- test
- test-book
- wasm
if: ${{ startsWith(github.ref, 'refs/tags/juniper') }}
runs-on: ubuntu-latest
Expand Down
1 change: 0 additions & 1 deletion .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
imports_granularity = "Crate"
use_field_init_shorthand = true
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[workspace]
members = [
"benches",
"book/tests",
"examples/basic_subscriptions",
"examples/warp_async",
"examples/warp_subscriptions",
Expand All @@ -16,5 +15,5 @@ members = [
"juniper_warp",
"juniper_actix",
"tests/codegen",
"tests/integration",
"tests/integration"
]
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ release: cargo.release
# make cargo.fmt [check=(no|yes)]

cargo.fmt:
cargo +nightly fmt --all $(if $(call eq,$(check),yes),-- --check,)
cargo fmt --all $(if $(call eq,$(check),yes),-- --check,)


# Lint Rust sources with Clippy.
Expand Down Expand Up @@ -90,7 +90,7 @@ cargo.test: test.cargo
# make test.book

test.book:
@make test.cargo crate=juniper_book_tests
cargo clean; cargo build; mdbook test book -L target/debug/deps


# Run Rust tests of project crates.
Expand Down
18 changes: 1 addition & 17 deletions book/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,5 @@ The output will be in the `_rendered/` directory.

To run the tests validating all code examples in the book, run:
```bash
cd tests/
cargo test

# or from project root dir:
cargo test -p juniper_book_tests

# or via shortcut from project root dir:
make test.book
mdbook test -L ../target/debug/deps
```




## Test setup

All Rust code examples in the book are compiled on the CI.

This is done using the [skeptic](https://github.com/budziq/rust-skeptic) crate.
2 changes: 2 additions & 0 deletions book/src/advanced/subscriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ This example shows a subscription operation that returns two events, the strings
sequentially:

```rust
# extern crate juniper;
# extern crate futures;
# use juniper::{graphql_object, graphql_subscription, FieldError};
# use futures::Stream;
# use std::pin::Pin;
Expand Down
1 change: 1 addition & 0 deletions book/src/types/objects/using_contexts.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Context cannot be specified by a mutable reference, because concurrent fields re
For example, when using async runtime with [work stealing][2] (like `tokio`), which obviously requires thread safety in addition, you will need to use a corresponding async version of `RwLock`:
```rust
# extern crate juniper;
# extern crate tokio;
# use std::collections::HashMap;
# use juniper::graphql_object;
use tokio::sync::RwLock;
Expand Down
6 changes: 6 additions & 0 deletions book/src/types/scalars.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ All the methods used from newtype's field can be replaced with attributes:
### `#[graphql(to_output_with = <fn>)]` attribute

```rust
# extern crate juniper;
# use juniper::{GraphQLScalar, ScalarValue, Value};
#
#[derive(GraphQLScalar)]
Expand All @@ -131,6 +132,7 @@ fn to_output<S: ScalarValue>(v: &Incremented) -> Value<S> {
### `#[graphql(from_input_with = <fn>)]` attribute

```rust
# extern crate juniper;
# use juniper::{GraphQLScalar, InputValue, ScalarValue};
#
#[derive(GraphQLScalar)]
Expand Down Expand Up @@ -165,6 +167,7 @@ impl UserId {
### `#[graphql(parse_token_with = <fn>]` or `#[graphql(parse_token(<types>)]` attributes

```rust
# extern crate juniper;
# use juniper::{
# GraphQLScalar, InputValue, ParseScalarResult, ParseScalarValue,
# ScalarValue, ScalarToken, Value
Expand Down Expand Up @@ -224,6 +227,7 @@ Path can be simply `with = Self` (default path where macro expects resolvers to
in case there is an impl block with custom resolvers:

```rust
# extern crate juniper;
# use juniper::{
# GraphQLScalar, InputValue, ParseScalarResult, ParseScalarValue,
# ScalarValue, ScalarToken, Value
Expand Down Expand Up @@ -269,6 +273,7 @@ impl StringOrInt {
Or it can be path to a module, where custom resolvers are located.

```rust
# extern crate juniper;
# use juniper::{
# GraphQLScalar, InputValue, ParseScalarResult, ParseScalarValue,
# ScalarValue, ScalarToken, Value
Expand Down Expand Up @@ -319,6 +324,7 @@ mod string_or_int {
Also, you can partially override `#[graphql(with)]` attribute with other custom scalars.

```rust
# extern crate juniper;
# use juniper::{GraphQLScalar, InputValue, ParseScalarResult, ScalarValue, ScalarToken, Value};
#
#[derive(GraphQLScalar)]
Expand Down
22 changes: 0 additions & 22 deletions book/tests/Cargo.toml

This file was deleted.

4 changes: 0 additions & 4 deletions book/tests/build.rs

This file was deleted.

3 changes: 0 additions & 3 deletions book/tests/src/lib.rs

This file was deleted.

7 changes: 4 additions & 3 deletions tests/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ edition = "2021"
publish = false

[dependencies]
futures = "0.3.1"
juniper = { path = "../../juniper" }
rustversion = "1.0"

[dev-dependencies]
serde_json = "1.0"
tokio = { version = "1.0", features = ["rt", "time", "macros"] }
trybuild = "1.0.25"
trybuild = "1.0.63"
futures = "0.3.1"
juniper = { path = "../../juniper" }
35 changes: 3 additions & 32 deletions tests/codegen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,9 @@
// TODO: [Object] Type Validation: §4 (interfaces) for objects
// TODO: [Non-Null] §1 A Non‐Null type must not wrap another Non‐Null type.

#[cfg(test)]
use std::{
fs::{read_dir, DirEntry},
io,
path::{Path, PathBuf},
};

#[cfg(test)]
fn visit_dirs(dir: &Path, cb: &dyn Fn(&DirEntry)) -> io::Result<()> {
if dir.is_dir() {
for entry in read_dir(dir)? {
let entry = entry?;
let path = entry.path();
if path.is_dir() {
visit_dirs(&path, cb)?;
} else {
cb(&entry);
}
}
}
Ok(())
}

#[rustversion::nightly]
#[test]
fn test_failing_compiliation() {
fn test_failing_compilation() {
let t = trybuild::TestCases::new();
let dir = PathBuf::from("fail");

visit_dirs(dir.as_path(), &|entry: &DirEntry| {
if let Some(Some("rs")) = entry.path().extension().map(|os| os.to_str()) {
t.compile_fail(entry.path());
}
})
.unwrap();
t.compile_fail("fail/**/*.rs");
}
4 changes: 1 addition & 3 deletions tests/integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ version = "0.0.0"
edition = "2021"
publish = false

[dependencies]
[dev-dependencies]
chrono = "0.4"
derive_more = "0.99"
futures = "0.3"
juniper = { path = "../../juniper" }
juniper_subscriptions = { path = "../../juniper_subscriptions" }

[dev-dependencies]
async-trait = "0.1.39"
fnv = "1.0"
serde = { version = "1.0", features = ["derive"] }
Expand Down
15 changes: 0 additions & 15 deletions tests/integration/src/codegen/mod.rs

This file was deleted.

Loading