Skip to content

Commit d1f2a44

Browse files
edvilmeCopilot
andauthored
Experiment: integrate shared package as a git submodule (#696)
* Integrate shared package as a git submodule Replaces the external @vscode/common-python-lsp / vscode-common-python-lsp dependency with a git submodule at external/vscode-common-python-lsp (pinned to v0.8.0). npm consumes it via a file: reference, the Python lib is bundled from the submodule, and the release pipeline now bumps the submodule commit instead of a version pin. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix CI for git submodule integration - Build the shared package TypeScript dist via a postinstall hook so the bundler and type-checker can resolve the file: dependency. - Regenerate package-lock.json to record the file: link and the submodule dependency tree. - Exclude external/ from the extension tsconfig so the submodule sources are not type-checked against the extension rootDir. - Check out submodules (recursive) in PR and push CI so the submodule and its Python library are present for npm and nox. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix VSIX packaging and type-checking for submodule integration - Exclude external/ from the VSIX (.vscodeignore) since webpack already bundles the shared package; avoids case-insensitive path collisions from the submodule node_modules. - Add skipLibCheck to tsconfig where missing so hoisted submodule devDep type definitions do not fail the extension type-check. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Checkout submodules in Azure DevOps pipelines The 1ES/DevDiv checkout template does not initialize submodules, so add an explicit git submodule update --init --recursive step before npm ci and nox in the validation, stable, and pre-release pipelines. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Init submodules manually in isort tests job The tests job checks out into a working directory with spaces and unicode (the special-working-directory path), which breaks actions/checkout submodule initialization. Check out without submodules there and run git submodule update --init --recursive as a separate step instead. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent cc3220e commit d1f2a44

17 files changed

Lines changed: 924 additions & 121 deletions

.github/workflows/pr-check.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818
steps:
1919
- name: Checkout
2020
uses: actions/checkout@v6.0.2
21+
with:
22+
submodules: recursive
2123

2224
- name: Build VSIX
2325
uses: ./.github/actions/build-vsix
@@ -31,6 +33,8 @@ jobs:
3133
steps:
3234
- name: Checkout
3335
uses: actions/checkout@v6.0.2
36+
with:
37+
submodules: recursive
3438

3539
- name: Lint
3640
uses: ./.github/actions/lint
@@ -56,6 +60,10 @@ jobs:
5660
with:
5761
path: ${{ env.special-working-directory-relative }}
5862

63+
- name: Checkout submodules
64+
run: git submodule update --init --recursive
65+
shell: bash
66+
5967
# Install bundled libs using env.PYTHON_VERSION even though you test it on other versions.
6068
- name: Use Python ${{ env.PYTHON_VERSION }}
6169
uses: actions/setup-python@v6

.github/workflows/push-check.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
steps:
2525
- name: Checkout
2626
uses: actions/checkout@v6.0.2
27+
with:
28+
submodules: recursive
2729

2830
- name: Build VSIX
2931
uses: ./.github/actions/build-vsix
@@ -38,6 +40,8 @@ jobs:
3840
steps:
3941
- name: Checkout
4042
uses: actions/checkout@v6.0.2
43+
with:
44+
submodules: recursive
4145

4246
- name: Lint
4347
uses: ./.github/actions/lint
@@ -64,6 +68,10 @@ jobs:
6468
with:
6569
path: ${{ env.special-working-directory-relative }}
6670

71+
- name: Checkout submodules
72+
run: git submodule update --init --recursive
73+
shell: bash
74+
6775
# Install bundled libs using env.PYTHON_VERSION even though you test it on other versions.
6876
- name: Use Python ${{ env.PYTHON_VERSION }}
6977
uses: actions/setup-python@v6

.github/workflows/shared-package-release.yml renamed to .github/workflows/shared-package-submodule-sync.yml

Lines changed: 32 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Shared Package Release Handler
1+
name: Shared Package Submodule Sync
22

33
on:
44
repository_dispatch:
@@ -9,32 +9,22 @@ permissions:
99
issues: write
1010

1111
concurrency:
12-
group: 'shared-package-release-${{ github.event.client_payload.release_tag }}'
12+
group: 'shared-package-submodule-${{ github.event.client_payload.release_tag }}'
1313
cancel-in-progress: false
1414

1515
env:
16-
NODE_VERSION: 24.17.0
17-
# Match the Python version documented in requirements.in so the regenerated
18-
# lockfile stays valid across the supported Python range.
19-
PYTHON_VERSION: '3.10'
16+
SUBMODULE_PATH: external/vscode-common-python-lsp
2017

2118
jobs:
22-
update-shared-packages:
23-
name: Update shared packages
19+
update-submodule:
20+
name: Update shared package submodule
2421
runs-on: ubuntu-latest
2522
steps:
2623
- name: Checkout
2724
uses: actions/checkout@v6
28-
29-
- name: Install Node
30-
uses: actions/setup-node@v6
31-
with:
32-
node-version: ${{ env.NODE_VERSION }}
33-
34-
- name: Install Python
35-
uses: actions/setup-python@v6
3625
with:
37-
python-version: ${{ env.PYTHON_VERSION }}
26+
submodules: recursive
27+
fetch-depth: 0
3828

3929
- name: Validate dispatch payload
4030
env:
@@ -50,15 +40,6 @@ jobs:
5040
exit 1
5141
fi
5242
53-
- name: Normalize release tag
54-
id: release_version
55-
env:
56-
RELEASE_TAG: ${{ github.event.client_payload.release_tag }}
57-
run: |
58-
set -euo pipefail
59-
VERSION="${RELEASE_TAG#v}"
60-
echo "value=$VERSION" >> "$GITHUB_OUTPUT"
61-
6243
- name: Create branch for this release
6344
env:
6445
RELEASE_TAG: ${{ github.event.client_payload.release_tag }}
@@ -69,46 +50,28 @@ jobs:
6950
# Fetch any pre-existing remote branch so --force-with-lease has a ref.
7051
git fetch origin "+refs/heads/${BRANCH}:refs/remotes/origin/${BRANCH}" 2>/dev/null || true
7152
git checkout -B "$BRANCH" origin/main
53+
# Re-sync the submodule to whatever the freshly checked-out main records.
54+
git submodule update --init --recursive "${SUBMODULE_PATH}"
7255
73-
- name: Update npm dependency
56+
- name: Move submodule to the released commit
7457
env:
75-
NPM_DEP: ${{ github.event.client_payload.npm_dependency }}
76-
RELEASE_VERSION: ${{ steps.release_version.outputs.value }}
77-
run: |
78-
set -euo pipefail
79-
if [ -z "${NPM_DEP}" ]; then
80-
echo 'No npm dependency in payload; skipping.'
81-
exit 0
82-
fi
83-
npm install "${NPM_DEP}@${RELEASE_VERSION}"
84-
85-
- name: Update pip dependency
86-
env:
87-
PIP_DEP: ${{ github.event.client_payload.pip_dependency }}
88-
RELEASE_VERSION: ${{ steps.release_version.outputs.value }}
58+
RELEASE_TAG: ${{ github.event.client_payload.release_tag }}
8959
run: |
9060
set -euo pipefail
91-
if [ -z "${PIP_DEP}" ]; then
92-
echo 'No pip dependency in payload; skipping.'
93-
exit 0
94-
fi
95-
if [ ! -f requirements.in ]; then
96-
echo 'No requirements.in found; skipping.'
97-
exit 0
98-
fi
99-
python -m pip install --upgrade uv
100-
# Rewrite the pin (case-insensitive) for the shared package only.
101-
sed -i -E "s/^${PIP_DEP}([<>=!~].*)?\$/${PIP_DEP}==${RELEASE_VERSION}/I" requirements.in
102-
if ! grep -iEq "^${PIP_DEP}==${RELEASE_VERSION}([[:space:];].*)?\$" requirements.in; then
103-
echo "Failed to pin ${PIP_DEP}==${RELEASE_VERSION} in requirements.in." >&2
104-
exit 1
61+
cd "${SUBMODULE_PATH}"
62+
git fetch --tags --force origin
63+
STRIPPED="${RELEASE_TAG#v}"
64+
if git rev-parse -q --verify "refs/tags/${RELEASE_TAG}^{commit}" >/dev/null; then
65+
TARGET="refs/tags/${RELEASE_TAG}"
66+
elif git rev-parse -q --verify "refs/tags/v${STRIPPED}^{commit}" >/dev/null; then
67+
TARGET="refs/tags/v${STRIPPED}"
68+
else
69+
echo "Release tag '${RELEASE_TAG}' not found upstream; falling back to origin/main." >&2
70+
git fetch origin main
71+
TARGET="origin/main"
10572
fi
106-
# Scope the re-resolve to the shared package and pin to the documented
107-
# Python version so unrelated deps and version markers are preserved.
108-
uv pip compile --generate-hashes \
109-
--upgrade-package "${PIP_DEP}" \
110-
--python-version "${PYTHON_VERSION}" \
111-
-o requirements.txt requirements.in
73+
echo "Checking out submodule at ${TARGET}."
74+
git checkout --detach "${TARGET}"
11275
11376
- name: Push branch and open tracking issue if changed
11477
env:
@@ -120,18 +83,19 @@ jobs:
12083
set -euo pipefail
12184
git config user.name 'github-actions[bot]'
12285
git config user.email 'github-actions[bot]@users.noreply.github.com'
123-
if git diff --quiet; then
124-
echo 'No changes detected.'
86+
# Only the submodule gitlink should have moved.
87+
if git diff --quiet -- "${SUBMODULE_PATH}"; then
88+
echo 'Submodule already at the released commit; nothing to do.'
12589
exit 0
12690
fi
12791
BRANCH="shared-package-v${RELEASE_TAG#v}"
128-
git add -A
129-
git commit -m "Upgrade shared package to ${RELEASE_TAG}"
92+
git add "${SUBMODULE_PATH}"
93+
git commit -m "Update shared package submodule to ${RELEASE_TAG}"
13094
git push --force-with-lease --set-upstream origin "$BRANCH"
13195
COMPARE_URL="https://github.com/${REPO}/compare/main...${BRANCH}?expand=1"
132-
TITLE="[Shared Package] Open PR to upgrade to ${RELEASE_TAG}"
96+
TITLE="[Shared Package] Open PR to update submodule to ${RELEASE_TAG}"
13397
{
134-
echo "### Shared package upgrade ready"
98+
echo "### Shared package submodule update ready"
13599
echo ''
136100
echo "Branch \`${BRANCH}\` has been pushed."
137101
echo ''
@@ -141,7 +105,7 @@ jobs:
141105
} >> "$GITHUB_STEP_SUMMARY"
142106
BODY_FILE="$(mktemp)"
143107
cat > "$BODY_FILE" <<EOF
144-
Branch \`${BRANCH}\` has been pushed with the shared package upgrade to ${RELEASE_TAG}.
108+
Branch \`${BRANCH}\` has been pushed, moving the \`${SUBMODULE_PATH}\` submodule to ${RELEASE_TAG}.
145109
146110
Organization settings prevent this workflow from opening pull requests automatically. Please open the PR manually:
147111

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "external/vscode-common-python-lsp"]
2+
path = external/vscode-common-python-lsp
3+
url = https://github.com/microsoft/vscode-common-python-lsp.git

.vscodeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.vscode-test/**
33
out/**
44
node_modules/**
5+
external/**
56
src/**
67
.gitignore
78
.yarnrc

build/azure-devdiv-pipeline.pre-release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ parameters:
3838
- name: buildSteps
3939
type: stepList
4040
default:
41+
- script: git submodule update --init --recursive
42+
displayName: Checkout submodules
4143
- script: npm ci
4244
displayName: Install NPM dependencies
4345

build/azure-devdiv-pipeline.stable.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ parameters:
3333
- name: buildSteps
3434
type: stepList
3535
default:
36+
- script: git submodule update --init --recursive
37+
displayName: Checkout submodules
3638
- script: npm ci
3739
displayName: Install NPM dependencies
3840

build/azure-pipeline.pre-release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ extends:
4848
architecture: 'x64'
4949
displayName: Select Python version
5050

51+
- script: git submodule update --init --recursive
52+
displayName: Checkout submodules
5153
- script: npm ci
5254
displayName: Install NPM dependencies
5355

build/azure-pipeline.stable.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ extends:
4444
architecture: 'x64'
4545
displayName: Select Python version
4646

47+
- script: git submodule update --init --recursive
48+
displayName: Checkout submodules
4749
- script: npm ci
4850
displayName: Install NPM dependencies
4951

build/azure-pipeline.validation.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ parameters:
3232
- name: buildSteps
3333
type: stepList
3434
default:
35+
- script: git submodule update --init --recursive
36+
displayName: Checkout submodules
3537
- script: npm ci
3638
displayName: Install NPM dependencies
3739

0 commit comments

Comments
 (0)