Skip to content
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

ci: external types checking #3175

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 34 additions & 6 deletions .github/workflows/clippy-fmt.yml → .github/workflows/lint.yml
Expand Up @@ -17,7 +17,8 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions-rust-lang/setup-rust-toolchain@v1.5.0
- name: Install Rust (nightly)
uses: actions-rust-lang/setup-rust-toolchain@v1.5.0
with:
toolchain: nightly
components: rustfmt
Expand All @@ -32,7 +33,8 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions-rust-lang/setup-rust-toolchain@v1.5.0
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1.5.0
with:
components: clippy

Expand All @@ -47,7 +49,8 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions-rust-lang/setup-rust-toolchain@v1.5.0
- name: Install Rust (nightly)
uses: actions-rust-lang/setup-rust-toolchain@v1.5.0
with:
toolchain: nightly
components: rust-docs
Expand All @@ -57,6 +60,29 @@ jobs:
RUSTDOCFLAGS: -D warnings
run: cargo +nightly doc --no-deps --workspace --all-features

check-external-types:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust (nightly-2023-10-10)
uses: actions-rust-lang/setup-rust-toolchain@v1.5.0
with:
toolchain: nightly-2023-10-10

- name: Install just
uses: taiki-e/install-action@v2.20.2
with:
tool: just

- name: Install cargo-check-external-types
uses: taiki-e/cache-cargo-install-action@v1.2.2
with:
tool: cargo-check-external-types@0.1.10

- name: check external types
run: just check-external-types-all +nightly-2023-10-10

public-api-diff:
runs-on: ubuntu-latest
steps:
Expand All @@ -66,13 +92,15 @@ jobs:

- uses: actions/checkout@v4

- uses: actions-rust-lang/setup-rust-toolchain@v1.5.0
- name: Install Rust (nightly-2023-08-25)
uses: actions-rust-lang/setup-rust-toolchain@v1.5.0
with:
toolchain: nightly-2023-08-25

- uses: taiki-e/cache-cargo-install-action@v1.2.2
- name: Install cargo-public-api
uses: taiki-e/cache-cargo-install-action@v1.2.2
with:
tool: cargo-public-api
tool: cargo-public-api@0.32.0

- name: generate API diff
run: |
Expand Down
11 changes: 8 additions & 3 deletions actix-files/Cargo.toml
Expand Up @@ -13,9 +13,14 @@ categories = ["asynchronous", "web-programming::http-server"]
license = "MIT OR Apache-2.0"
edition = "2021"

[lib]
name = "actix_files"
path = "src/lib.rs"
[package.metadata.cargo_check_external_types]
allowed_external_types = [
"actix_http::*",
"actix_service::*",
"actix_web::*",
"http::*",
"mime::*",
]

[features]
experimental-io-uring = ["actix-web/experimental-io-uring", "tokio-uring"]
Expand Down
14 changes: 11 additions & 3 deletions actix-http-test/Cargo.toml
Expand Up @@ -18,9 +18,17 @@ edition = "2021"
[package.metadata.docs.rs]
features = []

[lib]
name = "actix_http_test"
path = "src/lib.rs"
[package.metadata.cargo_check_external_types]
allowed_external_types = [
"actix_codec::*",
"actix_http::*",
"actix_server::*",
"awc::*",
"bytes::*",
"futures_core::*",
"http::*",
"tokio::*",
]

[features]
default = []
Expand Down
23 changes: 20 additions & 3 deletions actix-http/Cargo.toml
Expand Up @@ -23,9 +23,26 @@ rust-version.workspace = true
# features that docs.rs will build with
features = ["http2", "ws", "openssl", "rustls-0_20", "rustls-0_21", "compress-brotli", "compress-gzip", "compress-zstd"]

[lib]
name = "actix_http"
path = "src/lib.rs"
[package.metadata.cargo_check_external_types]
allowed_external_types = [
"actix_codec::*",
"actix_service::*",
"actix_tls::*",
"actix_utils::*",
"bytes::*",
"bytestring::*",
"encoding_rs::*",
"futures_core::*",
"h2::*",
"http::*",
"httparse::*",
"language_tags::*",
"mime::*",
"openssl::*",
"rustls::*",
"tokio_util::*",
"tokio::*",
]

[features]
default = []
Expand Down
15 changes: 15 additions & 0 deletions actix-multipart/Cargo.toml
Expand Up @@ -16,6 +16,21 @@ edition = "2021"
rustdoc-args = ["--cfg", "docsrs"]
all-features = true

[package.metadata.cargo_check_external_types]
allowed_external_types = [
"actix_http::*",
"actix_multipart_derive::*",
"actix_utils::*",
"actix_web::*",
"bytes::*",
"futures_core::*",
"mime::*",
"serde_json::*",
"serde_plain::*",
"serde::*",
"tempfile::*",
]

[features]
default = ["tempfile", "derive"]
derive = ["actix-multipart-derive"]
Expand Down
8 changes: 5 additions & 3 deletions actix-router/Cargo.toml
Expand Up @@ -12,9 +12,11 @@ repository = "https://github.com/actix/actix-web.git"
license = "MIT OR Apache-2.0"
edition = "2021"

[lib]
name = "actix_router"
path = "src/lib.rs"
[package.metadata.cargo_check_external_types]
allowed_external_types = [
"http::*",
"serde::*",
]

