Skip to content

Commit

Permalink
chore: use cargo-hack instead of manually listing each feature
Browse files Browse the repository at this point in the history
It is hard to maintain features list manually, so use cargo-hack's
`--each-feature` flag. And cargo-hack provides a workaround for an issue
that dev-dependencies leaking into normal build (`--no-dev-deps` flag),
so removed own ci tool.

Also, compared to running tests on all features, there is not much
advantage in running tests on each feature, so only the default features
and all features are tested.
If the behavior changes depending on the feature, we need to test it as
another job in CI.
  • Loading branch information
taiki-e committed Oct 30, 2019
1 parent d625c15 commit 6bee4d8
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 89 deletions.
25 changes: 6 additions & 19 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,8 @@ jobs:
displayName: Test tokio
cross: true
crates:
tokio:
- fs
- io
- io-traits
- io-util
- net-driver
- process
- rt-full
- signal
- sync
- tcp
- timer
- udp
- uds
tests-integration: []
- tokio
- tests-integration

# Test crates that are NOT platform specific
- template: ci/azure-test-stable.yml
Expand All @@ -48,10 +35,10 @@ jobs:
displayName: Test sub crates -
rust: beta
crates:
tokio-macros: []
tokio-test: []
tokio-util: []
examples: []
- tokio-macros
- tokio-test
- tokio-util
- examples

# Test compilation failure
# Disable pending: https://github.com/tokio-rs/tokio/pull/1695#issuecomment-547045383
Expand Down
77 changes: 43 additions & 34 deletions ci/azure-test-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ jobs:
# rust_version: stable
rust_version: ${{ parameters.rust }}

- script: |
git clone https://github.com/taiki-e/cargo-hack
cargo install cargo-hack --path cargo-hack
rm -rf cargo-hack
displayName: Install cargo-hack
- template: azure-is-release.yml

- ${{ each crate in parameters.crates }}:
Expand All @@ -28,17 +34,26 @@ jobs:
env:
LOOM_MAX_PREEMPTIONS: 2
CI: 'True'
displayName: ${{ crate.key }} - cargo test
workingDirectory: $(Build.SourcesDirectory)/${{ crate.key }}
displayName: ${{ crate }} - cargo test
workingDirectory: $(Build.SourcesDirectory)/${{ crate }}

# Run with all crate features
- script: cargo test --all-features
env:
LOOM_MAX_PREEMPTIONS: 2
CI: 'True'
displayName: ${{ crate }} - cargo test --features ${{ feature }}
workingDirectory: $(Build.SourcesDirectory)/${{ crate }}

# Run with each specified feature
- ${{ each feature in crate.value }}:
- script: cargo test --no-default-features --features ${{ feature }}
env:
LOOM_MAX_PREEMPTIONS: 2
CI: 'True'
displayName: ${{ crate.key }} - cargo test --features ${{ feature }}
workingDirectory: $(Build.SourcesDirectory)/${{ crate.key }}
# Check each specified feature works properly
# * --each-feature - run for each feature which includes --no-default-features and default features of package
# * --no-dev-deps - build without dev-dependencies to avoid https://github.com/rust-lang/cargo/issues/4866
- script: cargo hack check --each-feature --no-dev-deps
env:
LOOM_MAX_PREEMPTIONS: 2
CI: 'True'
displayName: ${{ crate }} - cargo hack check --each-feature
workingDirectory: $(Build.SourcesDirectory)/${{ crate }}

- template: azure-patch-crates.yml

Expand All @@ -48,29 +63,23 @@ jobs:
env:
LOOM_MAX_PREEMPTIONS: 2
CI: 'True'
displayName: ${{ crate.key }} - cargo test
workingDirectory: $(Build.SourcesDirectory)/${{ crate.key }}
displayName: ${{ crate }} - cargo test
workingDirectory: $(Build.SourcesDirectory)/${{ crate }}

# Run with each specified feature
- ${{ each feature in crate.value }}:
- script: cargo test --no-default-features --features ${{ feature }}
env:
LOOM_MAX_PREEMPTIONS: 2
CI: 'True'
displayName: ${{ crate.key }} - cargo test --features ${{ feature }}
workingDirectory: $(Build.SourcesDirectory)/${{ crate.key }}

# Remove all dev-dependencies to avoid https://github.com/rust-lang/cargo/issues/4866.
- bash: cargo run --manifest-path ci/remove-dev-dependencies/Cargo.toml ./*/Cargo.toml
displayName: Remove dev-dependencies
# Run with all crate features
- script: cargo test --all-features
env:
LOOM_MAX_PREEMPTIONS: 2
CI: 'True'
displayName: ${{ crate }} - cargo test --all-features
workingDirectory: $(Build.SourcesDirectory)/${{ crate }}

# Check each specified feature works properly
- ${{ each crate in parameters.crates }}:
# Run with each specified feature
- ${{ each feature in crate.value }}:
- script: cargo check --no-default-features --features ${{ feature }}
env:
LOOM_MAX_PREEMPTIONS: 2
CI: 'True'
displayName: ${{ crate.key }} - cargo check --features ${{ feature }}
workingDirectory: $(Build.SourcesDirectory)/${{ crate.key }}
# Check each specified feature works properly
# * --each-feature - run for each feature which includes --no-default-features and default features of package
# * --no-dev-deps - build without dev-dependencies to avoid https://github.com/rust-lang/cargo/issues/4866
- script: cargo hack check --each-feature --no-dev-deps
env:
LOOM_MAX_PREEMPTIONS: 2
CI: 'True'
displayName: ${{ crate }} - cargo hack check --each-feature
workingDirectory: $(Build.SourcesDirectory)/${{ crate }}
11 changes: 0 additions & 11 deletions ci/remove-dev-dependencies/Cargo.toml

This file was deleted.

25 changes: 0 additions & 25 deletions ci/remove-dev-dependencies/src/main.rs

This file was deleted.

0 comments on commit 6bee4d8

Please sign in to comment.