Skip to content

Commit 3de8dad

Browse files
authored
feat: reduce clone/fetch size when building docs PRs (#3094)
do not fetch tags use a treeless clone of the target branch instead of cloning the default branch
1 parent 88d54f3 commit 3de8dad

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

.buildkite/scripts/build_pr.sh

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ if [[ "${GITHUB_PR_BASE_REPO}" != 'docs' ]]; then
4848
echo "Cloning the ${GITHUB_PR_BASE_REPO} PR locally"
4949

5050
git clone --reference /opt/git-mirrors/elastic-$GITHUB_PR_BASE_REPO \
51+
--filter=tree:0 --no-checkout --no-tags --depth 1 -v --branch "$GITHUB_PR_TARGET_BRANCH" \
5152
[email protected]:elastic/$GITHUB_PR_BASE_REPO.git ./product-repo
5253

5354
cd ./product-repo &&
54-
git fetch origin pull/$GITHUB_PR_NUMBER/head:pr_$GITHUB_PR_NUMBER &&
55+
git fetch --no-tags origin pull/$GITHUB_PR_NUMBER/head:pr_$GITHUB_PR_NUMBER &&
5556
git switch pr_$GITHUB_PR_NUMBER
5657

5758
# Some repositories allow the documentation build to exit early if there are no doc-related changes
@@ -61,114 +62,114 @@ if [[ "${GITHUB_PR_BASE_REPO}" != 'docs' ]]; then
6162

6263
# repositories with a docs dir and changelog
6364
"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")
64-
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
65+
git fetch --no-tags --unshallow origin "$GITHUB_PR_TARGET_BRANCH"
6566
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs CHANGELOG.asciidoc)
6667
;;
6768

6869
# repositories with a docs dir
6970
"apm-k8s-attacher" | "cloud" | "cloud-assets" | "cloud-on-k8s" | "ecctl" | "ecs" | "ecs-dotnet" | "ecs-logging" | "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")
70-
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
71+
git fetch --no-tags --unshallow origin "$GITHUB_PR_TARGET_BRANCH"
7172
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs)
7273
;;
7374

7475
# repositories with a docs dir, changelogs dir, and changelog
7576
"apm-server")
76-
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
77+
git fetch --no-tags --unshallow origin "$GITHUB_PR_TARGET_BRANCH"
7778
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs ./changelogs CHANGELOG.asciidoc)
7879
;;
7980

8081
"beats")
81-
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
82+
git fetch --no-tags --unshallow origin "$GITHUB_PR_TARGET_BRANCH"
8283
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)
8384
;;
8485

8586
"clients-team")
86-
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
87+
git fetch --no-tags --unshallow origin "$GITHUB_PR_TARGET_BRANCH"
8788
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs/examples/elastic-cloud)
8889
;;
8990

9091
"curator")
91-
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
92+
git fetch --no-tags --unshallow origin "$GITHUB_PR_TARGET_BRANCH"
9293
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs/asciidoc)
9394
;;
9495

9596
"eland" | "enterprise-search-php" | "enterprise-search-python" | "enterprise-search-ruby")
96-
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
97+
git fetch --no-tags --unshallow origin "$GITHUB_PR_TARGET_BRANCH"
9798
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs/guide)
9899
;;
99100

100101
"elasticsearch")
101-
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
102+
git fetch --no-tags --unshallow origin "$GITHUB_PR_TARGET_BRANCH"
102103
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)
103104
;;
104105

105106
"elasticsearch-hadoop")
106-
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
107+
git fetch --no-tags --unshallow origin "$GITHUB_PR_TARGET_BRANCH"
107108
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs/src/reference/asciidoc)
108109
;;
109110

110111
"elasticsearch-java")
111-
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
112+
git fetch --no-tags --unshallow origin "$GITHUB_PR_TARGET_BRANCH"
112113
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs ./java-client/src/test/java/co/elastic/clients/documentation)
113114
;;
114115

115116
"elasticsearch-net")
116-
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
117+
git fetch --no-tags --unshallow origin "$GITHUB_PR_TARGET_BRANCH"
117118
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs ./tests/Tests/Documentation)
118119
;;
119120

120121
"elasticsearch-py")
121-
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
122+
git fetch --no-tags --unshallow origin "$GITHUB_PR_TARGET_BRANCH"
122123
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs/guide ./docs/examples)
123124
;;
124125

125126
"go-elasticsearch")
126-
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
127+
git fetch --no-tags --unshallow origin "$GITHUB_PR_TARGET_BRANCH"
127128
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./.doc)
128129
;;
129130

130131
"enterprise-search-pubs")
131-
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
132+
git fetch --no-tags --unshallow origin "$GITHUB_PR_TARGET_BRANCH"
132133
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./enterprise-search-docs ./workplace-search-docs ./app-search-docs ./esre-docs ./client-docs/app-search-javascript ./client-docs/app-search-node ./client-docs/workplace-search-node)
133134
;;
134135

135136
"enterprise-search-js")
136-
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
137+
git fetch --no-tags --unshallow origin "$GITHUB_PR_TARGET_BRANCH"
137138
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./packages/enterprise-search/docs)
138139
;;
139140

140141
"esf" | "ingest-docs" | "observability-docs" | "stack-docs" | "x-pack-logstash")
141-
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
142+
git fetch --no-tags --unshallow origin "$GITHUB_PR_TARGET_BRANCH"
142143
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs/en)
143144
;;
144145

145146
"packagespec")
146-
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
147+
git fetch --no-tags --unshallow origin "$GITHUB_PR_TARGET_BRANCH"
147148
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./versions ./spec)
148149
;;
149150

150151
"tech-content")
151-
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
152+
git fetch --no-tags --unshallow origin "$GITHUB_PR_TARGET_BRANCH"
152153
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./welcome-to-elastic)
153154
;;
154155

155156
"terraform-provider-ec")
156-
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
157+
git fetch --no-tags --unshallow origin "$GITHUB_PR_TARGET_BRANCH"
157158
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs-elastic)
158159
;;
159160

160161
"x-pack")
161-
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
162+
git fetch --no-tags --unshallow origin "$GITHUB_PR_TARGET_BRANCH"
162163
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs/public/graph ./docs/public/marvel ./docs/public/reporting ./docs/public/shield ./docs/public/watcher ./docs/en ./docs/kr ./docs/jp)
163164
;;
164165

165166
"x-pack-elasticsearch")
166-
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
167+
git fetch --no-tags --unshallow origin "$GITHUB_PR_TARGET_BRANCH"
167168
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs/en ./docs/kr ./docs/jp ./qa/sql)
168169
;;
169170

170171
"x-pack-kibana")
171-
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
172+
git fetch --no-tags --unshallow origin "$GITHUB_PR_TARGET_BRANCH"
172173
docs_diff=$(git diff --stat "origin/$GITHUB_PR_TARGET_BRANCH"...HEAD -- ./docs/en ./docs/kr ./docs/jp)
173174
;;
174175

0 commit comments

Comments
 (0)