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

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

Merged
vpaiu merged 23 commits into aws:main from vpaiu:rebase-patches
Aug 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
cd180c4
Changed prepare-src to accept multiple targets
vpaiu Aug 14, 2025
d94603a
Changed build workflow to call prepare-src with target
vpaiu Aug 14, 2025
48e4883
Added basic rebase functionality to prepare-src and added step in wor...
vpaiu Aug 14, 2025
73375d5
Temporarily changed branch to run workflow on for testing purposes
vpaiu Aug 14, 2025
d5dcd3d
For testing
vpaiu Aug 14, 2025
4098da3
Fixed minor bug
vpaiu Aug 14, 2025
a76dfa6
Added intial check for unsaved changes
vpaiu Aug 14, 2025
58c9c7c
fixed checking unsaved changes
vpaiu Aug 14, 2025
df1a4f1
Added flag for not checking for unsaved changes when rebasing
vpaiu Aug 15, 2025
20b55c9
Capturing error output when rebasing
vpaiu Aug 15, 2025
9a01387
Removed error caputuring and simplified the output
vpaiu Aug 15, 2025
9421e5f
Merge branch 'aws:main' into rebase-patches
vpaiu Aug 15, 2025
b1c2cc5
Added pattern matching
vpaiu Aug 15, 2025
1779fbf
Fixed bugs for rebasing
vpaiu Aug 18, 2025
2334c36
Merge branch 'aws:main' into rebase-patches
vpaiu Aug 18, 2025
020c508
Added job for reporting metrics to CW
vpaiu Aug 18, 2025
440f8ec
Fixed bug concerning information passing between jobs
vpaiu Aug 18, 2025
875c701
Changed the job for failure reporting
vpaiu Aug 18, 2025
02a89de
Refactored prepare-src + added target
vpaiu Aug 18, 2025
b0883e2
Merge branch 'main' into rebase-patches
vpaiu Aug 18, 2025
7859328
Got rid of the flag and added empty package-lock-override folders
vpaiu Aug 18, 2025
094a447
Made update_inline_sha usable only by prepare-src
vpaiu Aug 18, 2025
d5089f6
Got rid of the while loop parsing flags
vpaiu Aug 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/build-targets.yaml
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ jobs:
environment: build-targets-workflow-env
strategy:
matrix:
build-target: [code-editor-server, code-editor-sagemaker-server, code-editor-web-embedded]
build-target: [code-editor-server, code-editor-sagemaker-server, code-editor-web-embedded, code-editor-web-embedded-with-terminal]
exclude:
# Only build SageMaker for now, remove the excluded targets when needed in the future.
- build-target: code-editor-server
- build-target: code-editor-web-embedded
- build-target: code-editor-web-embedded-with-terminal
steps:
- name: Start Build Workflow
run: |
Expand All @@ -36,7 +37,7 @@ jobs:

- name: Run patches script
run: |
./scripts/prepare-src.sh
./scripts/prepare-src.sh ${{ matrix.build-target }}

- name: Set up Node.js
uses: actions/setup-node@v4
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/update-automation.yaml
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Copy link
Contributor

@sachinh-amazon sachinh-amazon Aug 18, 2025

Choose a reason for hiding this comment

The 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 update-automation job. From GitHub docs

by default, jobs have no dependencies and run in parallel

If this job runs in parallel with the update-automation job, then failure handling won't work as expected for us. We should move this step as part of the update-automation job itself, right after the rebasing for all targets step. Example here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The needs: attribute of the handle-failures job specifies that it is run after update-automation is finished (they don't run in parallel), and the if attribute activates the job only if update-automation ended in failure. I created it as a separate job because there are multiple points in the update-automation workflow where metrics would need to be sent to CW in case of failure.

Copy link
Contributor

@sachinh-amazon sachinh-amazon Aug 18, 2025

Choose a reason for hiding this comment

The 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 update-automation job fails, and not just if the rebasing step fails.

vpaiu reacted with thumbs up emoji


16 changes: 16 additions & 0 deletions configuration/code-editor-sagemaker-server.json
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
Copy link
Contributor

@sachinh-amazon sachinh-amazon Aug 18, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also use version here for all configuration files, just to keep it consistent with the internal ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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"
}
}
16 changes: 16 additions & 0 deletions configuration/code-editor-server.json
View file Open in desktop
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"
}
}
16 changes: 16 additions & 0 deletions configuration/code-editor-web-embedded-with-terminal.json
View file Open in desktop
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"
}
}
16 changes: 16 additions & 0 deletions configuration/code-editor-web-embedded.json
View file Open in desktop
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"
}
}
Empty file.
View file Open in desktop
Empty file.
View file Open in desktop
Empty file.
202 changes: 190 additions & 12 deletions scripts/prepare-src.sh
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this command is going to fail for code-editor-server and code-editor-web-embedded, because there is no folders package-lock-overrides/web-server.series or package-lock-overrides/web-server.series. We need to add empty folders

vpaiu reacted with thumbs up emoji
}

update_inline_sha() {
Expand All @@ -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"

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