Skip to content

Commit 23c83cc

Browse files
committed
Improve script paths and add constants for job types in should-skip-job.sh
1 parent 834ada0 commit 23c83cc

7 files changed

+16
-11
lines changed

.buildkite/commands/diff-merged-manifest.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash -eu
22

3-
if .buildkite/commands/should-skip-job.sh --job-type validation; then
3+
if "$(dirname "${BASH_SOURCE[0]}")/should-skip-job.sh" --job-type validation; then
44
exit 0
55
fi
66

.buildkite/commands/gradle-cache-build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash -eu
22

3-
if .buildkite/commands/should-skip-job.sh --job-type build; then
3+
if "$(dirname "${BASH_SOURCE[0]}")/should-skip-job.sh" --job-type build; then
44
exit 0
55
fi
66

.buildkite/commands/lint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash -eu
22

3-
if .buildkite/commands/should-skip-job.sh --job-type lint; then
3+
if "$(dirname "${BASH_SOURCE[0]}")/should-skip-job.sh" --job-type lint; then
44
exit 0
55
fi
66

.buildkite/commands/prototype-build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash -eu
22

3-
if .buildkite/commands/should-skip-job.sh --job-type build; then
3+
if "$(dirname "${BASH_SOURCE[0]}")/should-skip-job.sh" --job-type build; then
44
exit 0
55
fi
66

.buildkite/commands/run-instrumented-tests.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash -eu
22

3-
if .buildkite/commands/should-skip-job.sh --job-type validation; then
3+
if "$(dirname "${BASH_SOURCE[0]}")/should-skip-job.sh" --job-type validation; then
44
mkdir -p buildkite-test-analytics && touch buildkite-test-analytics/empty.xml
55
exit 0
66
fi

.buildkite/commands/run-unit-tests.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash -eu
22

3-
if .buildkite/commands/should-skip-job.sh --job-type validation; then
3+
if "$(dirname "${BASH_SOURCE[0]}")/should-skip-job.sh" --job-type validation; then
44
mkdir -p buildkite-test-analytics && touch buildkite-test-analytics/empty.xml
55
exit 0
66
fi

.buildkite/commands/should-skip-job.sh

+10-5
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,22 @@ COMMON_PATTERNS=(
2828
"version.properties"
2929
)
3030

31+
# Define constants for job types
32+
VALIDATION="validation"
33+
BUILD="build"
34+
LINT="lint"
35+
3136
# Check if arguments are valid
3237
if [ -z "${1:-}" ] || [ "$1" != "--job-type" ] || [ -z "${2:-}" ]; then
33-
echo "Error: Must specify --job-type [validation|build|lint]"
38+
echo "Error: Must specify --job-type [$VALIDATION|$BUILD|$LINT]"
3439
buildkite-agent step cancel
3540
exit 15
3641
fi
3742

3843
# Function to display skip message and create annotation
3944
show_skip_message() {
4045
local job_type=$1
41-
local message="Skipping ${BUILDKITE_LABEL:-Job} - no relevant files changed"
46+
local message="Skipped ${BUILDKITE_LABEL:-Job} - no relevant files changed"
4247
local context="skip-$(echo "${BUILDKITE_LABEL:-$job_type}" | sed -E -e 's/[^[:alnum:]]+/-/g' | tr A-Z a-z)"
4348

4449
echo "$message" | buildkite-agent annotate --style "info" --context "$context"
@@ -47,7 +52,7 @@ show_skip_message() {
4752

4853
job_type="$2"
4954
case "$job_type" in
50-
"validation")
55+
$VALIDATION)
5156
# We should skip if changes are limited to documentation, tooling, non-code files, and localization files
5257
PATTERNS=("${COMMON_PATTERNS[@]}" "**/strings.xml")
5358
if pr_changed_files --all-match "${PATTERNS[@]}"; then
@@ -56,7 +61,7 @@ case "$job_type" in
5661
fi
5762
exit 1
5863
;;
59-
"build"|"lint")
64+
$BUILD|$LINT)
6065
# We should skip if changes are limited to documentation, tooling, and non-code files
6166
# We'll let the job run (won't skip) if PR includes changes in localization files though
6267
PATTERNS=("${COMMON_PATTERNS[@]}")
@@ -67,7 +72,7 @@ case "$job_type" in
6772
exit 1
6873
;;
6974
*)
70-
echo "Error: Job type must be either 'validation', 'build', or 'lint'"
75+
echo "Error: Job type must be either '$VALIDATION', '$BUILD', or '$LINT'"
7176
buildkite-agent step cancel
7277
exit 15
7378
;;

0 commit comments

Comments
 (0)