Skip to content

Commit

Permalink
chore: specify external types for each crate (#496)
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed Oct 30, 2023
1 parent 61b6e01 commit f967562
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 1 deletion.
23 changes: 23 additions & 0 deletions .github/workflows/clippy-fmt.yml → .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,26 @@ jobs:
reporter: 'github-pr-check'
github_token: ${{ secrets.GITHUB_TOKEN }}
clippy_flags: --workspace --all-features --tests --examples --bins -- -Dclippy::todo -Aunknown_lints

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
9 changes: 9 additions & 0 deletions actix-codec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ license = "MIT OR Apache-2.0"
edition.workspace = true
rust-version.workspace = true

[package.metadata.cargo_check_external_types]
allowed_external_types = [
"bytes::*",
"futures_core::*",
"futures_sink::*",
"tokio::*",
"tokio_util::*",
]

[dependencies]
bitflags = "2"
bytes = "1"
Expand Down
5 changes: 5 additions & 0 deletions actix-rt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ license = "MIT OR Apache-2.0"
edition.workspace = true
rust-version.workspace = true

[package.metadata.cargo_check_external_types]
allowed_external_types = [
"tokio::*",
]

[features]
default = ["macros"]
macros = ["actix-macros"]
Expand Down
5 changes: 5 additions & 0 deletions actix-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ license = "MIT OR Apache-2.0"
edition.workspace = true
rust-version.workspace = true

[package.metadata.cargo_check_external_types]
allowed_external_types = [
"tokio::*",
]

[features]
default = []
io-uring = ["tokio-uring", "actix-rt/io-uring"]
Expand Down
8 changes: 8 additions & 0 deletions actix-tls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ rust-version.workspace = true
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.cargo_check_external_types]
allowed_external_types = [
"actix_service::*",
"actix_utils::*",
"futures_core::*",
"tokio::*",
]

[package.metadata.cargo-machete]
ignored = [
"rustls_021", # specified to force version with add_trust_anchors method
Expand Down
8 changes: 8 additions & 0 deletions actix-tracing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ license = "MIT OR Apache-2.0"
edition.workspace = true
rust-version.workspace = true

[package.metadata.cargo_check_external_types]
allowed_external_types = [
"actix_service::*",
"actix_utils::*",
"tracing::*",
"tracing_futures::*",
]

[dependencies]
actix-service = "2"
actix-utils = "3"
Expand Down
8 changes: 7 additions & 1 deletion bytestring/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ authors = [
keywords = ["string", "bytes", "utf8", "web", "actix"]
categories = ["no-std", "web-programming"]
homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git"
repository = "https://github.com/actix/actix-net"
license = "MIT OR Apache-2.0"
edition.workspace = true
rust-version.workspace = true

[package.metadata.cargo_check_external_types]
allowed_external_types = [
"bytes::*",
"serde::*",
]

[dependencies]
bytes = { version = "1.2", default-features = false }
serde = { version = "1.0", optional = true }
Expand Down
25 changes: 25 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,28 @@ 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:
#!/usr/bin/env bash
set -euo pipefail
for f in $(find . -mindepth 2 -maxdepth 2 -name Cargo.toml); do
echo "Checking for $f"
just check-external-types-manifest "$f" || true
echo
echo
done

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

# Check for unintentional external type exposure on a crate.
check-external-types-manifest manifest_path *extra_args:
cargo +nightly check-external-types --manifest-path "{{manifest_path}}" {{extra_args}}
6 changes: 6 additions & 0 deletions local-channel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ license.workspace = true
edition.workspace = true
rust-version.workspace = true

[package.metadata.cargo_check_external_types]
allowed_external_types = [
"futures_core::*",
"futures_sink::*",
]

[dependencies]
futures-core = "0.3.17"
futures-sink = "0.3.17"
Expand Down

0 comments on commit f967562

Please sign in to comment.