Skip to content

Commit 7bd889c

Browse files
Make build_pr script more specific (#3183)
* only run docs pr preview job when an asciidoc file is edited * wrap paths using wildcards in quotes * apply suggestions from code review Co-authored-by: Brandon Morelli <[email protected]> * Update .buildkite/scripts/build_pr.sh Co-authored-by: Brandon Morelli <[email protected]> --------- Co-authored-by: Brandon Morelli <[email protected]>
1 parent 4f4ccdd commit 7bd889c

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

.buildkite/scripts/build_pr.sh

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,25 +62,25 @@ if [[ "${GITHUB_PR_BASE_REPO}" != 'docs' ]]; then
6262
# repositories with a docs dir and changelog
6363
"apm-aws-lambda" | "apm-agent-android" | "apm-agent-nodejs" | "apm-agent-python" | "apm-agent-ruby" | "apm-agent-rum-js" | "apm-agent-go" | "apm-agent-java" | "apm-agent-dotnet" | "apm-agent-php" | "apm-agent-ios")
6464
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
65-
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs CHANGELOG.asciidoc)
65+
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- "./docs/**.asciidoc" CHANGELOG.asciidoc)
6666
;;
6767

68-
# test glob
69-
"ecs-logging")
68+
# repositories with a docs dir that are migrated to docs-builder
69+
"apm-k8s-attacher" | "cloud" | "ecs-logging" | "cloud-on-k8s" | "ecctl" | "ecs" | "ecs-dotnet" | "ecs-logging-go-logrus" | "ecs-logging-go-zap" | "ecs-logging-go-zerolog" | "ecs-logging-java" | "ecs-logging-nodejs" | "ecs-logging-php" | "ecs-logging-python" | "ecs-logging-ruby" | "elasticsearch-js" | "elasticsearch-ruby" | "elasticsearch-php"| "elasticsearch-rs" | "logstash" | "logstash-docs" | "security-docs")
7070
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
71-
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- "**/*.asciidoc")
71+
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- "./docs/**.asciidoc")
7272
;;
7373

74-
# repositories with a docs dir
75-
"apm-k8s-attacher" | "cloud" | "cloud-assets" | "cloud-on-k8s" | "ecctl" | "ecs" | "ecs-dotnet" | "ecs-logging-go-logrus" | "ecs-logging-go-zap" | "ecs-logging-go-zerolog" | "ecs-logging-java" | "ecs-logging-nodejs" | "ecs-logging-php" | "ecs-logging-python" | "ecs-logging-ruby" | "elasticsearch-js" | "elasticsearch-js-legacy" | "elasticsearch-ruby" | "elasticsearch-php" | "elasticsearch-perl" | "elasticsearch-rs" | "kibana-cn" | "logstash" | "logstash-docs" | "security-docs" | "sense" | "swiftype")
74+
# repositories with a docs dir that are not migrated to docs-builder
75+
"cloud-assets" | "elasticsearch-js-legacy" | "elasticsearch-perl" | "kibana-cn" | "sense" | "swiftype")
7676
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
7777
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs)
7878
;;
7979

8080
# repositories with a docs dir, changelogs dir, and changelog
8181
"apm-server")
8282
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
83-
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs ./changelogs CHANGELOG.asciidoc)
83+
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- "./docs/**.asciidoc" "./changelogs/**.asciidoc" CHANGELOG.asciidoc)
8484
;;
8585

8686
"docs-content")
@@ -90,7 +90,7 @@ if [[ "${GITHUB_PR_BASE_REPO}" != 'docs' ]]; then
9090

