forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaffects-files.sh
executable file
·33 lines (29 loc) · 940 Bytes
/
affects-files.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
#
# Checks if a CI build affects one or more path patterns. Each command-line
# argument is checked in series.
#
# Bash regular expressions are permitted in the pattern:
# ./affects-files.sh .rs$ -- any file or directory ending in .rs
# ./affects-files.sh .rs -- also matches foo.rs.bar
# ./affects-files.sh ^snap/ -- anything under the snap/ subdirectory
# ./affects-files.sh snap/ -- also matches foo/snap/
#
set -e
cd "$(dirname "$0")"/..
if ci/is-pr.sh; then
affectedFiles="$(buildkite-agent meta-data get affected_files)"
echo "Affected files in this PR: $affectedFiles"
IFS=':' read -ra files <<< "$affectedFiles"
for pattern in "$@"; do
for file in "${files[@]}"; do
if [[ $file =~ $pattern ]]; then
exit 0
fi
done
done
exit 1
fi
# affected_files metadata is not currently available for non-PR builds, so assume
# the worse (affected)
exit 0