[features]
default = ["http"]
Expand Down
16 changes: 16 additions & 0 deletions actix-test/Cargo.toml
Expand Up @@ -18,6 +18,22 @@ categories = [
license = "MIT OR Apache-2.0"
edition = "2021"

[package.metadata.cargo_check_external_types]
allowed_external_types = [
"actix_codec::*",
"actix_http_test::*",
"actix_http::*",
"actix_service::*",
"actix_web::*",
"awc::*",
"bytes::*",
"futures_core::*",
"http::*",
"openssl::*",
"rustls::*",
"tokio::*",
]

[features]
default = []

Expand Down
12 changes: 9 additions & 3 deletions actix-web-actors/Cargo.toml
Expand Up @@ -9,9 +9,15 @@ repository = "https://github.com/actix/actix-web"
license = "MIT OR Apache-2.0"
edition = "2021"

[lib]
name = "actix_web_actors"
path = "src/lib.rs"
[package.metadata.cargo_check_external_types]
allowed_external_types = [
"actix::*",
"actix_http::*",
"actix_web::*",
"bytes::*",
"bytestring::*",
"futures_core::*",
]

[dependencies]
actix = { version = ">=0.12, <0.14", default-features = false }
Expand Down
28 changes: 25 additions & 3 deletions actix-web/Cargo.toml
Expand Up @@ -24,9 +24,31 @@ rust-version.workspace = true
features = ["macros", "openssl", "rustls-0_20", "rustls-0_21", "compress-brotli", "compress-gzip", "compress-zstd", "cookies", "secure-cookies"]
rustdoc-args = ["--cfg", "docsrs"]

[lib]
name = "actix_web"
path = "src/lib.rs"
[package.metadata.cargo_check_external_types]
allowed_external_types = [
"actix_http::*",
"actix_router::*",
"actix_rt::*",
"actix_server::*",
"actix_service::*",
"actix_utils::*",
"actix_web_codegen::*",
"bytes::*",
"cookie::*",
"cookie",
"futures_core::*",
"http::*",
"language_tags::*",
"mime::*",
"openssl::*",
"rustls::*",
"serde_json::*",
"serde_urlencoded::*",
"serde::*",
"serde::*",
"tokio::*",
"url::*",
]

[features]
default = ["macros", "compress-brotli", "compress-gzip", "compress-zstd", "cookies", "http2"]
Expand Down
25 changes: 21 additions & 4 deletions awc/Cargo.toml
Expand Up @@ -15,14 +15,31 @@ repository = "https://github.com/actix/actix-web.git"
license = "MIT OR Apache-2.0"
edition = "2021"

[lib]
name = "awc"
path = "src/lib.rs"

[package.metadata.docs.rs]
# features that docs.rs will build with
features = ["openssl", "rustls-0_20", "rustls-0_21", "compress-brotli", "compress-gzip", "compress-zstd", "cookies"]

[package.metadata.cargo_check_external_types]
allowed_external_types = [
# "actix_codec::*",
"actix_http::*",
"actix_rt::*",
"actix_service::*",
"actix_tls::*",
"bytes::*",
"cookie::*",
"cookie",
"futures_core::*",
"h2::*",
"http::*",
"openssl::*",
"rustls::*",
"serde_json::*",
"serde_urlencoded::*",
"serde::*",
"tokio::*",
]

[features]
default = ["compress-brotli", "compress-gzip", "compress-zstd", "cookies"]

Expand Down
26 changes: 26 additions & 0 deletions justfile
Expand Up @@ -9,3 +9,29 @@ doc:
doc-watch:
RUSTDOCFLAGS="--cfg=docsrs" cargo +nightly doc --no-deps --workspace --features=rustls,openssl --open
cargo watch -- RUSTDOCFLAGS="--cfg=docsrs" cargo +nightly doc --no-deps --workspace --features=rustls,openssl

# Check for unintentional external type exposure on all crates in workspace.
check-external-types-all toolchain="+nightly":
#!/usr/bin/env bash
set -euo pipefail
exit=0
for f in $(find . -mindepth 2 -maxdepth 2 -name Cargo.toml | grep -vE "\-codegen/|\-derive/|\-macros/"); do
if ! just check-external-types-manifest "$f" {{toolchain}}; then exit=1; fi
echo
echo
done
exit $exit

# Check for unintentional external type exposure on all crates in workspace.
check-external-types-all-table toolchain="+nightly":
#!/usr/bin/env bash
set -euo pipefail
for f in $(find . -mindepth 2 -maxdepth 2 -name Cargo.toml | grep -vE "\-codegen/|\-derive/|\-macros/"); do
echo
echo "Checking for $f"
just check-external-types-manifest "$f" {{toolchain}} --output-format=markdown-table
done

# Check for unintentional external type exposure on a crate.
check-external-types-manifest manifest_path toolchain="+nightly" *extra_args="":
cargo {{toolchain}} check-external-types --manifest-path "{{manifest_path}}" {{extra_args}}
4 changes: 3 additions & 1 deletion scripts/bump
Expand Up @@ -93,7 +93,9 @@ fi

# done; remove backup files
rm -f $CARGO_MANIFEST.bak
rm -f $CHANGELOG_FILE.bak
if [ -n "${CHANGELOG_FILE-}" ]; then
rm -f $CHANGELOG_FILE.bak
fi
rm -f $README_FILE.bak

echo "manifest, changelog, and readme updated"
Expand Down