Skip to content

Commit

Permalink
ci: Prepare for addition of non-additive features
Browse files Browse the repository at this point in the history
See #94 for the context.
  • Loading branch information
taiki-e committed Jun 4, 2023
1 parent 2c9e790 commit 8fcbe7c
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 5 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ env:
RUSTDOCFLAGS: -D warnings
RUSTFLAGS: -D warnings
RUSTUP_MAX_RETRIES: 10
# NB: sync with:
# - docs.rs metadata in Cargo.toml
# - test_features list in tools/build.sh and tools/test.sh.
TEST_FEATURES: float,std,serde,critical-section

defaults:
run:
Expand All @@ -47,7 +51,7 @@ jobs:
with:
event_name: ${{ github.event_name }}
# Exclude serde and critical-section features because the MSRV when it is enabled depends on the MSRV of them
args: -vvv --feature-powerset --depth 2 --optional-deps --exclude-features serde,critical-section
args: -vvv --feature-powerset --depth 2 --optional-deps --exclude-features serde,critical-section,__do_not_enable
tidy:
uses: taiki-e/workflows/.github/workflows/tidy.yml@main
with:
Expand Down Expand Up @@ -299,7 +303,7 @@ jobs:
- run: tools/build.sh ${{ matrix.target || 'host' }}
- run: TESTS=1 tools/build.sh ${{ matrix.target || 'host' }}

- run: cargo minimal-versions build -vvv --workspace --all-features --ignore-private $TARGET $BUILD_STD
- run: cargo minimal-versions build -vvv --workspace --features $TEST_FEATURES --ignore-unknown-features --ignore-private $TARGET $BUILD_STD
if: matrix.rust != '1.54'

build:
Expand Down
9 changes: 8 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ Portable atomic types including support for 128-bit atomics, atomic float, etc.
"""

[package.metadata.docs.rs]
features = ["float", "std", "serde"]
# NB: sync with:
# - env.TEST_FEATURES in .github/workflows/ci.yml.
# - test_features list in tools/build.sh and tools/test.sh.
features = ["float", "std", "serde", "critical-section"]
rustdoc-args = ["--cfg", "docsrs"]
targets = ["x86_64-unknown-linux-gnu"]

Expand Down Expand Up @@ -50,6 +53,10 @@ std = []
# See documentation for more: https://github.com/taiki-e/portable-atomic#optional-features-require-cas
require-cas = []

# DO NOT USE. This is NOT public API. Only used for testing our test infrastructures.
# TODO: remove when adding real non-additive features.
__do_not_enable = []

# Note: serde and critical-section are public dependencies.
[dependencies]
# Implements serde::{Serialize,Deserialize} for atomic types.
Expand Down
6 changes: 6 additions & 0 deletions portable-atomic-util/.external-types.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# cargo-check-external-types configuration
# https://crates.io/crates/cargo-check-external-types

# The following are external types that are allowed to be exposed in our public API.
allowed_external_types = [
]
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,9 @@ compile_error!(
"you may not enable feature `critical-section` and cfg(portable_atomic_unsafe_assume_single_core) at the same time"
);

#[cfg(feature = "__do_not_enable")]
compile_error!("Do NOT use `__do_not_enable` feature. This is NOT public API. Only used for testing our test infrastructures.");

#[cfg(feature = "require-cas")]
#[cfg_attr(
portable_atomic_no_cfg_target_has_atomic,
Expand Down
10 changes: 9 additions & 1 deletion tools/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ known_cfgs=(
rustfmt
valgrind
)
# NB: sync with:
# - docs.rs metadata in Cargo.toml
# - env.TEST_FEATURES in .github/workflows/ci.yml.
# - test_features list in tools/test.sh.
test_features="float,std,serde,critical-section"
exclude_features="__do_not_enable"

x() {
local cmd="$1"
Expand Down Expand Up @@ -381,7 +387,8 @@ build() {
return 0
fi
args+=(
--all-features --tests
--tests
--features "${test_features}"
--workspace --exclude bench --exclude portable-atomic-internal-codegen
)
elif [[ -n "${TARGET_GROUP:-}" ]]; then
Expand Down Expand Up @@ -451,6 +458,7 @@ build() {

args+=(
--feature-powerset --depth 2 --optional-deps --no-dev-deps
${exclude_features+"--exclude-features=${exclude_features}"}
--workspace --ignore-private
)
# critical-section requires 1.54
Expand Down
8 changes: 7 additions & 1 deletion tools/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ trap -- 'echo >&2 "$0: trapped SIGINT"; exit 1' SIGINT
# ./tools/test.sh [+toolchain] [cargo_options]...
# ./tools/test.sh [+toolchain] build|miri|valgrind [cargo_options]...

# NB: sync with:
# - docs.rs metadata in Cargo.toml
# - env.TEST_FEATURES in .github/workflows/ci.yml.
# - test_features list in tools/build.sh.
test_features="float,std,serde,critical-section"

x() {
local cmd="$1"
shift
Expand Down Expand Up @@ -136,7 +142,7 @@ if [[ -n "${target}" ]]; then
fi
fi
fi
args+=(--all-features)
args+=(--features "${test_features}")
case "${cmd}" in
build) ;;
*) args+=(--workspace --exclude bench --exclude portable-atomic-internal-codegen) ;;
Expand Down

0 comments on commit 8fcbe7c

Please sign in to comment.