9191
"beats")
9292
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
93-
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./auditbeat ./CHANGELOG.asciidoc ./docs ./filebeat ./heartbeat ./journalbeat ./libbeat/docs ./libbeat/outputs/*/docs/* ./libbeat/processors/*/docs/* ./metricbeat ./packetbeat ./topbeat/docs ./winlogbeat ./x-pack/auditbeat ./x-pack/dockerlogbeat/docs ./x-pack/filebeat/docs ./x-pack/filebeat/processors/*/docs/* ./x-pack/functionbeat ./x-pack/libbeat/docs ./x-pack/libbeat/processors/*/docs/* ./x-pack/metricbeat/module)
93+
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- "./auditbeat/**.asciidoc" ./**.asciidoc "./docs/**.asciidoc" "./filebeat/**.asciidoc" "./heartbeat/**.asciidoc" "./journalbeat/**.asciidoc" "./libbeat/docs/**.asciidoc" "./libbeat/outputs/*/docs/**.asciidoc" "./libbeat/processors/*/docs/**.asciidoc" "./metricbeat/**/*.asciidoc" "./packetbeat/**.asciidoc" "./topbeat/docs/**.asciidoc" "./winlogbeat/**.asciidoc" "./x-pack/auditbeat/**/*.asciidoc" "./x-pack/dockerlogbeat/docs/**.asciidoc" "./x-pack/filebeat/docs/**.asciidoc" "./x-pack/filebeat/processors/*/docs/**.asciidoc" "./x-pack/functionbeat/**.asciidoc" "./x-pack/libbeat/docs/**.asciidoc" "./x-pack/libbeat/processors/*/docs/**.asciidoc" "./x-pack/metricbeat/module/**.asciidoc")
9494
;;
9595

9696
"clients-team")
@@ -103,14 +103,19 @@ if [[ "${GITHUB_PR_BASE_REPO}" != 'docs' ]]; then
103103
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs/asciidoc)
104104
;;
105105

106-
"eland" | "enterprise-search-php" | "enterprise-search-python" | "enterprise-search-ruby")
106+
"eland")
107+
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
108+
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- "./docs/guide/**.asciidoc")
109+
;;
110+
111+
"enterprise-search-php" | "enterprise-search-python" | "enterprise-search-ruby")
107112
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
108113
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs/guide)
109114
;;
110115

111116
"elasticsearch")
112117
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
113-
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./buildSrc ./build-tools-internal ./build-tools/src/main/resources ./client ./docs ./modules/reindex/src/internalClusterTest/java/org/elasticsearch/client/documentation ./modules/reindex/src/test/java/org/elasticsearch/client/documentation ./plugins/examples ./server/src/internalClusterTest/java/org/elasticsearch/client/documentation ./server/src/main/resources/org/elasticsearch/common ./server/src/test/java/org/elasticsearch/client/documentation ./x-pack/docs ./x-pack/plugin/esql/qa/testFixtures/src/main/resources ./x-pack/plugin/sql/qa ./x-pack/qa/sql)
118+
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./buildSrc ./build-tools-internal ./build-tools/src/main/resources ./client "./docs/**.asciidoc" ./modules/reindex/src/internalClusterTest/java/org/elasticsearch/client/documentation ./modules/reindex/src/test/java/org/elasticsearch/client/documentation ./plugins/examples ./server/src/internalClusterTest/java/org/elasticsearch/client/documentation ./server/src/main/resources/org/elasticsearch/common ./server/src/test/java/org/elasticsearch/client/documentation ./x-pack/docs ./x-pack/plugin/esql/qa/testFixtures/src/main/resources ./x-pack/plugin/sql/qa ./x-pack/qa/sql)
114119
;;
115120

116121
"elasticsearch-hadoop")
@@ -120,22 +125,22 @@ if [[ "${GITHUB_PR_BASE_REPO}" != 'docs' ]]; then
120125

121126
"elasticsearch-java")
122127
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
123-
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs ./java-client/src/test/java/co/elastic/clients/documentation)
128+
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs "./java-client/src/test/java/co/elastic/clients/documentation/**.asciidoc")
124129
;;
125130

126131
"elasticsearch-net")
127132
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
128-
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs ./tests/Tests/Documentation)
133+
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- "./docs/**.asciidoc" ./tests/Tests/Documentation)
129134
;;
130135

131136
"elasticsearch-py")
132137
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
133-
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs/guide ./docs/examples)
138+
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- "./docs/guide/**.asciidoc" ./docs/examples)
134139
;;
135140

136141
"go-elasticsearch")
137142
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
138-
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./.doc)
143+
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- "./.doc/**.asciidoc")
139144
;;
140145

141146
"enterprise-search-pubs")
@@ -148,11 +153,16 @@ if [[ "${GITHUB_PR_BASE_REPO}" != 'docs' ]]; then
148153
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./packages/enterprise-search/docs)
149154
;;
150155

151-
"esf" | "ingest-docs" | "observability-docs" | "stack-docs" | "x-pack-logstash")
156+
"x-pack-logstash")
152157
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
153158
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs/en)
154159
;;
155160

161+
"esf" | "ingest-docs" | "observability-docs" | "stack-docs" | "x-pack-logstash")
162+
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
163+
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- "./docs/en/**.asciidoc")
164+
;;
165+
156166
"observability-robots-playground")
157167
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
158168
echo "This project is only for testing purposes"

0 commit comments

Comments
 (0)