Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit adcd6a5

Browse files
authored
Adding rebase patches step to update-automation workflow (#36)
1 parent 56b09a4 commit adcd6a5

File tree

10 files changed

+306
-14
lines changed

10 files changed

+306
-14
lines changed

‎.github/workflows/build-targets.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ jobs:
1313
environment: build-targets-workflow-env
1414
strategy:
1515
matrix:
16-
build-target: [code-editor-server, code-editor-sagemaker-server, code-editor-web-embedded]
16+
build-target: [code-editor-server, code-editor-sagemaker-server, code-editor-web-embedded, code-editor-web-embedded-with-terminal]
1717
exclude:
1818
# Only build SageMaker for now, remove the excluded targets when needed in the future.
1919
- build-target: code-editor-server
2020
- build-target: code-editor-web-embedded
21+
- build-target: code-editor-web-embedded-with-terminal
2122
steps:
2223
- name: Start Build Workflow
2324
run: |
@@ -36,7 +37,7 @@ jobs:
3637

3738
- name: Run patches script
3839
run: |
39-
./scripts/prepare-src.sh
40+
./scripts/prepare-src.sh ${{ matrix.build-target }}
4041
4142
- name: Set up Node.js
4243
uses: actions/setup-node@v4

‎.github/workflows/update-automation.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ jobs:
1212
permissions:
1313
contents: write
1414
steps:
15+
- name: Setup environment
16+
run: |
17+
echo "Installing required dependencies"
18+
sudo apt-get update
19+
sudo apt-get install -y quilt libxml2-utils jq
20+
1521
- name: Checkout code
1622
uses: actions/checkout@v4
1723
with:
@@ -88,5 +94,48 @@ jobs:
8894
8995
echo "Created staging branch: $STAGING_BRANCH with VS Code $LATEST_TAG"
9096
fi
97+
98+
- name: Rebase patches for all targets
99+
run: |
100+
echo "Rebasing patches for all build targets"
101+
102+
# Test each target sequentially with rebasing
103+
FAILED_TARGETS=()
104+
105+
for target in code-editor-server code-editor-sagemaker-server code-editor-web-embedded code-editor-web-embedded-with-terminal; do
106+
echo ""
107+
echo "=== REBASING TARGET: $target ==="
108+
109+
if ./scripts/prepare-src.sh --command rebase_patches "$target"; then
110+
echo "Successfully rebased $target"
111+
else
112+
echo "Failed to rebase $target"
113+
FAILED_TARGETS+=("$target")
114+
fi
115+
116+
# Clean up for next target
117+
rm -rf code-editor-src
118+
119+
echo "=== END TARGET: $target ==="
120+
done
121+
122+
# Report results
123+
if [ ${#FAILED_TARGETS[@]} -gt 0 ]; then
124+
echo "Failed targets: ${FAILED_TARGETS[*]}"
125+
exit 1
126+
else
127+
echo "All targets rebased successfully"
128+
fi
129+
130+
handle-failures:
131+
name: Handle Failures
132+
runs-on: ubuntu-latest
133+
needs: update-automation
134+
if: failure()
135+
steps:
136+
- name: Report rebase failures
137+
run: |
138+
# TODO: Implement metric reporting to CW.
139+
exit 1
91140
92141
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": 1,
3+
"patches": {
4+
"path": "patches/sagemaker.series"
5+
},
6+
"overrides": {
7+
"path": "overrides"
8+
},
9+
"package-lock-overrides": {
10+
"path": "package-lock-overrides/sagemaker.series"
11+
},
12+
"target": "code-editor-sagemaker-server",
13+
"ignoredErrors": {
14+
"path": "ignored-errors"
15+
}
16+
}

‎configuration/code-editor-server.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": 1,
3+
"patches": {
4+
"path": "patches/web-server.series"
5+
},
6+
"overrides": {
7+
"path": "overrides"
8+
},
9+
"package-lock-overrides": {
10+
"path": "package-lock-overrides/web-server.series"
11+
},
12+
"target": "code-editor-server",
13+
"ignoredErrors": {
14+
"path": "ignored-errors"
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": 1,
3+
"patches": {
4+
"path": "patches/web-embedded-with-terminal.series"
5+
},
6+
"overrides": {
7+
"path": "overrides"
8+
},
9+
"package-lock-overrides": {
10+
"path": "package-lock-overrides/web-embedded-with-terminal.series"
11+
},
12+
"target": "code-editor-web-embedded-with-terminal",
13+
"ignoredErrors": {
14+
"path": "ignored-errors"
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": 1,
3+
"patches": {
4+
"path": "patches/web-embedded.series"
5+
},
6+
"overrides": {
7+
"path": "overrides"
8+
},
9+
"package-lock-overrides": {
10+
"path": "package-lock-overrides/web-embedded.series"
11+
},
12+
"target": "code-editor-web-embedded",
13+
"ignoredErrors": {
14+
"path": "ignored-errors"
15+
}
16+
}

‎package-lock-overrides/web-embedded-with-terminal.series/.gitkeep

Whitespace-only changes.

‎package-lock-overrides/web-embedded.series/.gitkeep

Whitespace-only changes.

‎package-lock-overrides/web-server.series/.gitkeep

Whitespace-only changes.

‎scripts/prepare-src.sh

Lines changed: 190 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
set -euo pipefail
44

55
PRESENT_WORKING_DIR="$(pwd)"
6-
PATCHED_SRC_DIR="$PRESENT_WORKING_DIR/code-editor-src"
76
# Manually update this list to include all files for which there are modified script-src CSP rules
87
UPDATE_CHECKSUM_FILEPATHS=(
98
"/src/vs/workbench/contrib/webview/browser/pre/index.html"
@@ -70,33 +69,99 @@ calc_script_SHAs() {
7069
return 0
7170
}
7271

73-
apply_changes() {
74-
echo "Creating patched source in directory: ${PATCHED_SRC_DIR}"
72+
check_unsaved_changes() {
73+
local patches_path=$(jq -r '.patches.path' "$CONFIG_FILE")
74+
75+
if [[ "$patches_path" == "null" || -z "$patches_path" ]]; then
76+
return
77+
fi
78+
79+
if [[ ! -d "${PATCHED_SRC_DIR}" ]]; then
80+
return
81+
fi
82+
83+
export QUILT_PATCHES="${PRESENT_WORKING_DIR}/patches"
84+
export QUILT_SERIES="${PRESENT_WORKING_DIR}/$patches_path"
85+
86+
pushd "${PATCHED_SRC_DIR}"
87+
88+
# Check if there are applied patches
89+
local applied_output
90+
applied_output=$(quilt applied 2>/dev/null || true)
91+
92+
if [[ -z "$applied_output" ]]; then
93+
popd
94+
return
95+
fi
96+
97+
# Check for unsaved changes with diff
98+
local diff_output
99+
diff_output=$(quilt diff -z 2>/dev/null || true)
75100

101+
if [[ -n "$diff_output" ]]; then
102+
popd
103+
echo "Error: You have unsaved changes in the current patch."
104+
echo "Run 'quilt refresh' to update the patch with your changes."
105+
echo "Please refresh or revert your changes before rebasing again"
106+
exit 1
107+
fi
108+
109+
popd
110+
}
111+
112+
setup_quilt_environment() {
113+
local patches_path=$(jq -r '.patches.path' "$CONFIG_FILE")
114+
76115
patch_dir="${PRESENT_WORKING_DIR}/patches"
77116
echo "Set patch directory as: $patch_dir"
78117

79118
export QUILT_PATCHES="${patch_dir}"
80-
export QUILT_SERIES="${PRESENT_WORKING_DIR}/patches/sagemaker.series"
119+
export QUILT_SERIES="${PRESENT_WORKING_DIR}/$patches_path"
120+
echo "Using series file: $QUILT_SERIES"
121+
}
81122

82-
# Clean out the build directory
123+
prepare_patch_directory() {
83124
echo "Cleaning build src dir"
84125
rm -rf "${PATCHED_SRC_DIR}"
85-
86-
# Copy third party source
126+
87127
echo "Copying third party source to the patch directory"
88128
rsync -a "${PRESENT_WORKING_DIR}/third-party-src/" "${PATCHED_SRC_DIR}"
129+
}
89130

90-
echo "Applying base patches"
131+
apply_patches() {
132+
echo "Applying patches"
91133
pushd "${PATCHED_SRC_DIR}"
92134
quilt push -a
93135
popd
136+
}
137+
138+
prepare_src() {
139+
echo "Creating patched source in directory: ${PATCHED_SRC_DIR}"
140+
setup_quilt_environment
141+
prepare_patch_directory
142+
apply_patches
143+
apply_overrides
144+
}
94145

146+
rebase_patches() {
147+
echo "Creating patched source in directory: ${PATCHED_SRC_DIR}"
148+
setup_quilt_environment
149+
check_unsaved_changes
150+
prepare_patch_directory
151+
rebase
152+
apply_overrides
153+
}
154+
155+
apply_overrides() {
156+
# Read configuration from JSON file
157+
local overrides_path=$(jq -r '.overrides.path' "$CONFIG_FILE")
158+
local package_lock_path=$(jq -r '."package-lock-overrides".path' "$CONFIG_FILE")
159+
95160
echo "Applying overrides"
96-
rsync -a "${PRESENT_WORKING_DIR}/overrides/" "${PATCHED_SRC_DIR}"
161+
rsync -a "${PRESENT_WORKING_DIR}/$overrides_path/" "${PATCHED_SRC_DIR}"
97162

98163
echo "Applying package-lock overrides"
99-
rsync -a "${PRESENT_WORKING_DIR}/package-lock-overrides/sagemaker.series/" "${PATCHED_SRC_DIR}"
164+
rsync -a "${PRESENT_WORKING_DIR}/$package_lock_path/" "${PATCHED_SRC_DIR}"
100165
}
101166

102167
update_inline_sha() {
@@ -121,5 +186,118 @@ update_inline_sha() {
121186
done
122187
}
123188

124-
apply_changes
125-
update_inline_sha
189+
parse_conflict_files() {
190+
printf '%s\n' "1ドル" | grep -A1 "^patching file" | grep -B1 "NOT MERGED" | grep "^patching file" | sed 's/^patching file //'
191+
}
192+
193+
parse_missing_files() {
194+
printf '%s\n' "1ドル" | grep -A5 "can't find file to patch" | grep "^|Index:" | sed 's/^|Index: //' | sort -u
195+
}
196+
197+
rebase() {
198+
echo "Rebasing patches one by one..."
199+
pushd "${PATCHED_SRC_DIR}"
200+
201+
# Apply patches one by one with force
202+
while quilt next >/dev/null 2>&1; do
203+
204+
local output
205+
set +e # Disable exit on error
206+
output=$(quilt push -f -m 2>&1)
207+
local exit_code=$?
208+
set -e # Re-enable exit on error
209+
210+
echo "$output"
211+
212+
# Parse conflicts and missing files
213+
local conflict_files
214+
local missing_files
215+
conflict_files=($(parse_conflict_files "$output" || true))
216+
missing_files=($(parse_missing_files "$output" || true))
217+
218+
if [[ $exit_code -eq 0 ]]; then
219+
echo "Successfully applied patch: $(quilt top)"
220+
221+
else
222+
223+
if [[ ${#conflict_files[@]} -gt 0 ]]; then
224+
echo ""
225+
echo "Files with conflicts:"
226+
for file in "${conflict_files[@]}"; do
227+
echo "- $file"
228+
done
229+
fi
230+
231+
if [[ ${#missing_files[@]} -gt 0 ]]; then
232+
echo ""
233+
echo "Missing files:"
234+
for file in "${missing_files[@]}"; do
235+
echo "- $file"
236+
done
237+
fi
238+
239+
echo ""
240+
echo "Required actions:"
241+
echo "1. Edit the files to resolve any conflicts"
242+
echo "2. Run 'quilt refresh' to update the patch"
243+
echo "3. Then run the prepare-src script again to continue"
244+
echo ""
245+
popd
246+
exit 1
247+
fi
248+
249+
done
250+
251+
echo "All patches applied successfully"
252+
popd
253+
}
254+
255+
# Parse command line arguments
256+
COMMAND="prepare_src"
257+
TARGET="code-editor-sagemaker-server"
258+
259+
case "${1:-}" in
260+
--command)
261+
[[ $# -ge 2 ]] || { echo "--command requires a value" >&2; exit 1; }
262+
COMMAND="2ドル"
263+
TARGET="${3:-$TARGET}"
264+
;;
265+
-*)
266+
echo "Unknown option 1ドル" >&2
267+
exit 1
268+
;;
269+
"")
270+
# No arguments, use defaults
271+
;;
272+
*)
273+
TARGET="1ドル"
274+
;;
275+
esac
276+
277+
PATCHED_SRC_DIR="$PRESENT_WORKING_DIR/code-editor-src"
278+
CONFIG_FILE="$PRESENT_WORKING_DIR/configuration/$TARGET.json"
279+
280+
# Check if config file exists
281+
if [[ ! -f "$CONFIG_FILE" ]]; then
282+
echo "Error: Configuration file not found: $CONFIG_FILE" >&2
283+
exit 1
284+
fi
285+
286+
echo "Using configuration: $CONFIG_FILE"
287+
echo "Preparing source for target: $TARGET"
288+
case "$COMMAND" in
289+
prepare_src)
290+
prepare_src
291+
update_inline_sha
292+
;;
293+
rebase_patches)
294+
echo "Rebase mode enabled"
295+
rebase_patches
296+
;;
297+
*)
298+
echo "Unknown command: $COMMAND" >&2
299+
echo "Available commands: prepare_src, rebase_patches" >&2
300+
exit 1
301+
;;
302+
esac
303+
echo "Successfully prepared source for target: $TARGET"

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /