Skip to content

Commit

Permalink
ci: Add utility to generate the feature "powerset" list
Browse files Browse the repository at this point in the history
The list isn't technically a powerset because we limit the "depth".

We're doing this instead of using `cargo hack` because `cargo hack` does
not allow splitting the tasks across different workflow runners via e.g.
a matrix.

This PR also updates the `feature_powerset.yml` workflow to use our
custom powerset script.
  • Loading branch information
spencewenski committed Oct 19, 2024
1 parent 2d8d31f commit 2a9a681
Show file tree
Hide file tree
Showing 16 changed files with 596 additions and 102 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ jobs:
- name: Test
run: just test-examples

test-private:
name: Test private
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: rui314/setup-mold@v1
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@just
- name: Test
run: just test-private

test:
name: Tests
runs-on: ubuntu-latest
Expand Down
112 changes: 76 additions & 36 deletions .github/workflows/feature_powerset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,65 +43,105 @@ jobs:
if: ${{ github.event_name == 'pull_request' && github.event.label.name == 'powerset_check' }}
run: echo "should_run=true" >> "$GITHUB_OUTPUT"

powerset_test:
name: Powerset Tests
generate_powerset:
needs: check_trigger
if: ${{ needs.check_trigger.outputs.should_run1 == 'true' || needs.check_trigger.outputs.should_run2 == 'true' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
outputs:
data: ${{ steps.build_data.outputs.data }}
steps:
- uses: actions/checkout@v4
- uses: rui314/setup-mold@v1
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@cargo-hack
- uses: taiki-e/install-action@nextest
# protoc is needed to build examples that have grpc enabled
- uses: taiki-e/install-action@protoc
- name: Test
run: cargo hack nextest run --no-fail-fast --feature-powerset --depth 3 --skip default --group-features jwt-ietf,jwt --group-features jwt-openid,jwt --group-features open-api,http --group-features email-smtp,email --group-features email-sendgrid,email --clean-per-run --log-group github-actions --exclude-no-default-features --exclude-all-features
- name: Check disk usage
run: df -h
- name: Random seed
id: random_seed
run: |
if [ -n "${{ github.event.number }}" ]; then
echo "seed=-r ${{ github.event.number }}" >> "$GITHUB_OUTPUT"
elif [ -n "${{ github.run_id }}" ]; then
echo "seed=-r ${{ github.run_id }}" >> "$GITHUB_OUTPUT"
else
echo "seed=" >> "$GITHUB_OUTPUT"
fi
- name: Build powerset data
id: build_data
run: |
cd private/powerset_matrix
echo "data=$(cargo run -- -s 40 -f json -c 50 ${{ steps.random_seed.outputs.seed }})" >> "$GITHUB_OUTPUT"
powerset_doc_test:
name: Powerset Doc tests
needs: check_trigger
if: ${{ needs.check_trigger.outputs.should_run1 == 'true' || needs.check_trigger.outputs.should_run2 == 'true' || github.event_name == 'workflow_dispatch' }}
powerset_test:
name: Powerset Tests
needs: generate_powerset
runs-on: ubuntu-latest
strategy:
max-parallel: 10
matrix:
index: ${{ fromJson(needs.generate_powerset.outputs.data).indexes }}
env:
features: ${{ join(fromJson(needs.generate_powerset.outputs.data).powersets[ matrix.index ], ' ') }}
steps:
- uses: actions/checkout@v4
- uses: rui314/setup-mold@v1
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@cargo-hack
# protoc is needed to build examples that have grpc enabled
- uses: taiki-e/install-action@protoc
- name: Doc test
run: cargo hack test --doc --no-fail-fast --feature-powerset --depth 3 --skip default --group-features jwt-ietf,jwt --group-features jwt-openid,jwt --group-features open-api,http --group-features email-smtp,email --group-features email-sendgrid,email --clean-per-run --log-group github-actions --exclude-no-default-features --exclude-all-features
- uses: taiki-e/install-action@nextest
- name: Test
run: |
features=($features)
i=0
for feature_list in "${features[@]}"; do
echo "::group::$i: cargo nextest run --no-fail-fast --features $feature_list"
cargo nextest run --no-fail-fast --features "$feature_list"
echo "::endgroup::"
echo "::group::cargo test --doc --no-fail-fast --features $feature_list"
cargo test --doc --no-fail-fast --features "$feature_list"
cargo clean -p roadster
i=$(expr $i + 1)
echo "::endgroup::"
done
powerset_check:
name: Powerset Check
needs: check_trigger
if: ${{ needs.check_trigger.outputs.should_run1 == 'true' || needs.check_trigger.outputs.should_run2 == 'true' || github.event_name == 'workflow_dispatch' }}
needs: generate_powerset
runs-on: ubuntu-latest
strategy:
max-parallel: 10
matrix:
index: ${{ fromJson(needs.generate_powerset.outputs.data).indexes }}
env:
features: ${{ join(fromJson(needs.generate_powerset.outputs.data).powersets[ matrix.index ], ' ') }}
steps:
- uses: actions/checkout@v4
- uses: rui314/setup-mold@v1
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@cargo-hack
# protoc is needed to build examples that have grpc enabled
- uses: taiki-e/install-action@protoc
- name: Check
run: cargo hack check --feature-powerset --depth 3 --no-dev-deps --skip default --group-features jwt-ietf,jwt --group-features jwt-openid,jwt --group-features open-api,http --group-features email-smtp,email --group-features email-sendgrid,email --clean-per-run --log-group github-actions --exclude-no-default-features --exclude-all-features
run: |
features=($features)
i=0
for feature_list in "${features[@]}"; do
echo "::group::$i: cargo check --no-dev-deps --features $feature_list"
cargo check --no-dev-deps --features "$feature_list"
cargo clean -p roadster
i=$(expr $i + 1)
echo "::endgroup::"
done
powerset_clippy:
name: Powerset Clippy
needs: check_trigger
if: ${{ needs.check_trigger.outputs.should_run1 == 'true' || needs.check_trigger.outputs.should_run2 == 'true' || github.event_name == 'workflow_dispatch' }}
needs: generate_powerset
runs-on: ubuntu-latest
strategy:
max-parallel: 10
matrix:
index: ${{ fromJson(needs.generate_powerset.outputs.data).indexes }}
env:
features: ${{ join(fromJson(needs.generate_powerset.outputs.data).powersets[ matrix.index ], ' ') }}
steps:
- uses: actions/checkout@v4
- uses: rui314/setup-mold@v1
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@cargo-hack
# protoc is needed to build examples that have grpc enabled
- uses: taiki-e/install-action@protoc
- name: Clippy
run: cargo hack clippy --all-targets --feature-powerset --depth 3 --skip default --group-features jwt-ietf,jwt --group-features jwt-openid,jwt --group-features open-api,http --group-features email-smtp,email --group-features email-sendgrid,email --clean-per-run --log-group github-actions --exclude-no-default-features --exclude-all-features -- -D warnings
run: |
features=($features)
i=0
for feature_list in "${features[@]}"; do
echo "::group::$i: cargo clippy --features $feature_list -- -D warnings "
cargo clippy --features "$feature_list" -- -D warnings
cargo clean -p roadster
i=$(expr $i + 1)
echo "::endgroup::"
done
25 changes: 17 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ rstest = { workspace = true, optional = true }
# Others
anyhow = { workspace = true }
serde = { workspace = true }
serde_derive = "1.0.185"
serde_derive = { workspace = true }
serde_json = { workspace = true }
serde_with = { version = "3.0.0", features = ["macros", "chrono_0_4"] }
strum = "0.26.0"
strum_macros = "0.26.0"
itertools = "0.13.0"
serde_json = "1.0.96"
strum = { workspace = true }
strum_macros = { workspace = true }
itertools = { workspace = true }
toml = "0.8.0"
url = { version = "2.5.0", features = ["serde"] }
uuid = { version = "1.1.2", features = ["v4", "serde"] }
Expand All @@ -113,10 +113,10 @@ chrono = { version = "0.4.34", features = ["serde"] }
byte-unit = { version = "5.0.0", features = ["serde"] }
convert_case = "0.6.0"
const_format = "0.2.30"
typed-builder = "0.20.0"
typed-builder = { workspace = true }
num-traits = "0.2.14"
validator = { version = "0.18.0", features = ["derive"] }
thiserror = "1.0.38"
thiserror = { workspace = true }
# Add latest version of `time` to resolve a build error on nightly
# https://github.com/time-rs/time/issues/681
time = "0.3.36"
Expand All @@ -131,7 +131,7 @@ mockall_double = "0.3.1"
rstest = { workspace = true }

[workspace]
members = [".", "examples/*", "book/examples/*"]
members = [".", "examples/*", "book/examples/*", "private/*"]

[workspace.dependencies]
# Tracing
Expand Down Expand Up @@ -179,10 +179,19 @@ tokio = { version = "1.34.0", features = ["full"] }
tokio-util = { version = "0.7.10" }
anyhow = "1.0.86"
serde = { version = "1.0.185", features = ["derive"] }
serde_derive = "1.0.185"
serde_json = "1.0.96"
strum = "0.26.0"
strum_macros = "0.26.0"
cfg-if = "1.0.0"
vergen = { version = "9.0.0" }
vergen-gitcl = { version = "1.0.0" }
reqwest = "0.12.8"
itertools = "0.13.0"
cargo-manifest = "0.15.0"
typed-builder = "0.20.0"
rand = "0.8.5"
thiserror = "1.0.49"

[package.metadata.docs.rs]
# Have docs.rs pass `--all-features` to ensure all features have their documentation built.
Expand Down
Loading

0 comments on commit 2a9a681

Please sign in to comment.