-
Notifications
You must be signed in to change notification settings - Fork 6
Adding rebase patches step to update-automation workflow #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
cd180c4
d94603a
48e4883
73375d5
d5dcd3d
4098da3
a76dfa6
58c9c7c
df1a4f1
20b55c9
9a01387
9421e5f
b1c2cc5
1779fbf
2334c36
020c508
440f8ec
875c701
02a89de
b0883e2
7859328
094a447
d5089f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,12 @@ jobs: | |
permissions: | ||
contents: write | ||
steps: | ||
- name: Setup environment | ||
run: | | ||
echo "Installing required dependencies" | ||
sudo apt-get update | ||
sudo apt-get install -y quilt libxml2-utils jq | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
|
@@ -88,5 +94,48 @@ jobs: | |
|
||
echo "Created staging branch: $STAGING_BRANCH with VS Code $LATEST_TAG" | ||
fi | ||
|
||
- name: Rebase patches for all targets | ||
run: | | ||
echo "Rebasing patches for all build targets" | ||
|
||
# Test each target sequentially with rebasing | ||
FAILED_TARGETS=() | ||
|
||
for target in code-editor-server code-editor-sagemaker-server code-editor-web-embedded code-editor-web-embedded-with-terminal; do | ||
echo "" | ||
echo "=== REBASING TARGET: $target ===" | ||
|
||
if ./scripts/prepare-src.sh --command rebase_patches "$target"; then | ||
echo "Successfully rebased $target" | ||
else | ||
echo "Failed to rebase $target" | ||
FAILED_TARGETS+=("$target") | ||
fi | ||
|
||
# Clean up for next target | ||
rm -rf code-editor-src | ||
|
||
echo "=== END TARGET: $target ===" | ||
done | ||
|
||
# Report results | ||
if [ ${#FAILED_TARGETS[@]} -gt 0 ]; then | ||
echo "Failed targets: ${FAILED_TARGETS[*]}" | ||
exit 1 | ||
else | ||
echo "All targets rebased successfully" | ||
fi | ||
|
||
handle-failures: | ||
name: Handle Failures | ||
runs-on: ubuntu-latest | ||
needs: update-automation | ||
if: failure() | ||
steps: | ||
- name: Report rebase failures | ||
run: | | ||
# TODO: Implement metric reporting to CW. | ||
exit 1 | ||
Comment on lines
+130
to
+139
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like we have created this as a separate job, independent of the previous
If this job runs in parallel with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense! But we will need to publish a failure metric in case any of the step in the |
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will add. |
||
"version": 1, | ||
"patches": { | ||
"path": "patches/sagemaker.series" | ||
}, | ||
"overrides": { | ||
"path": "overrides" | ||
}, | ||
"package-lock-overrides": { | ||
"path": "package-lock-overrides/sagemaker.series" | ||
}, | ||
"target": "code-editor-sagemaker-server", | ||
"ignoredErrors": { | ||
"path": "ignored-errors" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"version": 1, | ||
"patches": { | ||
"path": "patches/web-server.series" | ||
}, | ||
"overrides": { | ||
"path": "overrides" | ||
}, | ||
"package-lock-overrides": { | ||
"path": "package-lock-overrides/web-server.series" | ||
}, | ||
"target": "code-editor-server", | ||
"ignoredErrors": { | ||
"path": "ignored-errors" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"version": 1, | ||
"patches": { | ||
"path": "patches/web-embedded-with-terminal.series" | ||
}, | ||
"overrides": { | ||
"path": "overrides" | ||
}, | ||
"package-lock-overrides": { | ||
"path": "package-lock-overrides/web-embedded-with-terminal.series" | ||
}, | ||
"target": "code-editor-web-embedded-with-terminal", | ||
"ignoredErrors": { | ||
"path": "ignored-errors" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"version": 1, | ||
"patches": { | ||
"path": "patches/web-embedded.series" | ||
}, | ||
"overrides": { | ||
"path": "overrides" | ||
}, | ||
"package-lock-overrides": { | ||
"path": "package-lock-overrides/web-embedded.series" | ||
}, | ||
"target": "code-editor-web-embedded", | ||
"ignoredErrors": { | ||
"path": "ignored-errors" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
set -euo pipefail | ||
|
||
PRESENT_WORKING_DIR="$(pwd)" | ||
PATCHED_SRC_DIR="$PRESENT_WORKING_DIR/code-editor-src" | ||
# Manually update this list to include all files for which there are modified script-src CSP rules | ||
UPDATE_CHECKSUM_FILEPATHS=( | ||
"/src/vs/workbench/contrib/webview/browser/pre/index.html" | ||
|
@@ -70,33 +69,99 @@ calc_script_SHAs() { | |
return 0 | ||
} | ||
|
||
apply_changes() { | ||
echo "Creating patched source in directory: ${PATCHED_SRC_DIR}" | ||
check_unsaved_changes() { | ||
local patches_path=$(jq -r '.patches.path' "$CONFIG_FILE") | ||
|
||
if [[ "$patches_path" == "null" || -z "$patches_path" ]]; then | ||
return | ||
fi | ||
|
||
if [[ ! -d "${PATCHED_SRC_DIR}" ]]; then | ||
return | ||
fi | ||
|
||
export QUILT_PATCHES="${PRESENT_WORKING_DIR}/patches" | ||
export QUILT_SERIES="${PRESENT_WORKING_DIR}/$patches_path" | ||
|
||
pushd "${PATCHED_SRC_DIR}" | ||
|
||
# Check if there are applied patches | ||
local applied_output | ||
applied_output=$(quilt applied 2>/dev/null || true) | ||
|
||
if [[ -z "$applied_output" ]]; then | ||
popd | ||
return | ||
fi | ||
|
||
# Check for unsaved changes with diff | ||
local diff_output | ||
diff_output=$(quilt diff -z 2>/dev/null || true) | ||
|
||
if [[ -n "$diff_output" ]]; then | ||
popd | ||
echo "Error: You have unsaved changes in the current patch." | ||
echo "Run 'quilt refresh' to update the patch with your changes." | ||
echo "Please refresh or revert your changes before rebasing again" | ||
exit 1 | ||
fi | ||
|
||
popd | ||
} | ||
|
||
setup_quilt_environment() { | ||
local patches_path=$(jq -r '.patches.path' "$CONFIG_FILE") | ||
|
||
patch_dir="${PRESENT_WORKING_DIR}/patches" | ||
echo "Set patch directory as: $patch_dir" | ||
|
||
export QUILT_PATCHES="${patch_dir}" | ||
export QUILT_SERIES="${PRESENT_WORKING_DIR}/patches/sagemaker.series" | ||
export QUILT_SERIES="${PRESENT_WORKING_DIR}/$patches_path" | ||
echo "Using series file: $QUILT_SERIES" | ||
} | ||
|
||
# Clean out the build directory | ||
prepare_patch_directory() { | ||
echo "Cleaning build src dir" | ||
rm -rf "${PATCHED_SRC_DIR}" | ||
|
||
# Copy third party source | ||
|
||
echo "Copying third party source to the patch directory" | ||
rsync -a "${PRESENT_WORKING_DIR}/third-party-src/" "${PATCHED_SRC_DIR}" | ||
} | ||
|
||
echo "Applying base patches" | ||
apply_patches() { | ||
echo "Applying patches" | ||
pushd "${PATCHED_SRC_DIR}" | ||
quilt push -a | ||
popd | ||
} | ||
|
||
prepare_src() { | ||
echo "Creating patched source in directory: ${PATCHED_SRC_DIR}" | ||
setup_quilt_environment | ||
prepare_patch_directory | ||
apply_patches | ||
apply_overrides | ||
} | ||
|
||
rebase_patches() { | ||
echo "Creating patched source in directory: ${PATCHED_SRC_DIR}" | ||
setup_quilt_environment | ||
check_unsaved_changes | ||
prepare_patch_directory | ||
rebase | ||
apply_overrides | ||
} | ||
|
||
apply_overrides() { | ||
# Read configuration from JSON file | ||
local overrides_path=$(jq -r '.overrides.path' "$CONFIG_FILE") | ||
local package_lock_path=$(jq -r '."package-lock-overrides".path' "$CONFIG_FILE") | ||
|
||
echo "Applying overrides" | ||
rsync -a "${PRESENT_WORKING_DIR}/overrides/" "${PATCHED_SRC_DIR}" | ||
rsync -a "${PRESENT_WORKING_DIR}/$overrides_path/" "${PATCHED_SRC_DIR}" | ||
|
||
echo "Applying package-lock overrides" | ||
rsync -a "${PRESENT_WORKING_DIR}/package-lock-overrides/sagemaker.series/" "${PATCHED_SRC_DIR}" | ||
rsync -a "${PRESENT_WORKING_DIR}/$package_lock_path/" "${PATCHED_SRC_DIR}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this command is going to fail for |
||
} | ||
|
||
update_inline_sha() { | ||
|
@@ -121,5 +186,118 @@ update_inline_sha() { | |
done | ||
} | ||
|
||
apply_changes | ||
update_inline_sha | ||
parse_conflict_files() { | ||
printf '%s\n' "1ドル" | grep -A1 "^patching file" | grep -B1 "NOT MERGED" | grep "^patching file" | sed 's/^patching file //' | ||
} | ||
|
||
parse_missing_files() { | ||
printf '%s\n' "1ドル" | grep -A5 "can't find file to patch" | grep "^|Index:" | sed 's/^|Index: //' | sort -u | ||
} | ||
|
||
rebase() { | ||
echo "Rebasing patches one by one..." | ||
pushd "${PATCHED_SRC_DIR}" | ||
|
||
# Apply patches one by one with force | ||
while quilt next >/dev/null 2>&1; do | ||
|
||
local output | ||
set +e # Disable exit on error | ||
output=$(quilt push -f -m 2>&1) | ||
local exit_code=$? | ||
set -e # Re-enable exit on error | ||
|
||
echo "$output" | ||
|
||
# Parse conflicts and missing files | ||
local conflict_files | ||
local missing_files | ||
conflict_files=($(parse_conflict_files "$output" || true)) | ||
missing_files=($(parse_missing_files "$output" || true)) | ||
|
||
if [[ $exit_code -eq 0 ]]; then | ||
echo "Successfully applied patch: $(quilt top)" | ||
|
||
else | ||
|
||
if [[ ${#conflict_files[@]} -gt 0 ]]; then | ||
echo "" | ||
echo "Files with conflicts:" | ||
for file in "${conflict_files[@]}"; do | ||
echo "- $file" | ||
done | ||
fi | ||
|
||
if [[ ${#missing_files[@]} -gt 0 ]]; then | ||
echo "" | ||
echo "Missing files:" | ||
for file in "${missing_files[@]}"; do | ||
echo "- $file" | ||
done | ||
fi | ||
|
||
echo "" | ||
echo "Required actions:" | ||
echo "1. Edit the files to resolve any conflicts" | ||
echo "2. Run 'quilt refresh' to update the patch" | ||
echo "3. Then run the prepare-src script again to continue" | ||
echo "" | ||
popd | ||
exit 1 | ||
fi | ||
|
||
done | ||
|
||
echo "All patches applied successfully" | ||
popd | ||
} | ||
|
||
# Parse command line arguments | ||
COMMAND="prepare_src" | ||
TARGET="code-editor-sagemaker-server" | ||
|
||
case "${1:-}" in | ||
--command) | ||
[[ $# -ge 2 ]] || { echo "--command requires a value" >&2; exit 1; } | ||
COMMAND="2ドル" | ||
TARGET="${3:-$TARGET}" | ||
;; | ||
-*) | ||
echo "Unknown option 1ドル" >&2 | ||
exit 1 | ||
;; | ||
"") | ||
# No arguments, use defaults | ||
;; | ||
*) | ||
TARGET="1ドル" | ||
;; | ||
esac | ||
|
||
PATCHED_SRC_DIR="$PRESENT_WORKING_DIR/code-editor-src" | ||
CONFIG_FILE="$PRESENT_WORKING_DIR/configuration/$TARGET.json" | ||
|
||
# Check if config file exists | ||
if [[ ! -f "$CONFIG_FILE" ]]; then | ||
echo "Error: Configuration file not found: $CONFIG_FILE" >&2 | ||
exit 1 | ||
fi | ||
|
||
echo "Using configuration: $CONFIG_FILE" | ||
echo "Preparing source for target: $TARGET" | ||
case "$COMMAND" in | ||
prepare_src) | ||
prepare_src | ||
update_inline_sha | ||
;; | ||
rebase_patches) | ||
echo "Rebase mode enabled" | ||
rebase_patches | ||
;; | ||
*) | ||
echo "Unknown command: $COMMAND" >&2 | ||
echo "Available commands: prepare_src, rebase_patches" >&2 | ||
exit 1 | ||
;; | ||
esac | ||
echo "Successfully prepared source for target: $TARGET" |