Skip to content

Commit 8fcbe7c

Browse files
committed
ci: Prepare for addition of non-additive features
See #94 for the context.
1 parent 2c9e790 commit 8fcbe7c

File tree

6 files changed

+39
-5
lines changed

6 files changed

+39
-5
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ env:
2323
RUSTDOCFLAGS: -D warnings
2424
RUSTFLAGS: -D warnings
2525
RUSTUP_MAX_RETRIES: 10
26+
# NB: sync with:
27+
# - docs.rs metadata in Cargo.toml
28+
# - test_features list in tools/build.sh and tools/test.sh.
29+
TEST_FEATURES: float,std,serde,critical-section
2630

2731
defaults:
2832
run:
@@ -47,7 +51,7 @@ jobs:
4751
with:
4852
event_name: ${{ github.event_name }}
4953
# Exclude serde and critical-section features because the MSRV when it is enabled depends on the MSRV of them
50-
args: -vvv --feature-powerset --depth 2 --optional-deps --exclude-features serde,critical-section
54+
args: -vvv --feature-powerset --depth 2 --optional-deps --exclude-features serde,critical-section,__do_not_enable
5155
tidy:
5256
uses: taiki-e/workflows/.github/workflows/tidy.yml@main
5357
with:
@@ -299,7 +303,7 @@ jobs:
299303
- run: tools/build.sh ${{ matrix.target || 'host' }}
300304
- run: TESTS=1 tools/build.sh ${{ matrix.target || 'host' }}
301305

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

305309
build:

Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ Portable atomic types including support for 128-bit atomics, atomic float, etc.
1313
"""
1414

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

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

56+
# DO NOT USE. This is NOT public API. Only used for testing our test infrastructures.
57+
# TODO: remove when adding real non-additive features.
58+
__do_not_enable = []
59+
5360
# Note: serde and critical-section are public dependencies.
5461
[dependencies]
5562
# Implements serde::{Serialize,Deserialize} for atomic types.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# cargo-check-external-types configuration
2+
# https://crates.io/crates/cargo-check-external-types
3+
4+
# The following are external types that are allowed to be exposed in our public API.
5+
allowed_external_types = [
6+
]

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,9 @@ compile_error!(
419419
"you may not enable feature `critical-section` and cfg(portable_atomic_unsafe_assume_single_core) at the same time"
420420
);
421421

422+
#[cfg(feature = "__do_not_enable")]
423+
compile_error!("Do NOT use `__do_not_enable` feature. This is NOT public API. Only used for testing our test infrastructures.");
424+
422425
#[cfg(feature = "require-cas")]
423426
#[cfg_attr(
424427
portable_atomic_no_cfg_target_has_atomic,

tools/build.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ known_cfgs=(
120120
rustfmt
121121
valgrind
122122
)
123+
# NB: sync with:
124+
# - docs.rs metadata in Cargo.toml
125+
# - env.TEST_FEATURES in .github/workflows/ci.yml.
126+
# - test_features list in tools/test.sh.
127+
test_features="float,std,serde,critical-section"
128+
exclude_features="__do_not_enable"
123129

124130
x() {
125131
local cmd="$1"
@@ -381,7 +387,8 @@ build() {
381387
return 0
382388
fi
383389
args+=(
384-
--all-features --tests
390+
--tests
391+
--features "${test_features}"
385392
--workspace --exclude bench --exclude portable-atomic-internal-codegen
386393
)
387394
elif [[ -n "${TARGET_GROUP:-}" ]]; then
@@ -451,6 +458,7 @@ build() {
451458

452459
args+=(
453460
--feature-powerset --depth 2 --optional-deps --no-dev-deps
461+
${exclude_features+"--exclude-features=${exclude_features}"}
454462
--workspace --ignore-private
455463
)
456464
# critical-section requires 1.54

tools/test.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ trap -- 'echo >&2 "$0: trapped SIGINT"; exit 1' SIGINT
1111
# ./tools/test.sh [+toolchain] [cargo_options]...
1212
# ./tools/test.sh [+toolchain] build|miri|valgrind [cargo_options]...
1313

14+
# NB: sync with:
15+
# - docs.rs metadata in Cargo.toml
16+
# - env.TEST_FEATURES in .github/workflows/ci.yml.
17+
# - test_features list in tools/build.sh.
18+
test_features="float,std,serde,critical-section"
19+
1420
x() {
1521
local cmd="$1"
1622
shift
@@ -136,7 +142,7 @@ if [[ -n "${target}" ]]; then
136142
fi
137143
fi
138144
fi
139-
args+=(--all-features)
145+
args+=(--features "${test_features}")
140146
case "${cmd}" in
141147
build) ;;
142148
*) args+=(--workspace --exclude bench --exclude portable-atomic-internal-codegen) ;;

0 commit comments

Comments
 (0)