Skip to content

Commit 2126b11

Browse files
authored
Add step for updating the package-lock overrides in the update-automation workflow (#38)
1 parent 01a2f96 commit 2126b11

File tree

1 file changed

+87
-6
lines changed

1 file changed

+87
-6
lines changed

.github/workflows/update-automation.yaml

Lines changed: 87 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,26 @@ jobs:
1111
runs-on: ubuntu-latest
1212
permissions:
1313
contents: write
14+
outputs:
15+
staging-branch: ${{ env.STAGING_BRANCH }}
1416
steps:
1517
- name: Setup environment
1618
run: |
1719
echo "Installing required dependencies"
1820
sudo apt-get update
19-
sudo apt-get install -y quilt libxml2-utils jq
21+
sudo apt-get install -y quilt libxml2-utils jq libkrb5-dev libx11-dev libxkbfile-dev
2022
2123
- name: Checkout code
2224
uses: actions/checkout@v4
2325
with:
2426
fetch-depth: 0
2527
submodules: true
2628

29+
- name: Configure git
30+
run: |
31+
git config user.name "github-actions[bot]"
32+
git config user.email "github-actions[bot]@users.noreply.github.com"
33+
2734
- name: Get latest semver branch
2835
run: |
2936
git fetch origin
@@ -80,10 +87,6 @@ jobs:
8087
git checkout "$LATEST_TAG"
8188
cd ..
8289
83-
# Configure git user and commit changes if needed
84-
git config user.name "github-actions[bot]"
85-
git config user.email "github-actions[bot]@users.noreply.github.com"
86-
8790
git add third-party-src
8891
if git diff --staged --quiet; then
8992
echo "No changes to commit, submodule already up to date"
@@ -92,6 +95,7 @@ jobs:
9295
git push origin "$STAGING_BRANCH"
9396
fi
9497
98+
echo "STAGING_BRANCH=$STAGING_BRANCH" >> $GITHUB_ENV
9599
echo "Created staging branch: $STAGING_BRANCH with VS Code $LATEST_TAG"
96100
fi
97101
@@ -127,10 +131,87 @@ jobs:
127131
echo "All targets rebased successfully"
128132
fi
129133
134+
# Commit rebased patches if any changes
135+
git add patches/
136+
if ! git diff --staged --quiet; then
137+
git commit -m "Rebase patches for all targets"
138+
git push origin "$STAGING_BRANCH"
139+
fi
140+
141+
update-package-locks:
142+
name: Update Package Locks
143+
runs-on: ubuntu-latest
144+
needs: update-automation
145+
if: needs.update-automation.outputs.staging-branch != ''
146+
permissions:
147+
contents: write
148+
strategy:
149+
matrix:
150+
target: [code-editor-server, code-editor-sagemaker-server, code-editor-web-embedded, code-editor-web-embedded-with-terminal]
151+
steps:
152+
- name: Setup environment
153+
run: |
154+
sudo apt-get update
155+
sudo apt-get install -y quilt libxml2-utils jq libkrb5-dev libx11-dev libxkbfile-dev
156+
157+
- name: Checkout code
158+
uses: actions/checkout@v4
159+
with:
160+
ref: ${{ needs.update-automation.outputs.staging-branch }}
161+
fetch-depth: 0
162+
submodules: true
163+
164+
- name: Configure git
165+
run: |
166+
git config user.name "github-actions[bot]"
167+
git config user.email "github-actions[bot]@users.noreply.github.com"
168+
169+
- name: Update package-lock for target
170+
run: |
171+
OVERRIDE_PATH=$(jq -r '."package-lock-overrides".path' "configuration/${{ matrix.target }}.json")
172+
173+
./scripts/prepare-src.sh "${{ matrix.target }}"
174+
175+
cd code-editor-src
176+
npm install
177+
cd ..
178+
179+
rm -rf "$OVERRIDE_PATH"
180+
mkdir -p "$OVERRIDE_PATH"
181+
182+
find code-editor-src -name "package-lock.json" -type f | while read -r file; do
183+
rel_path="${file#code-editor-src/}"
184+
third_party_file="third-party-src/$rel_path"
185+
186+
if [ ! -f "$third_party_file" ] || ! cmp -s "$file" "$third_party_file"; then
187+
dest_dir="$OVERRIDE_PATH/$(dirname "$rel_path")"
188+
mkdir -p "$dest_dir"
189+
cp "$file" "$dest_dir/"
190+
echo "Copied updated $rel_path to $OVERRIDE_PATH"
191+
fi
192+
done
193+
194+
rm -rf code-editor-src
195+
196+
- name: Commit package-lock overrides
197+
run: |
198+
git add package-lock-overrides/
199+
if ! git diff --staged --quiet; then
200+
git commit -m "Update package-lock.json overrides for ${{ matrix.target }}"
201+
202+
# Retry push with rebase until successful
203+
for i in {1..5}; do
204+
if git pull --rebase origin "${{ needs.update-automation.outputs.staging-branch }}" && git push origin "${{ needs.update-automation.outputs.staging-branch }}"; then
205+
break
206+
fi
207+
sleep $((i * 2))
208+
done
209+
fi
210+
130211
handle-failures:
131212
name: Handle Failures
132213
runs-on: ubuntu-latest
133-
needs: update-automation
214+
needs: [update-automation, update-package-locks]
134215
if: failure()
135216
steps:
136217
- name: Report rebase failures

0 commit comments

Comments
 (0)