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: obtain files modified from PR instead of git diff (#5436)
Sanchith Hegde2f47491c65fb
diff --git a/.github/workflows/CI-pr.yml b/.github/workflows/CI-pr.ymlindex 4bd50710ce..4c591cba81 100644--- a/.github/workflows/CI-pr.yml+++ b/.github/workflows/CI-pr.yml@@ -101,10 +101,6 @@ jobs:- name: Checkout repositoryuses: actions/checkout@v4- - name: "Fetch base branch"- shell: bash- run: git fetch origin $GITHUB_BASE_REF --depth 1-- name: Install mold linkeruses: rui314/setup-mold@v1if: ${{ runner.os == 'Linux' }}@@ -150,6 +146,8 @@ jobs:- name: Cargo hackshell: bash+ env:+ GH_TOKEN: ${{ github.token }}run: just ci_hack# cargo-deny:@@ -205,10 +203,6 @@ jobs:ref: ${{ github.event.pull_request.head.ref }}token: ${{ steps.generate_token.outputs.token }}- - name: "Fetch base branch"- shell: bash- run: git fetch origin $GITHUB_BASE_REF --depth 1-- name: Install mold linkeruses: rui314/setup-mold@v1if: ${{ runner.os == 'Linux' }}@@ -277,6 +271,8 @@ jobs:- name: Run cargo checkshell: bash+ env:+ GH_TOKEN: ${{ github.token }}run: just ci_hacktypos:diff --git a/scripts/ci-checks.sh b/scripts/ci-checks.shindex 6bc37451a1..5108995572 100755--- a/scripts/ci-checks.sh+++ b/scripts/ci-checks.sh@@ -16,29 +16,37 @@ PACKAGES_CHECKED=()PACKAGES_SKIPPED=()# If we are running this on a pull request, then only check for packages that are modified-if [[ -n "${GITHUB_BASE_REF:-}" ]]; then+if [[ "${GITHUB_EVENT_NAME:-}" == 'pull_request' ]]; then+ # Obtain the pull request number and files modified in the pull request+ pull_request_number="$(jq --raw-output '.pull_request.number' "${GITHUB_EVENT_PATH}")"+ files_modified="$(+ gh api \+ --header 'Accept: application/vnd.github+json' \+ --header 'X-GitHub-Api-Version: 2022-11-28' \+ --paginate \+ "https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${pull_request_number}/files" \+ --jq '.[].filename'+ )"+while IFS= read -r package_name; do- # Obtain comma-separated list of transitive workspace dependencies for each workspace member+ # Obtain pipe-separated list of transitive workspace dependencies for each workspace memberchange_paths="$(cargo tree --all-features --no-dedupe --prefix none --package "${package_name}" \| grep 'crates/' \| sort --unique \- | awk --field-separator ' ' '{ printf "crates/%s\n", $1 }' | paste -d ',' -s -)"-- # Store change paths in an array by splitting `change_paths` by comma- IFS=',' read -ra change_paths <<< "${change_paths}"+ | awk --field-separator ' ' '{ printf "crates/%s\n", $1 }' | paste -d '|' -s -)"# A package must be checked if any of its transitive dependencies (or itself) has been modified- if git diff --exit-code --quiet "origin/${GITHUB_BASE_REF}" -- "${change_paths[@]}"; then- printf '::debug::Skipping `%s` since none of these paths were modified: %s\n' "${package_name}" "${change_paths[*]}"- PACKAGES_SKIPPED+=("${package_name}")- else- printf '::debug::Checking `%s` since at least one of these paths was modified: %s\n' "${package_name}" "${change_paths[*]}"+ if grep --quiet --extended-regexp "^(${change_paths})" <<< "${files_modified}"; then+ printf '::debug::Checking `%s` since at least one of these paths was modified: %s\n' "${package_name}" "${change_paths[*]//|/ }"PACKAGES_CHECKED+=("${package_name}")+ else+ printf '::debug::Skipping `%s` since none of these paths were modified: %s\n' "${package_name}" "${change_paths[*]//|/ }"+ PACKAGES_SKIPPED+=("${package_name}")fidone <<< "${workspace_members}"printf '::notice::Packages checked: %s; Packages skipped: %s\n' "${PACKAGES_CHECKED[*]}" "${PACKAGES_SKIPPED[*]}"- packages_checked=$(printf '%s\n' "${PACKAGES_CHECKED[@]}" | jq -R . | jq -s .)+ packages_checked="$(jq --compact-output --null-input '$ARGS.positional' --args -- "${PACKAGES_CHECKED[@]}")"crates_with_features="$(cargo metadata --format-version 1 --no-deps \| jq \@@ -92,7 +100,7 @@ while IFS= read -r crate && [[ -n "${crate}" ]]; doall_commands+=("$command")done <<< "${crates_without_v1_feature}"-if (( ${#all_commands[@]} == 0 )); then+if ((${#all_commands[@]} == 0)); thenecho "There are no commands to be be executed"exit 0fi