diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d4259e10..88d49b7ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,6 +48,23 @@ jobs: args: --all -- --check - name: Lint run: ./scripts/lint.sh + external-types: + strategy: + matrix: + example: [opentelemetry, opentelemetry-sdk] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + components: rustfmt + override: true + - name: external-type-check + run: | + cargo install cargo-check-external-types + cd ${{ matrix.example }} + cargo check-external-types --config allowed-external-types.toml non-default-examples: strategy: matrix: diff --git a/opentelemetry-sdk/allowed-external-types.toml b/opentelemetry-sdk/allowed-external-types.toml new file mode 100644 index 000000000..11d11b899 --- /dev/null +++ b/opentelemetry-sdk/allowed-external-types.toml @@ -0,0 +1,18 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 +# This is used with cargo-check-external-types to reduce the surface area of downstream crates from +# the public API. Ideally this can have a few exceptions as possible. +allowed_external_types = [ + "opentelemetry::*", + "async_channel::Receiver", + "async_channel::Sender", + "async_std::stream::interval::Interval", + "futures_channel::oneshot::Sender", # TODO: This is a pre-1.0 crate, we can't easily stabilize with this in the public API + "futures_core::future::BoxFuture", # TODO: This is a pre-1.0 crate, we can't easily stabilize with this in the public API + "futures_core::stream::Stream", # TODO: This is a pre-1.0 crate, we can't easily stabilize with this in the public API + "opentelemetry_http::HttpClient", # TODO: We probably shouldn't be depending on another SDK not in the API from the SDK. + "tokio_stream::wrappers::interval::IntervalStream", # TODO: This is a pre-1.0 crate, we can't easily stabilize with this in the public API + "tokio_stream::wrappers::mpsc_bounded::ReceiverStream", # TODO: This is a pre-1.0 crate, we can't easily stabilize with this in the public API + "tokio::sync::mpsc::bounded::Sender", + "tokio::time::sleep::Sleep", +] diff --git a/opentelemetry/allowed-external-types.toml b/opentelemetry/allowed-external-types.toml new file mode 100644 index 000000000..3cc9df234 --- /dev/null +++ b/opentelemetry/allowed-external-types.toml @@ -0,0 +1,19 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 +# This is used with cargo-check-external-types to reduce the surface area of downstream crates from +# the public API. Ideally this can have a few exceptions as possible. +allowed_external_types = [ + "indexmap::map::core::Entry", + "indexmap::map::iter::Drain", + "indexmap::map::iter::IterMut", + "indexmap::map::iter::Iter", + "indexmap::map::iter::IntoIter", + "indexmap::map::iter::IntoKeys", + "indexmap::map::iter::Keys", + "indexmap::map::iter::IntoValues", + "indexmap::map::iter::Values", + "indexmap::map::iter::ValuesMut", + "equivalent::Equivalent", + "futures_sink::Sink", # TODO: This is a pre-1.0 crate, we can't easily stabilize with this in the public API + "futures_core::stream::Stream", # TODO: This is a pre-1.0 crate, we can't easily stabilize with this in the public API +]