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 all 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
53 changes: 36 additions & 17 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 @@ -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,14 +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:
- uses: actions/checkout@v3
Expand All @@ -213,6 +205,34 @@ jobs:

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

test-book:
name: test Book
strategy:
fail-fast: false
matrix:
os:
- ubuntu
- macOS
# TODO: Re-enable once rust-lang/rust#99466 is fixed:
# https://github.com/rust-lang/rust/issues/99466
#- windows
toolchain:
- stable
- beta
- nightly
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
override: true

- run: cargo install mdbook

- run: make test.book

wasm:
strategy:
fail-fast: false
Expand Down Expand Up @@ -281,6 +301,7 @@ jobs:
- package
- rustfmt
- test
- test-book
- wasm
if: ${{ startsWith(github.ref, 'refs/tags/juniper') }}
runs-on: ubuntu-latest
Expand All @@ -304,7 +325,7 @@ jobs:
- name: Parse CHANGELOG link
id: changelog
run: echo ::set-output
name=LINK::https://github.com/${{ github.repository }}/blob/${{ steps.crate.outputs.NAME }}%40${{ steps.release.outputs.VERSION }}//${{ steps.crate.outputs.NAME }}/CHANGELOG.md#$(sed -n '/^## \[${{ steps.release.outputs.VERSION }}\]/{s/^## \[\(.*\)\][^0-9]*\([0-9].*\)/\1--\2/;s/[^0-9a-z-]*//g;p;}' ${{ steps.crate.outputs.NAME }}/CHANGELOG.md)
name=LINK::${{ github.server_url }}/${{ github.repository }}/blob/${{ steps.crate.outputs.NAME }}%40${{ steps.release.outputs.VERSION }}//${{ steps.crate.outputs.NAME }}/CHANGELOG.md#$(sed -n '/^## \[${{ steps.release.outputs.VERSION }}\]/{s/^## \[\(.*\)\][^0-9]*\([0-9].*\)/\1--\2/;s/[^0-9a-z-]*//g;p;}' ${{ steps.crate.outputs.NAME }}/CHANGELOG.md)

- uses: softprops/action-gh-release@v1
env:
Expand Down Expand Up @@ -347,19 +368,17 @@ jobs:

deploy-book:
name: deploy Book
needs: ["test"]
needs: ["test", "test-book"]
if: ${{ github.ref == 'refs/heads/master'
|| startsWith(github.ref, 'refs/tags/juniper@') }}
|| startsWith(github.ref, 'refs/tags/juniper@') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: peaceiris/actions-mdbook@v1

- run: make book.build out=gh-pages/master
if: ${{ github.ref == 'refs/heads/master' }}

- run: make book.build out=gh-pages
if: ${{ startsWith(github.ref, 'refs/tags/juniper@') }}
- run: make book.build out=gh-pages${{ (github.ref == 'refs/heads/master'
&& '/master')
|| '' }}

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
Expand Down
13 changes: 5 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,16 @@ Before submitting a PR, you should follow these steps to prevent redundant churn

Consistent formatting is enforced on the CI.

Before you submit your PR, you should run `cargo fmt` in the root directory.
Before you submit your PR, you should run `cargo +nightly fmt --all` in the root directory (or use the `make fmt` shortcut).

Formatting should be run on the **stable** compiler.
(You can do `rustup run stable cargo fmt` when developing on nightly)
Formatting should be run on the **nightly** compiler.

### Run all tests

