diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b98380d..27a6250 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,20 +14,20 @@ check-example: before_script: - cargo -V script: - - cd example - - cargo check + - cargo check --manifest-path example/Cargo.toml cache: key: cargo-stable-example paths: - cargo/ - target/ - + test-default: stage: test image: rust:1.49-slim before_script: - cargo -V script: + - cargo test --manifest-path openapi_type/Cargo.toml -- --skip trybuild - cargo test cache: key: cargo-1-49-default @@ -43,6 +43,7 @@ test-full: - apt install -y --no-install-recommends libpq-dev - cargo -V script: + - cargo test --manifest-path openapi_type/Cargo.toml --all-features -- --skip trybuild - cargo test --no-default-features --features full cache: key: cargo-1-49-all @@ -79,6 +80,7 @@ test-trybuild-ui: - apt install -y --no-install-recommends libpq-dev - cargo -V script: + - cargo test --manifest-path openapi_type/Cargo.toml --all-features -- trybuild - cargo test --no-default-features --features full --tests -- --ignored cache: key: cargo-1-50-all @@ -107,8 +109,9 @@ rustfmt: - cargo -V - cargo fmt --version script: - - cargo fmt -- --check + - cargo fmt --all -- --check - ./tests/ui/rustfmt.sh --check + - ./openapi-type/tests/fail/rustfmt.sh --check doc: stage: build diff --git a/openapi_type/tests/fail/not_openapitype_generics.stderr b/openapi_type/tests/fail/not_openapitype_generics.stderr index d41098b..d33bafe 100644 --- a/openapi_type/tests/fail/not_openapitype_generics.stderr +++ b/openapi_type/tests/fail/not_openapitype_generics.stderr @@ -16,6 +16,8 @@ error[E0599]: no function or associated item named `schema` found for struct `Fo = note: the method `schema` exists but the following trait bounds were not satisfied: `Bar: OpenapiType` which is required by `Foo: OpenapiType` + `Foo: OpenapiType` + which is required by `&Foo: OpenapiType` = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `schema`, perhaps you need to implement it: candidate #1: `OpenapiType` diff --git a/openapi_type/tests/fail/rustfmt.sh b/openapi_type/tests/fail/rustfmt.sh new file mode 100755 index 0000000..a93f958 --- /dev/null +++ b/openapi_type/tests/fail/rustfmt.sh @@ -0,0 +1,21 @@ +#!/bin/busybox ash +set -euo pipefail + +rustfmt=${RUSTFMT:-rustfmt} +version="$($rustfmt -V)" +case "$version" in + *nightly*) + # all good, no additional flags required + ;; + *) + # assume we're using some sort of rustup setup + rustfmt="$rustfmt +nightly" + ;; +esac + +return=0 +find "$(dirname "$0")" -name '*.rs' -type f | while read file; do + $rustfmt --config-path "$(dirname "$0")/../../../rustfmt.toml" "$@" "$file" || return=1 +done + +exit $return