Re-integrate examples into the root workspace (#1466)

Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
This commit is contained in:
Jonas Platte 2023-03-10 12:02:11 +01:00 committed by GitHub
parent e7eda0e416
commit dc480f7b0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
44 changed files with 60 additions and 78 deletions

View file

@ -13,15 +13,9 @@ on:
jobs: jobs:
check: check:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
pwd:
- .
- examples
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@master
- uses: arduino/setup-protoc@v1 - uses: arduino/setup-protoc@v1
if: matrix.pwd == 'examples'
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: dtolnay/rust-toolchain@stable - uses: dtolnay/rust-toolchain@stable
@ -31,17 +25,16 @@ jobs:
profile: minimal profile: minimal
components: clippy, rustfmt components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.pwd }}
workspaces: ${{ matrix.pwd }}
- name: Check - name: Check
working-directory: ${{ matrix.pwd }} uses: actions-rs/cargo@v1
run: | with:
cargo clippy --all --all-targets --all-features command: clippy
args: --workspace --all-targets --all-features
- name: rustfmt - name: rustfmt
working-directory: ${{ matrix.pwd }} uses: actions-rs/cargo@v1
run: | with:
cargo fmt --all -- --check command: fmt
args: -- --check
check-docs: check-docs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -62,6 +55,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@master
- uses: arduino/setup-protoc@v1
- uses: dtolnay/rust-toolchain@stable - uses: dtolnay/rust-toolchain@stable
with: with:
toolchain: stable toolchain: stable
@ -101,6 +95,7 @@ jobs:
rust: [stable, beta] rust: [stable, beta]
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@master
- uses: arduino/setup-protoc@v1
- uses: dtolnay/rust-toolchain@stable - uses: dtolnay/rust-toolchain@stable
with: with:
toolchain: ${{ matrix.rust }} toolchain: ${{ matrix.rust }}
@ -113,6 +108,7 @@ jobs:
command: test command: test
args: --all --all-features --all-targets args: --all --all-features --all-targets
# some examples doesn't support our MSRV so we only test axum itself on our MSRV
test-nightly: test-nightly:
needs: check needs: check
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -269,11 +265,6 @@ jobs:
dependencies-are-sorted: dependencies-are-sorted:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
pwd:
- .
- examples
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@master
- uses: dtolnay/rust-toolchain@stable - uses: dtolnay/rust-toolchain@stable
@ -282,16 +273,12 @@ jobs:
override: true override: true
profile: minimal profile: minimal
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.pwd }}
workspaces: ${{ matrix.pwd }}
- name: Install cargo-sort - name: Install cargo-sort
run: | run: |
cargo install cargo-sort cargo install cargo-sort
# Work around cargo-sort not honoring workspace.exclude
- name: Remove non-crate folder - name: Remove non-crate folder
run: rm -rf async-graphql || true run: rm -rf examples/async-graphql
working-directory: ${{ matrix.pwd }}
- name: Check dependency tables - name: Check dependency tables
working-directory: ${{ matrix.pwd }}
run: | run: |
cargo sort --workspace --grouped --check cargo sort --workspace --grouped --check

4
.gitignore vendored
View file

