Skip to content

Commit 755bffb

Browse files
baijumeswaniprathikrPrathik RaoCopilotCopilot
authored
Cherry-pick round 1 (#579)
Co-authored-by: Prathik Rao <prathik.rao@gmail.com> Co-authored-by: Prathik Rao <prathikrao@microsoft.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: baijumeswani <12852605+baijumeswani@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: MaanavD <24942306+MaanavD@users.noreply.github.com> Co-authored-by: bmehta001 <bmehta001@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: maanavd <maanavdalal@gmail.com> Co-authored-by: Nenad Banfic <46795300+nenad1002@users.noreply.github.com> Co-authored-by: Scott McKay <Scott.McKay@microsoft.com> Co-authored-by: skottmckay <979079+skottmckay@users.noreply.github.com> Co-authored-by: Samuel Kemp <samuel100@users.noreply.github.com>
1 parent 08f9174 commit 755bffb

271 files changed

Lines changed: 14368 additions & 4388 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-cs-steps.yml

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,41 @@ jobs:
4141
env:
4242
NUGET_AUTH_TOKEN: ${{ secrets.AZURE_DEVOPS_PAT }}
4343

44+
- name: Generate temporary NuGet.config
45+
run: |
46+
# The repo-level NuGet.config cleared all sources and only included ORT-Nightly.
47+
# We generate a temporary one with both nuget.org and ORT-Nightly.
48+
# We provide credentials to allow the ORT-Nightly feed to pull from its upstreams.
49+
$xml = @"
50+
<?xml version="1.0" encoding="utf-8"?>
51+
<configuration>
52+
<packageSources>
53+
<clear />
54+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
55+
<add key="ORT-Nightly" value="https://pkgs.dev.azure.com/aiinfra/PublicPackages/_packaging/ORT-Nightly/nuget/v3/index.json" />
56+
</packageSources>
57+
<packageSourceCredentials>
58+
<ORT-Nightly>
59+
<add key="Username" value="az" />
60+
<add key="ClearTextPassword" value="${{ secrets.ORT_NIGHTLY_PAT }}" />
61+
</ORT-Nightly>
62+
</packageSourceCredentials>
63+
</configuration>
64+
"@
65+
Set-Content -Path sdk/cs/NuGet.temp.config -Value $xml
66+
shell: pwsh
67+
4468
# TODO: once the nightly packaging is fixed, add back the commented out lines with /p:FoundryLocalCoreVersion="*-*"
4569
# /p:FoundryLocalCoreVersion="*-*" to always use nightly version of Foundry Local Core
4670
- name: Restore dependencies
4771
run: |
48-
# dotnet restore sdk/cs/src/Microsoft.AI.Foundry.Local.csproj /p:UseWinML=${{ inputs.useWinML }} /p:FoundryLocalCoreVersion="*-*" --configfile sdk/cs/NuGet.config
49-
dotnet restore sdk/cs/src/Microsoft.AI.Foundry.Local.csproj /p:UseWinML=${{ inputs.useWinML }} --configfile sdk/cs/NuGet.config
72+
# Clear the local NuGet cache to avoid bad metadata or corrupted package states.
73+
dotnet nuget locals all --clear
74+
# Restore using the temporary config file with credentials.
75+
dotnet restore sdk/cs/src/Microsoft.AI.Foundry.Local.csproj /p:UseWinML=${{ inputs.useWinML }} --configfile sdk/cs/NuGet.temp.config
5076
5177
- name: Build solution
5278
run: |
53-
# dotnet build sdk/cs/src/Microsoft.AI.Foundry.Local.csproj --no-restore --configuration ${{ inputs.buildConfiguration }} /p:UseWinML=${{ inputs.useWinML }} /p:FoundryLocalCoreVersion="*-*"
5479
dotnet build sdk/cs/src/Microsoft.AI.Foundry.Local.csproj --no-restore --configuration ${{ inputs.buildConfiguration }} /p:UseWinML=${{ inputs.useWinML }}
5580
5681
# need to use direct git commands to clone from Azure DevOps instead of actions/checkout
@@ -86,6 +111,7 @@ jobs:
86111
- name: Run Foundry Local Core tests
87112
run: |
88113
# dotnet test sdk/cs/test/FoundryLocal.Tests/Microsoft.AI.Foundry.Local.Tests.csproj --verbosity normal /p:UseWinML=${{ inputs.useWinML }} /p:FoundryLocalCoreVersion="*-*"
114+
# Use the temporary config file for test restore as well.
89115
dotnet test sdk/cs/test/FoundryLocal.Tests/Microsoft.AI.Foundry.Local.Tests.csproj --verbosity normal /p:UseWinML=${{ inputs.useWinML }}
90116
91117
- name: Pack NuGet package

.github/workflows/build-js-steps.yml

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- name: Format version for JS
4646
shell: pwsh
4747
run: |
48-
# Release: 0.9.0.41 -> 0.9.0-41
48+
# Release: 1.0.0.41 -> 1.0.0-41
4949
$version = "${{ inputs.version }}"
5050
$versionParts = $version -split '\.'
5151
$baseVersion = ($versionParts[0..2]) -join '.'
@@ -84,22 +84,18 @@ jobs:
8484
Write-Host "`nDirectory contents:"
8585
Get-ChildItem -Recurse -Depth 2 | ForEach-Object { Write-Host " $($_.FullName)" }
8686
87-
88-
- name: npm install (WinML)
89-
if: ${{ inputs.useWinML == true }}
87+
# The .npmrc points to an Azure Artifacts feed for CFS compliance.
88+
# Remove it in CI so npm uses the public registry directly.
89+
- name: Remove .npmrc (use public registry)
90+
shell: pwsh
9091
working-directory: sdk/js
91-
run: npm install --winml
92+
run: |
93+
if (Test-Path .npmrc) { Remove-Item .npmrc -Force; Write-Host "Removed .npmrc" }
9294
93-
- name: npm install (Standard)
94-
if: ${{ inputs.useWinML == false }}
95+
- name: npm install
9596
working-directory: sdk/js
9697
run: npm install
9798

98-
# Verify that installing new packages doesn't strip custom native binary folders
99-
- name: npm install openai (verify persistence)
100-
working-directory: sdk/js
101-
run: npm install openai
102-
10399
- name: Set package version
104100
working-directory: sdk/js
105101
run: npm version ${{ env.ProjectVersion }} --no-git-tag-version --allow-same-version
@@ -112,21 +108,15 @@ jobs:
112108
working-directory: sdk/js
113109
run: npm run build
114110

115-
- name: Pack npm package
111+
- name: Pack npm package (WinML)
112+
if: ${{ inputs.useWinML == true }}
116113
working-directory: sdk/js
117-
run: npm pack
114+
run: npm run pack:winml
118115

119-
- name: Rename WinML artifact
120-
if: ${{ inputs.useWinML == true }}
121-
shell: pwsh
116+
- name: Pack npm package (Standard)
117+
if: ${{ inputs.useWinML == false }}
122118
working-directory: sdk/js
123-
run: |
124-
$tgz = Get-ChildItem *.tgz | Select-Object -First 1
125-
if ($tgz) {
126-
$newName = $tgz.Name -replace '^foundry-local-sdk-', 'foundry-local-sdk-winml-'
127-
Rename-Item -Path $tgz.FullName -NewName $newName
128-
Write-Host "Renamed $($tgz.Name) to $newName"
129-
}
119+
run: npm run pack
130120

131121
- name: Upload npm packages
132122
uses: actions/upload-artifact@v4
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Build Python SDK
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
required: true
8+
type: string
9+
useWinML:
10+
required: false
11+
type: boolean
12+
default: false
13+
platform:
14+
required: false
15+
type: string
16+
default: 'windows'
17+
18+
permissions:
19+
contents: read
20+
21+
jobs:
22+
build:
23+
runs-on: ${{ inputs.platform }}-latest
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
with:
29+
clean: true
30+
31+
- name: Setup Python
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: '3.12'
35+
36+
# Clone test-data-shared from Azure DevOps (models for integration tests)
37+
- name: Checkout test-data-shared from Azure DevOps
38+
shell: pwsh
39+
working-directory: ${{ github.workspace }}/..
40+
run: |
41+
$pat = "${{ secrets.AZURE_DEVOPS_PAT }}"
42+
$encodedPat = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$pat"))
43+
44+
git config --global http.https://dev.azure.com.extraheader "AUTHORIZATION: Basic $encodedPat"
45+
46+
git lfs install
47+
git clone --depth 1 https://dev.azure.com/microsoft/windows.ai.toolkit/_git/test-data-shared test-data-shared
48+
49+
Write-Host "Clone completed successfully to ${{ github.workspace }}/../test-data-shared"
50+
51+
- name: Checkout specific commit in test-data-shared
52+
shell: pwsh
53+
working-directory: ${{ github.workspace }}/../test-data-shared
54+
run: |
55+
git checkout 231f820fe285145b7ea4a449b112c1228ce66a41
56+
if ($LASTEXITCODE -ne 0) {
57+
Write-Error "Git checkout failed."
58+
exit 1
59+
}
60+
61+
- name: Install build tool
62+
run: |
63+
python -m pip install build
64+
65+
- name: Configure pip for Azure Artifacts
66+
run: |
67+
pip config set global.index-url https://pkgs.dev.azure.com/aiinfra/PublicPackages/_packaging/ORT-Nightly/pypi/simple/
68+
pip config set global.extra-index-url https://pypi.org/simple/
69+
pip config set global.pre true
70+
71+
- name: Set package version
72+
working-directory: sdk/python
73+
run: echo '__version__ = "${{ inputs.version }}"' > src/version.py
74+
75+
- name: Build wheel (Cross-Platform)
76+
if: ${{ inputs.useWinML == false }}
77+
working-directory: sdk/python
78+
run: python -m build --wheel --outdir dist/
79+
80+
- name: Build wheel (WinML)
81+
if: ${{ inputs.useWinML == true }}
82+
working-directory: sdk/python
83+
run: python -m build --wheel -C winml=true --outdir dist/
84+
85+
- name: Install built wheel
86+
working-directory: sdk/python
87+
shell: pwsh
88+
run: |
89+
$wheel = (Get-ChildItem dist/*.whl | Select-Object -First 1).FullName
90+
pip install $wheel
91+
92+
- name: Install test dependencies
93+
run: pip install coverage pytest>=7.0.0 pytest-timeout>=2.1.0
94+
95+
- name: Run tests
96+
working-directory: sdk/python
97+
run: python -m pytest test/ -v
98+
99+
- name: Upload Python packages
100+
uses: actions/upload-artifact@v4
101+
with:
102+
name: python-sdk-${{ inputs.platform }}${{ inputs.useWinML == true && '-winml' || '' }}
103+
path: sdk/python/dist/*
104+
105+
- name: Upload flcore logs
106+
uses: actions/upload-artifact@v4
107+
if: always()
108+
with:
109+
name: python-sdk-${{ inputs.platform }}${{ inputs.useWinML == true && '-winml' || '' }}-logs
110+
path: sdk/python/logs/**

.github/workflows/build-rust-steps.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
working-directory: sdk/rust
2929

3030
env:
31-
CARGO_FEATURES: ${{ inputs.useWinML && '--features winml' || '' }}
31+
CARGO_FEATURES: ${{ inputs.useWinML && '--features winml,nightly' || '--features nightly' }}
3232

3333
steps:
3434
- name: Checkout repository
@@ -46,6 +46,18 @@ jobs:
4646
with:
4747
workspaces: sdk/rust -> target
4848

49+
# The .cargo/config.toml redirects crates-io to an Azure Artifacts feed
50+
# for CFS compliance. Remove the redirect in CI so cargo can fetch from
51+
# crates.io directly without Azure DevOps auth.
52+
- name: Use crates.io directly
53+
shell: pwsh
54+
working-directory: sdk/rust
55+
run: |
56+
if (Test-Path .cargo/config.toml) {
57+
Remove-Item .cargo/config.toml
58+
Write-Host "Removed .cargo/config.toml crates-io redirect"
59+
}
60+
4961
- name: Checkout test-data-shared from Azure DevOps
5062
if: ${{ inputs.run-integration-tests }}
5163
shell: pwsh

.github/workflows/foundry-local-sdk-build.yml

Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -17,62 +17,30 @@ permissions:
1717
contents: read
1818

1919
jobs:
20-
build-cs-windows:
21-
uses: ./.github/workflows/build-cs-steps.yml
22-
with:
23-
version: '0.9.0.${{ github.run_number }}'
24-
platform: 'windows'
25-
secrets: inherit
26-
build-js-windows:
27-
uses: ./.github/workflows/build-js-steps.yml
28-
with:
29-
version: '0.9.0.${{ github.run_number }}'
30-
platform: 'windows'
31-
secrets: inherit
32-
build-rust-windows:
33-
uses: ./.github/workflows/build-rust-steps.yml
34-
with:
35-
platform: 'windows'
36-
run-integration-tests: true
37-
secrets: inherit
38-
39-
build-cs-windows-WinML:
40-
uses: ./.github/workflows/build-cs-steps.yml
41-
with:
42-
version: '0.9.0.${{ github.run_number }}'
43-
platform: 'windows'
44-
useWinML: true
45-
secrets: inherit
46-
build-js-windows-WinML:
47-
uses: ./.github/workflows/build-js-steps.yml
48-
with:
49-
version: '0.9.0.${{ github.run_number }}'
50-
platform: 'windows'
51-
useWinML: true
52-
secrets: inherit
53-
build-rust-windows-WinML:
54-
uses: ./.github/workflows/build-rust-steps.yml
55-
with:
56-
platform: 'windows'
57-
useWinML: true
58-
run-integration-tests: true
59-
secrets: inherit
60-
20+
# Windows build/test moved to .pipelines/foundry-local-packaging.yml and runs in ADO
21+
# MacOS ARM64 not supported in ADO, need to use GitHub Actions
6122
build-cs-macos:
6223
uses: ./.github/workflows/build-cs-steps.yml
6324
with:
64-
version: '0.9.0.${{ github.run_number }}'
25+
version: '1.0.0.${{ github.run_number }}'
6526
platform: 'macos'
6627
secrets: inherit
6728
build-js-macos:
6829
uses: ./.github/workflows/build-js-steps.yml
6930
with:
70-
version: '0.9.0.${{ github.run_number }}'
31+
version: '1.0.0.${{ github.run_number }}'
32+
platform: 'macos'
33+
secrets: inherit
34+
build-python-macos:
35+
uses: ./.github/workflows/build-python-steps.yml
36+
with:
37+
version: '1.0.0.${{ github.run_number }}'
7138
platform: 'macos'
7239
secrets: inherit
7340
build-rust-macos:
7441
uses: ./.github/workflows/build-rust-steps.yml
7542
with:
43+
version: '1.0.0.${{ github.run_number }}'
7644
platform: 'macos'
7745
run-integration-tests: true
7846
secrets: inherit

0 commit comments

Comments
 (0)