Skip to content

Commit 86b9791

Browse files
karthiknadigDonJayamanne
authored andcommitted
Build rust python finder for CI and produce a package (#23465)
1 parent 4323c58 commit 86b9791

File tree

5 files changed

+1030
-153
lines changed

5 files changed

+1030
-153
lines changed

.github/actions/build-vsix/action.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ inputs:
1111
artifact_name:
1212
description: 'Name to give the artifact containing the VSIX'
1313
required: true
14+
cargo_target:
15+
description: 'Cargo build target for the native build'
16+
required: true
17+
vsix_target:
18+
description: 'vsix build target for the native build'
19+
required: true
1420

1521
runs:
1622
using: 'composite'
@@ -47,27 +53,32 @@ runs:
4753
run: nox --session install_python_libs
4854
shell: bash
4955

56+
- name: Add Rustup target
57+
run: rustup target add ${{ inputs.cargo_target }}
58+
shell: bash
59+
5060
- name: Build Native Binaries
5161
run: nox --session native_build
5262
shell: bash
63+
env:
64+
CARGO_TARGET: ${{ inputs.cargo_target }}
5365

5466
- name: Run npm ci
5567
run: npm ci --prefer-offline
5668
shell: bash
5769

58-
# Use the GITHUB_RUN_ID environment variable to update the build number.
59-
# GITHUB_RUN_ID is a unique number for each run within a repository.
60-
# This number does not change if you re-run the workflow run.
61-
- name: Update extension build number
62-
run: npm run updateBuildNumber -- --buildNumber $GITHUB_RUN_ID
63-
shell: bash
64-
6570
- name: Update optional extension dependencies
6671
run: npm run addExtensionPackDependencies
6772
shell: bash
6873

74+
- name: Build Webpack
75+
run: |
76+
npx gulp clean
77+
npx gulp prePublishBundle
78+
shell: bash
79+
6980
- name: Build VSIX
70-
run: npm run package
81+
run: npx vsce package --target ${{ inputs.vsix_target }} --out ms-python-insiders.vsix --pre-release
7182
shell: bash
7283

7384
- name: Rename VSIX

.github/workflows/pr-check.yml

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ env:
1212
PYTHON_VERSION: '3.10' # YML treats 3.10 the number as 3.1, so quotes around 3.10
1313
MOCHA_REPORTER_JUNIT: true # Use the mocha-multi-reporters and send output to both console (spec) and JUnit (mocha-junit-reporter). Also enables a reporter which exits the process running the tests if it haven't already.
1414
ARTIFACT_NAME_VSIX: ms-python-insiders-vsix
15-
VSIX_NAME: ms-python-insiders.vsix
1615
TEST_RESULTS_DIRECTORY: .
1716
# Force a path with spaces and to test extension works in these scenarios
1817
# Unicode characters are causing 2.7 failures so skip that for now.
@@ -22,7 +21,38 @@ env:
2221
jobs:
2322
build-vsix:
2423
name: Create VSIX
25-
runs-on: ubuntu-latest
24+
runs-on: ${{ matrix.os }}
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
include:
29+
- os: windows-latest
30+
target: x86_64-pc-windows-msvc
31+
vsix-target: win32-x64
32+
- os: windows-latest
33+
target: aarch64-pc-windows-msvc
34+
vsix-target: win32-arm64
35+
- os: ubuntu-latest
36+
target: x86_64-unknown-linux-gnu
37+
vsix-target: linux-x64
38+
# - os: ubuntu-latest
39+
# target: aarch64-unknown-linux-gnu
40+
# vsix-target: linux-arm64
41+
# - os: ubuntu-latest
42+
# target: arm-unknown-linux-gnueabihf
43+
# vsix-target: linux-armhf
44+
- os: macos-latest
45+
target: x86_64-apple-darwin
46+
vsix-target: darwin-x64
47+
- os: macos-14
48+
target: aarch64-apple-darwin
49+
vsix-target: darwin-arm64
50+
- os: ubuntu-latest
51+
target: x86_64-unknown-linux-musl
52+
vsix-target: alpine-x64
53+
# - os: ubuntu-latest
54+
# target: aarch64-unknown-linux-musl
55+
# vsix-target: alpine-arm64
2656
steps:
2757
- name: Checkout
2858
uses: actions/checkout@v4
@@ -31,8 +61,10 @@ jobs:
3161
uses: ./.github/actions/build-vsix
3262
with:
3363
node_version: ${{ env.NODE_VERSION}}
34-
vsix_name: ${{ env.VSIX_NAME }}
35-
artifact_name: ${{ env.ARTIFACT_NAME_VSIX }}
64+
vsix_name: 'ms-python-insiders-${{ matrix.vsix-target }}.vsix'
65+
artifact_name: '${{ env.ARTIFACT_NAME_VSIX }}-${{ matrix.vsix-target }}'
66+
cargo_target: ${{ matrix.target }}
67+
vsix_target: ${{ matrix.vsix-target }}
3668

3769
lint:
3870
name: Lint
@@ -345,7 +377,12 @@ jobs:
345377
matrix:
346378
# We're not running CI on macOS for now because it's one less matrix entry to lower the number of runners used,
347379
# macOS runners are expensive, and we assume that Ubuntu is enough to cover the UNIX case.
348-
os: [ubuntu-latest, windows-latest]
380+
include:
381+
- os: windows-latest
382+
vsix-target: win32-x64
383+
- os: ubuntu-latest
384+
vsix-target: linux-x64
385+
349386
steps:
350387
# Need the source to have the tests available.
351388
- name: Checkout
@@ -355,7 +392,7 @@ jobs:
355392
uses: ./.github/actions/smoke-tests
356393
with:
357394
node_version: ${{ env.NODE_VERSION }}
358-
artifact_name: ${{ env.ARTIFACT_NAME_VSIX }}
395+
artifact_name: '${{ env.ARTIFACT_NAME_VSIX }}-${{ matrix.vsix-target }}'
359396

360397
### Coverage run
361398
coverage:

noxfile.py

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
33

4+
import os
45
import pathlib
56
import nox
67
import shutil
78
import sys
9+
import sysconfig
810

911

1012
@nox.session()
@@ -45,26 +47,50 @@ def install_python_libs(session: nox.Session):
4547

4648

4749
@nox.session()
48-
def native_build(session:nox.Session):
50+
def native_build(session: nox.Session):
4951
with session.cd("./native_locator"):
50-
session.run("cargo", "build", "--release", "--package", "python-finder", external=True)
5152
if not pathlib.Path(pathlib.Path.cwd() / "bin").exists():
5253
pathlib.Path(pathlib.Path.cwd() / "bin").mkdir()
5354

5455
if not pathlib.Path(pathlib.Path.cwd() / "bin" / ".gitignore").exists():
55-
pathlib.Path(pathlib.Path.cwd() / "bin" / ".gitignore").write_text("*\n", encoding="utf-8")
56+
pathlib.Path(pathlib.Path.cwd() / "bin" / ".gitignore").write_text(
57+
"*\n", encoding="utf-8"
58+
)
59+
60+
ext = sysconfig.get_config_var("EXE") or ""
61+
target = os.environ.get("CARGO_TARGET", None)
5662

57-
if sys.platform == "win32":
58-
shutil.copy(
59-
"./target/release/python-finder.exe",
60-
"./bin/python-finder.exe",
63+
session.run("cargo", "fetch", external=True)
64+
if target:
65+
session.run(
66+
"cargo",
67+
"build",
68+
"--frozen",
69+
"--release",
70+
"--target",
71+
target,
72+
"--package",
73+
"python-finder",
74+
external=True,
6175
)
76+
source = f"./target/{target}/release/python-finder{ext}"
77+
dest = f"./bin/python-finder{ext}"
78+
shutil.copy(source, dest)
6279
else:
63-
shutil.copy(
64-
"./target/release/python-finder",
65-
"./bin/python-finder",
80+
session.run(
81+
"cargo",
82+
"build",
83+
"--frozen",
84+
"--release",
85+
"--package",
86+
"python-finder",
87+
external=True,
6688
)
6789

90+
source = f"./target/release/python-finder{ext}"
91+
dest = f"./bin/python-finder{ext}"
92+
shutil.copy(source, dest)
93+
6894

6995
@nox.session()
7096
def setup_repo(session: nox.Session):

0 commit comments

Comments
 (0)