@ -1,5 +1,3 @@
/target target
/examples/target
/examples/*/target
Cargo.lock Cargo.lock
.DS_Store .DS_Store

View file

@ -1,8 +1,7 @@
[workspace] [workspace]
members = [ members = ["axum", "axum-*", "examples/*"]
"axum", # Only check / build main crates by default (check all with `--workspace`)
"axum-core", default-members = ["axum", "axum-*"]
"axum-extra", # Example has been deleted, but README.md remains
"axum-macros", exclude = ["examples/async-graphql"]
]
resolver = "2" resolver = "2"

View file

@ -21,6 +21,8 @@ skip-tree = [
{ name = "base64" }, { name = "base64" },
# parking_lot pulls in old versions of windows-sys # parking_lot pulls in old versions of windows-sys
{ name = "windows-sys" }, { name = "windows-sys" },
# old version pulled in by rustls via ring
{ name = "spin" },
] ]
[sources] [sources]

View file

@ -1,4 +0,0 @@
[workspace]
members = ["*"]
exclude = ["async-graphql", "target"]
resolver = "2"

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-anyhow-error-response //! cargo run -p example-anyhow-error-response
//! ``` //! ```
use axum::{ use axum::{

View file

@ -3,7 +3,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-chat //! cargo run -p example-chat
//! ``` //! ```
use axum::{ use axum::{

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-consume-body-in-extractor-or-middleware //! cargo run -p example-consume-body-in-extractor-or-middleware
//! ``` //! ```
use axum::{ use axum::{

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-cors //! cargo run -p example-cors
//! ``` //! ```
use axum::{ use axum::{

View file

@ -12,5 +12,5 @@ already existing extractors
Run with Run with
```sh ```sh
cd examples && cargo run -p example-customize-extractor-error cargo run -p example-customize-extractor-error
``` ```

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-customize-extractor-error //! cargo run -p example-customize-extractor-error
//! ``` //! ```
mod custom_extractor; mod custom_extractor;

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-customize-path-rejection //! cargo run -p example-customize-path-rejection
//! ``` //! ```
use axum::{ use axum::{

View file

@ -4,7 +4,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-error-handling-and-dependency-injection //! cargo run -p example-error-handling-and-dependency-injection
//! ``` //! ```
use axum::{ use axum::{

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-form //! cargo run -p example-form
//! ``` //! ```
use axum::{extract::Form, response::Html, routing::get, Router}; use axum::{extract::Form, response::Html, routing::get, Router};

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-global-404-handler //! cargo run -p example-global-404-handler
//! ``` //! ```
use axum::{ use axum::{

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-graceful-shutdown //! cargo run -p example-graceful-shutdown
//! kill or ctrl-c //! kill or ctrl-c
//! ``` //! ```

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-handle-head-request //! cargo run -p example-handle-head-request
//! ``` //! ```
use axum::response::{IntoResponse, Response}; use axum::response::{IntoResponse, Response};

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-hello-world //! cargo run -p example-hello-world
//! ``` //! ```
use axum::{response::Html, routing::get, Router}; use axum::{response::Html, routing::get, Router};

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-hyper-1-0 //! cargo run -p example-hyper-1-0
//! ``` //! ```
use axum::{routing::get, Router}; use axum::{routing::get, Router};

View file

@ -3,7 +3,7 @@
//! Run with: //! Run with:
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-key-value-store //! cargo run -p example-key-value-store
//! ``` //! ```
use axum::{ use axum::{

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-low-level-rustls //! cargo run -p example-low-level-rustls
//! ``` //! ```
use axum::{extract::ConnectInfo, routing::get, Router}; use axum::{extract::ConnectInfo, routing::get, Router};

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-multipart-form //! cargo run -p example-multipart-form
//! ``` //! ```
use axum::{ use axum::{

View file

@ -3,7 +3,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-parse-body-based-on-content-type //! cargo run -p example-parse-body-based-on-content-type
//! ``` //! ```
use axum::{ use axum::{

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-print-request-response //! cargo run -p example-print-request-response
//! ``` //! ```
use axum::{ use axum::{

View file

@ -4,7 +4,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-prometheus-metrics //! cargo run -p example-prometheus-metrics
//! ``` //! ```
use axum::{ use axum::{

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-query-params-with-empty-strings //! cargo run -p example-query-params-with-empty-strings
//! ``` //! ```
use axum::{extract::Query, routing::get, Router}; use axum::{extract::Query, routing::get, Router};

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-readme //! cargo run -p example-readme
//! ``` //! ```
use axum::{ use axum::{

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-rest-grpc-multiplex //! cargo run -p example-rest-grpc-multiplex
//! ``` //! ```
use self::multiplex_service::MultiplexService; use self::multiplex_service::MultiplexService;

View file

@ -4,7 +4,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-reverse-proxy //! cargo run -p example-reverse-proxy
//! ``` //! ```
use axum::{ use axum::{

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-routes-and-handlers-close-together //! cargo run -p example-routes-and-handlers-close-together
//! ``` //! ```
use axum::{ use axum::{

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-sessions //! cargo run -p example-sessions
//! ``` //! ```
use async_session::{MemoryStore, Session, SessionStore as _}; use async_session::{MemoryStore, Session, SessionStore as _};

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-simple-router-wasm //! cargo run -p example-simple-router-wasm
//! ``` //! ```
//! //!
//! This example shows what using axum in a wasm context might look like. This example should //! This example shows what using axum in a wasm context might look like. This example should

View file

@ -3,7 +3,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-sqlx-postgres //! cargo run -p example-sqlx-postgres
//! ``` //! ```
//! //!
//! Test with curl: //! Test with curl:

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-sse //! cargo run -p example-sse
//! ``` //! ```
use axum::{ use axum::{

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples/static-file-server && cargo run -p example-static-file-server //! cargo run -p example-static-file-server
//! ``` //! ```
use axum::{ use axum::{

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-stream-to-file //! cargo run -p example-stream-to-file
//! ``` //! ```
use axum::{ use axum::{

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-templates //! cargo run -p example-templates
//! ``` //! ```
use askama::Template; use askama::Template;

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-tls-rustls //! cargo run -p example-tls-rustls
//! ``` //! ```
use axum::{ use axum::{

View file

@ -10,7 +10,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-todos //! cargo run -p example-todos
//! ``` //! ```
use axum::{ use axum::{

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-tokio-postgres //! cargo run -p example-tokio-postgres
//! ``` //! ```
use axum::{ use axum::{

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-tracing-aka-logging //! cargo run -p example-tracing-aka-logging
//! ``` //! ```
use axum::{ use axum::{

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-unix-domain-socket //! cargo run -p example-unix-domain-socket
//! ``` //! ```
#[cfg(unix)] #[cfg(unix)]

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-validator //! cargo run -p example-validator
//! //!
//! curl '127.0.0.1:3000?name=' //! curl '127.0.0.1:3000?name='
//! -> Input validation error: [name: Can not be empty] //! -> Input validation error: [name: Can not be empty]

View file

@ -1,7 +1,7 @@
//! Run with //! Run with
//! //!
//! ```not_rust //! ```not_rust
//! cd examples && cargo run -p example-versioning //! cargo run -p example-versioning
//! ``` //! ```
use axum::{ use axum::{