From d720770b0717af167d26ba123830b41fb9f316db Mon Sep 17 00:00:00 2001 From: John DiSanti Date: Wed, 24 Aug 2022 04:35:32 -0700 Subject: [PATCH] ci: add `cargo-check-external-types` check (#4914) --- .github/workflows/ci.yml | 25 +++++++++++++++++++++++++ tokio/external-types.toml | 16 ++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 tokio/external-types.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea9944bbd6b..3a5b83b7aa5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,6 +51,7 @@ jobs: - test-hyper - wasm32-unknown-unknown - wasm32-wasi + - check-external-types steps: - run: exit 0 @@ -513,3 +514,27 @@ jobs: # TODO: this should become: `cargo hack wasi test --each-feature` run: cargo wasi test --test rt_yield --features wasi-rt working-directory: tests-integration + + check-external-types: + name: check-external-types + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - windows-latest + - ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install Rust ${{ env.rust_nightly }} + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ env.rust_nightly }} + override: true + - uses: Swatinem/rust-cache@v1 + - name: check-external-types + run: | + set -x + cargo install cargo-check-external-types --locked --version 0.1.3 + cargo check-external-types --all-features --config external-types.toml + working-directory: tokio + diff --git a/tokio/external-types.toml b/tokio/external-types.toml new file mode 100644 index 00000000000..fba14f532c3 --- /dev/null +++ b/tokio/external-types.toml @@ -0,0 +1,16 @@ +# This config file is for the `cargo-check-external-types` tool that is run in CI. + +# The following are types that are allowed to be exposed in Tokio's public API. +# The standard library is allowed by default. +allowed_external_types = [ + "bytes::buf::buf_impl::Buf", + "bytes::buf::buf_mut::BufMut", + + "tokio_macros::*", + + # TODO(https://github.com/tokio-rs/tokio/issues/4916): Remove the libc types + "libc::unix::gid_t", + "libc::unix::pid_t", + "libc::unix::uid_t", +] +