To run all available tests, including verifying the code examples in the book,
you can use [cargo-make](https://github.com/sagiegurari/cargo-make).
To run all available tests, including verifying the code examples in the book:

1. Install cargo-make with `cargo install cargo-make`
2. Run `cargo make ci-flow` in the root directory
(You can do `rustup run nightly cargo make ci-flow` to run all tests when developing on stable)
1. Run `cargo test` in the root directory.
2. Run `make test.book` in the root directory.

### Update the CHANGELOG

Expand Down
1 change: 0 additions & 1 deletion 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 Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,14 @@ cargo.test: test.cargo
# Run Rust tests of Book.
#
# Usage:
# make test.book
# make test.book [clean=(no|yes)]

test.book:
@make test.cargo crate=juniper_book_tests
ifeq ($(clean),yes)
cargo clean
endif
cargo build
mdbook test book -L target/debug/deps


# Run Rust tests of project crates.
Expand Down
15 changes: 1 addition & 14 deletions book/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,8 @@ 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
mdbook test -L ../target/debug/deps

# or via shortcut from project root dir:
make test.book
```




## 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.
7 changes: 4 additions & 3 deletions book/src/advanced/subscriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ This example shows a subscription operation that returns two events, the strings
sequentially:

```rust
# use juniper::{graphql_object, graphql_subscription, FieldError};
# use futures::Stream;
# extern crate futures;
# extern crate juniper;
# use std::pin::Pin;
# use futures::Stream;
# use juniper::{graphql_object, graphql_subscription, FieldError};
#
# #[derive(Clone)]
# pub struct Database;
Expand Down Expand Up @@ -80,7 +82,6 @@ where [`Connection`][Connection] is a `Stream` of values returned by the operati
# extern crate juniper;
# extern crate juniper_subscriptions;
# extern crate serde_json;
# extern crate tokio;
# use juniper::{
# http::GraphQLRequest,
# graphql_object, graphql_subscription,
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]
futures = "0.3.1"
juniper = { path = "../../juniper" }
serde_json = "1.0"
tokio = { version = "1.0", features = ["rt", "time", "macros"] }
trybuild = "1.0.25"
trybuild = "1.0.63"
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ error[E0080]: evaluation of constant value failed
16 | id: String,
| ^^ the evaluated program panicked at 'Failed to implement interface `Character` on `ObjA`: Field `id`: Argument `isPresent` of type `Boolean!` isn't present on the interface and so has to be nullable.', $DIR/fail/interface/struct/attr_additional_non_nullable_argument.rs:16:5
|
= note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `::juniper::assert_field` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation of constant value failed
--> fail/interface/struct/attr_additional_non_nullable_argument.rs:16:5
|
16 | id: String,
| ^^ the evaluated program panicked at 'Failed to implement interface `Character` on `ObjA`: Field `id`: Argument `isPresent` of type `Boolean!` isn't present on the interface and so has to be nullable.', $DIR/fail/interface/struct/attr_additional_non_nullable_argument.rs:16:5
|
= note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `::juniper::assert_field` (in Nightly builds, run with -Z macro-backtrace for more info)
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ error[E0080]: evaluation of constant value failed
3 | #[derive(GraphQLObject)]
| ^^^^^^^^^^^^^ referenced constant has errors
|
= note: this error originates in the macro `$crate::const_concat` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::const_concat` which comes from the expansion of the derive macro `GraphQLObject` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation of constant value failed
--> fail/interface/struct/attr_implementers_duplicate_pretty.rs:3:10
|
3 | #[derive(GraphQLObject)]
| ^^^^^^^^^^^^^ referenced constant has errors
|
= note: this error originates in the macro `$crate::const_concat` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::const_concat` which comes from the expansion of the derive macro `GraphQLObject` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation of constant value failed
--> fail/interface/struct/attr_implementers_duplicate_pretty.rs:3:10
|
3 | #[derive(GraphQLObject)]
| ^^^^^^^^^^^^^ referenced constant has errors
|
= note: this error originates in the macro `$crate::const_concat` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `$crate::const_concat` which comes from the expansion of the derive macro `GraphQLObject` (in Nightly builds, run with -Z macro-backtrace for more info)
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ error[E0119]: conflicting implementations of trait `<CharacterValueEnum<ObjA, Ob
| first implementation here
| conflicting implementation for `ObjA`
|
= note: this error originates in the macro `::juniper::sa::assert_type_ne_all` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `::juniper::sa::assert_type_ne_all` which comes from the expansion of the attribute macro `graphql_interface` (in Nightly builds, run with -Z macro-backtrace for more info)
Loading