-
Notifications
You must be signed in to change notification settings - Fork 425
209 lines (186 loc) · 9.32 KB
/
build-check.yml
File metadata and controls
209 lines (186 loc) · 9.32 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
---
name: Build Check
on:
pull_request:
concurrency:
group: ${{ github.ref }} (Build Extensions)
cancel-in-progress: false
jobs:
build-and-deploy:
name: Build Check
runs-on: ubuntu-latest
environment: Production
steps:
- name: Checkout ${{ github.ref }} ( ${{ github.event.pull_request.head.sha }} )
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 20
- name: Refactor PR commits and check move
run: |
git config --global user.email "gha@apache.org"
git config --global user.name "github-action-test"
# Get the base commit of the PR
BASE_COMMIT=$(git merge-base origin/${{ github.base_ref }} HEAD)
# Run the Python script with the base commit range
python check_move.py $BASE_COMMIT
- name: Run Node.js dead link checker
run: |
node ./scripts/check_move.js `git rev-parse HEAD`
- name: Check exit code
run: |
if [ $? -ne 0 ]; then
echo "Have detected not processed link changes, please fix them."
exit 1
fi
- name: Detect changed doc versions and locales
id: detect
run: |
BASE_SHA=$(git merge-base origin/${{ github.base_ref }} HEAD)
CHANGED_FILES=$(git diff --name-only "$BASE_SHA" HEAD)
echo "=== Changed files ==="
echo "$CHANGED_FILES"
VERSIONS=""
LOCALES="en"
NEED_FULL_BUILD="false"
# Check each changed file and map to doc version
while IFS= read -r file; do
case "$file" in
# English current (dev) docs
docs/*)
VERSIONS="current,$VERSIONS"
;;
# English versioned docs
versioned_docs/version-*/*)
ver=$(echo "$file" | sed -n 's|versioned_docs/version-\([^/]*\)/.*|\1|p')
VERSIONS="${ver},$VERSIONS"
;;
# Chinese current docs
i18n/zh-CN/docusaurus-plugin-content-docs/current/*)
VERSIONS="current,$VERSIONS"
LOCALES="en,zh-CN"
;;
# Chinese versioned docs
i18n/zh-CN/docusaurus-plugin-content-docs/version-*/*)
ver=$(echo "$file" | sed -n 's|i18n/zh-CN/docusaurus-plugin-content-docs/version-\([^/]*\)/.*|\1|p')
VERSIONS="${ver},$VERSIONS"
LOCALES="en,zh-CN"
;;
# Chinese community docs
i18n/zh-CN/docusaurus-plugin-content-docs-community/*|i18n/zh-CN/code.json)
LOCALES="en,zh-CN"
;;
# Sidebar for current (dev) version
sidebars.ts)
VERSIONS="current,$VERSIONS"
;;
# Versioned sidebars: extract version from filename
# e.g. versioned_sidebars/version-4.x-sidebars.json → 4.x
versioned_sidebars/version-*-sidebars.json)
ver=$(echo "$file" | sed -n 's|versioned_sidebars/version-\(.*\)-sidebars\.json|\1|p')
VERSIONS="${ver},$VERSIONS"
;;
# Blog and community are independent plugins, not
# controlled by DOCS_VERSIONS. They are always built
# regardless of version filtering.
blog/*|community/*|releasenotes/*)
NEED_BUILD="true"
;;
# Releases i18n docs
i18n/zh-CN/docusaurus-plugin-content-docs-releases/*)
LOCALES="en,zh-CN"
;;
# Static image assets are copied verbatim to the
# build output and don't affect page rendering, so
# they should NOT trigger a full rebuild on their
# own. Any doc change that references these images
# will trigger its own version-scoped build above.
static/images/*|static/images/**)
;;
# Config, source code, or other structural changes
# require a full build to validate
sidebarsCommunity.json|sidebarsReleases.json|docusaurus.config.js|src/*|static/*|config/*|package.json|yarn.lock|tailwind.config.js)
NEED_FULL_BUILD="true"
;;
esac
done <<< "$CHANGED_FILES"
# Deduplicate versions
if [ "$NEED_FULL_BUILD" = "true" ]; then
# Structural changes: build all active versions
DOCS_VERSIONS=""
echo "Structural changes detected, will build ALL versions."
elif [ -n "$VERSIONS" ]; then
# Only doc content changes: build only affected versions
DOCS_VERSIONS=$(echo "$VERSIONS" | tr ',' '\n' | sort -u | grep -v '^$' | tr '\n' ',' | sed 's/,$//')
echo "Doc-only changes detected for versions: $DOCS_VERSIONS"
else
# No versioned doc changes (e.g., only blog, community, or scripts).
# Blog and community plugins are always compiled by Docusaurus
# regardless of DOCS_VERSIONS, so we just set the minimal docs
# scope to keep the build fast.
DOCS_VERSIONS="current"
echo "No doc version changes detected, doing minimal build with 'current' only."
echo "(Blog and community plugins are always built regardless.)"
fi
# Determine locales for the build command
LOCALE_ARGS=""
IFS=',' read -ra LOCALE_ARR <<< "$LOCALES"
for locale in "${LOCALE_ARR[@]}"; do
LOCALE_ARGS="$LOCALE_ARGS --locale $locale"
done
echo "docs_versions=$DOCS_VERSIONS" >> "$GITHUB_OUTPUT"
echo "locale_args=$LOCALE_ARGS" >> "$GITHUB_OUTPUT"
echo "need_full_build=$NEED_FULL_BUILD" >> "$GITHUB_OUTPUT"
echo ""
echo "=== Build plan ==="
echo " DOCS_VERSIONS: ${DOCS_VERSIONS:-all}"
echo " LOCALE_ARGS: $LOCALE_ARGS"
echo " NEED_FULL_BUILD: $NEED_FULL_BUILD"
- name: Build
env:
DOCS_VERSIONS: ${{ steps.detect.outputs.docs_versions }}
run: |
npm install -g yarn
yarn cache clean
export NODE_OPTIONS=--max-old-space-size=8192
yarn
echo "Building with DOCS_VERSIONS=${DOCS_VERSIONS:-all}"
PWA_SERVICE_WORKER_URL=https://doris.apache.org/sw.js yarn docusaurus build ${{ steps.detect.outputs.locale_args }}
rm -rf build
- name: Docs changed link gate
run: |
yarn docs:links:changed --fail-on-errors --output website-quality-governance/generated/docs-links-report.json
- name: Docs governance report
if: always()
continue-on-error: true
run: |
if [ ! -d node_modules ]; then
npm install -g yarn
yarn --frozen-lockfile || yarn
fi
yarn docs:lint:changed --output website-quality-governance/generated/docs-governance-report.json