Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
ci: dynamically fetch features for crates (#5551)
Prajjwal Kumar9dda292ca2b3
diff --git a/scripts/ci-checks-v2.sh b/scripts/ci-checks-v2.shindex cbdae11402..bebfce27e7 100755--- a/scripts/ci-checks-v2.sh+++ b/scripts/ci-checks-v2.sh@@ -1,4 +1,4 @@-#! /usr/bin/env bash+#!/usr/bin/env bashset -euo pipefailcrates_to_check=\@@ -15,6 +15,12 @@ packages_skipped=()# List of cargo commands that will be executedall_commands=()+# Function to get defined features for a crate+features_to_run() {+ local crate_name=$1+ cargo metadata --format-version 1 --no-deps | jq --raw-output --arg crate_name "${crate_name}" --arg v2_features "${v2_feature_set}" '[ .packages[] | select(.name == $crate_name) | .features | keys[] | select( IN( .; ( $v2_features | split(",") )[] ) ) ] | join(",")'+}+# If we are running this on a pull request, then only check for packages that are modifiedif [[ "${GITHUB_EVENT_NAME:-}" == 'pull_request' ]]; then# Obtain the pull request number and files modified in the pull request@@ -34,7 +40,8 @@ if [[ "${GITHUB_EVENT_NAME:-}" == 'pull_request' ]]; thenif [[ "${package_name}" == "storage_impl" ]]; thenall_commands+=("cargo hack clippy --features 'v2,payment_v2,customer_v2' -p storage_impl")else- all_commands+=("cargo hack clippy --feature-powerset --depth 2 --ignore-unknown-features --at-least-one-of 'v2 ' --include-features '${v2_feature_set}' --package '${package_name}'")+ valid_features="$(features_to_run "$package_name")"+ all_commands+=("cargo hack clippy --feature-powerset --depth 2 --ignore-unknown-features --at-least-one-of 'v2 ' --include-features '${valid_features}' --package '${package_name}'")fiprintf '::debug::Checking `%s` since it was modified %s\n' "${package_name}"packages_checked+=("${package_name}")@@ -47,20 +54,19 @@ if [[ "${GITHUB_EVENT_NAME:-}" == 'pull_request' ]]; thenelse# If we are doing this locally or on merge queue, then check for all the V2 crates- all_commands+=("cargo hack clippy --features 'v2,payment_v2,customer_v2' -p storage_impl")-- common_command="cargo hack clippy --feature-powerset --depth 2 --ignore-unknown-features --at-least-one-of 'v2 ' --include-features '${v2_feature_set}'"- crates_to_include=""+ all_commands+=("cargo hack clippy --features 'v2,payment_v2' -p storage_impl")+ common_command="cargo hack clippy --feature-powerset --depth 2 --ignore-unknown-features --at-least-one-of 'v2 '"while IFS= read -r crate; doif [[ "${crate}" != "storage_impl" ]]; then- crates_to_include+="--package '${crate}' "+ valid_features="$(features_to_run "$crate")"+ crate_with_features="--include-features '${valid_features}' --package '${crate}' "+ all_commands+=("${common_command} ${crate_with_features}")fidone <<< "${crates_to_check}"- all_commands+=("${common_command} ${crates_to_include}")fiif ((${#all_commands[@]} == 0)); then- echo "There are no commands to be be executed"+ echo "There are no commands to be executed"exit 0fidiff --git a/scripts/ci-checks.sh b/scripts/ci-checks.shindex 5a37d2f262..d51ba09da6 100755--- a/scripts/ci-checks.sh+++ b/scripts/ci-checks.sh@@ -101,7 +101,7 @@ while IFS= read -r crate && [[ -n "${crate}" ]]; dodone <<< "${crates_without_v1_feature}"if ((${#all_commands[@]} == 0)); then- echo "There are no commands to be be executed"+ echo "There are no commands to be executed"exit 0fi