Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add utility to generate the feature "powerset" list #454

Merged
merged 1 commit into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ on:
env:
CARGO_TERM_COLOR: always

# https://stackoverflow.com/a/72408109
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test-examples:
name: Test examples
Expand All @@ -23,6 +28,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
9 changes: 7 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
name: Test coverage

on:
push:
branches: [ main ]
pull_request:
branches:
- main

name: Test coverage
# https://stackoverflow.com/a/72408109
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
coverage:
Expand Down Expand Up @@ -37,4 +42,4 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: lcov.info
files: lcov.info
120 changes: 84 additions & 36 deletions .github/workflows/feature_powerset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ on:
env:
CARGO_TERM_COLOR: always

# https://stackoverflow.com/a/72408109
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
# https://stackoverflow.com/questions/63014786/how-to-schedule-a-github-actions-nightly-build-but-run-it-only-when-there-where
check_trigger:
Expand All @@ -43,65 +48,108 @@ 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)
length=${#features[@]}
i=1
for feature_list in "${features[@]}"; do
echo "::group::[$i/$length]: 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)
length=${#features[@]}
i=1
for feature_list in "${features[@]}"; do
echo "::group::[$i/$length]: cargo check --no-dev-deps --features $feature_list"
cargo check --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)
length=${#features[@]}
i=1
for feature_list in "${features[@]}"; do
echo "::group::[$i/$length]: 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
Loading