Skip to content

Commit

Permalink
use gh cli to get affected files (#29823)
Browse files Browse the repository at this point in the history
use gh client to get affected files
  • Loading branch information
yihau authored Jan 24, 2023
1 parent 631dd57 commit aef1a43
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
8 changes: 7 additions & 1 deletion ci/buildkite-pipeline-in-disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ cd "$(dirname "$0")"/..
output_file=${1:-/dev/stderr}

if [[ -n $CI_PULL_REQUEST ]]; then
IFS=':' read -ra affected_files <<< "$(buildkite-agent meta-data get affected_files)"
# filter pr number from ci branch.
[[ $CI_BRANCH =~ pull/([0-9]+)/head ]]
pr_number=${BASH_REMATCH[1]}
echo "get affected files from PR: $pr_number"

# get affected files
readarray -t affected_files < <(gh pr diff --name-only "$pr_number")
if [[ ${#affected_files[*]} -eq 0 ]]; then
echo "Unable to determine the files affected by this PR"
exit 1
Expand Down
8 changes: 7 additions & 1 deletion ci/buildkite-pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ cd "$(dirname "$0")"/..
output_file=${1:-/dev/stderr}

if [[ -n $CI_PULL_REQUEST ]]; then
IFS=':' read -ra affected_files <<< "$(buildkite-agent meta-data get affected_files)"
# filter pr number from ci branch.
[[ $CI_BRANCH =~ pull/([0-9]+)/head ]]
pr_number=${BASH_REMATCH[1]}
echo "get affected files from PR: $pr_number"

# get affected files
readarray -t affected_files < <(gh pr diff --name-only "$pr_number")
if [[ ${#affected_files[*]} -eq 0 ]]; then
echo "Unable to determine the files affected by this PR"
exit 1
Expand Down
8 changes: 7 additions & 1 deletion ci/buildkite-solana-private.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ cd "$(dirname "$0")"/..
output_file=${1:-/dev/stderr}

if [[ -n $CI_PULL_REQUEST ]]; then
IFS=':' read -ra affected_files <<< "$(buildkite-agent meta-data get affected_files)"
# filter pr number from ci branch.
[[ $CI_BRANCH =~ pull/([0-9]+)/head ]]
pr_number=${BASH_REMATCH[1]}
echo "get affected files from PR: $pr_number"

# get affected files
readarray -t affected_files < <(gh pr diff --name-only "$pr_number")
if [[ ${#affected_files[*]} -eq 0 ]]; then
echo "Unable to determine the files affected by this PR"
exit 1
Expand Down

0 comments on commit aef1a43

Please sign in to comment.