-
Notifications
You must be signed in to change notification settings - Fork 240
[sdk_v2] migrate c# and js sdk_v2 implementation and build pipeline to public GH repo #389
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
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
ec7124c
init
4dedcdb
Merge remote-tracking branch 'origin' into prathikrao/migrate-cs-sdk-…
69178df
stages to steps
b44aacd
workflows at root
321e775
rmv env
bf460ea
workflow dispatch
6e5317e
pwd
20287cc
Potential fix for code scanning alert no. 4: Workflow does not contai…
prathikr 3f5a792
Potential fix for code scanning alert no. 6: Workflow does not contai…
prathikr c47e530
config
8d36cd0
Merge branch 'prathikrao/migrate-cs-sdk-v2-to-public-gh' of https://g…
1080afa
Neutron
de6014b
secrets secrets
ee7cc75
configfile
efe843f
nuget.config
cb0ae8d
configfile not for restore
7c26892
update source
2918f97
add back configfile for restore
f34aaf4
one line
0d9f202
gh docs
500cd4b
comment
08a69bf
nuget.config again
b7fdc96
..
29c8767
diff pat
c38fd17
checkout properly
2311686
no working dir
7e29039
clone loc
45832b8
naming
ee3ee47
init
c599f70
proper npm auth
3f52cc3
remove npm auth
e8bf299
add nuget auth
5e89930
0.9.0
55e4425
scott
9408ef4
scott scott
271b395
nuget cmd
bf28665
cs test fix
65b63dc
readme
prathikr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| name: Build C# SDK | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| version: | ||
| required: true | ||
| type: string | ||
| useWinML: | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| buildConfiguration: | ||
| required: false | ||
| type: string | ||
| default: 'Debug' # or 'Release' | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: windows-latest | ||
| env: | ||
| buildConfiguration: 'Debug' | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| clean: true | ||
|
|
||
| # adapted from https://github.com/actions/setup-dotnet?tab=readme-ov-file#azure-artifacts | ||
| # saves auth credentials to ../nuget.config | ||
| - name: Setup .NET 9 SDK | ||
| uses: actions/setup-dotnet@v5 | ||
| with: | ||
| dotnet-version: '9.0.x' | ||
| source-url: https://pkgs.dev.azure.com/microsoft/windows.ai.toolkit/_packaging/Neutron/nuget/v3/index.json | ||
| env: | ||
| NUGET_AUTH_TOKEN: ${{ secrets.AZURE_DEVOPS_PAT }} | ||
|
|
||
| - name: Restore dependencies | ||
| run: | | ||
| dotnet restore sdk_v2\cs\src\Microsoft.AI.Foundry.Local.csproj /p:UseWinML=${{ inputs.useWinML }} --configfile ../nuget.config | ||
|
|
||
| - name: Build solution | ||
| run: | | ||
| dotnet build sdk_v2\cs\src\Microsoft.AI.Foundry.Local.csproj --configfile ../nuget.config --no-restore --configuration ${{ inputs.buildConfiguration }} /p:UseWinML=${{ inputs.useWinML }} | ||
|
|
||
| # need to use direct git commands to clone from Azure DevOps instead of actions/checkout | ||
| - name: Checkout test-data-shared from Azure DevOps | ||
| shell: pwsh | ||
| working-directory: ${{ github.workspace }}\.. | ||
| run: | | ||
| $pat = "${{ secrets.AZURE_DEVOPS_PAT }}" | ||
| $encodedPat = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$pat")) | ||
|
|
||
| # Configure git to use the PAT | ||
| git config --global http.https://dev.azure.com.extraheader "AUTHORIZATION: Basic $encodedPat" | ||
|
|
||
| # Clone with LFS to parent directory | ||
| git lfs install | ||
| git clone --depth 1 https://dev.azure.com/microsoft/windows.ai.toolkit/_git/test-data-shared test-data-shared | ||
|
|
||
| Write-Host "Clone completed successfully to ${{ github.workspace }}\..\test-data-shared" | ||
|
|
||
| - name: Checkout specific commit in test-data-shared | ||
| shell: pwsh | ||
| working-directory: ${{ github.workspace }}\..\test-data-shared | ||
| run: | | ||
| Write-Host "Current directory: $(Get-Location)" | ||
| git checkout 231f820fe285145b7ea4a449b112c1228ce66a41 | ||
| if ($LASTEXITCODE -ne 0) { | ||
| Write-Error "Git checkout failed." | ||
| exit 1 | ||
| } | ||
| Write-Host "`nDirectory contents:" | ||
| Get-ChildItem -Recurse -Depth 2 | ForEach-Object { Write-Host " $($_.FullName)" } | ||
|
|
||
| - name: Run Foundry Local Core tests | ||
| run: | | ||
| dotnet test sdk_v2\cs\test\FoundryLocal.Tests\Microsoft.AI.Foundry.Local.Tests.csproj --verbosity normal /p:UseWinML=${{ inputs.useWinML }} | ||
|
|
||
| - name: Pack NuGet package | ||
| shell: pwsh | ||
| run: | | ||
| $projectPath = "sdk_v2\cs\src\Microsoft.AI.Foundry.Local.csproj" | ||
| $outputDir = "sdk_v2\cs\bin" | ||
| $version = "${{ inputs.version }}" | ||
| $config = "${{ inputs.buildConfiguration }}" | ||
| $useWinML = "${{ inputs.useWinML }}" | ||
|
|
||
| Write-Host "Packing project: $projectPath" | ||
| Write-Host "Output directory: $outputDir" | ||
| Write-Host "Version: $version" | ||
| Write-Host "Configuration: $config" | ||
| Write-Host "UseWinML: $useWinML" | ||
|
|
||
| & dotnet pack $projectPath --no-build --configuration $config --output $outputDir /p:PackageVersion=$version /p:UseWinML=$useWinML /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg --verbosity normal | ||
|
|
||
| if ($LASTEXITCODE -ne 0) { | ||
| Write-Error "dotnet pack failed with exit code $LASTEXITCODE" | ||
| exit $LASTEXITCODE | ||
| } | ||
|
|
||
| Write-Host "Pack completed successfully" | ||
| Write-Host "Generated packages:" | ||
| Get-ChildItem -Path $outputDir -Filter "*.nupkg" | ForEach-Object { Write-Host " $($_.Name)" } | ||
| Get-ChildItem -Path $outputDir -Filter "*.snupkg" | ForEach-Object { Write-Host " $($_.Name)" } | ||
|
|
||
| - name: Upload NuGet packages | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: cs-sdk | ||
| path: | | ||
| sdk_v2\cs\bin\*.nupkg | ||
| sdk_v2\cs\bin\*.snupkg | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| name: Build JS SDK | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| version: | ||
| required: true | ||
| type: string | ||
| useWinML: | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: windows-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| clean: true | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20.x' | ||
|
|
||
| # needed to download Foundry Local Core from Azure Artifacts | ||
| - name: Setup .NET SDK for NuGet authentication | ||
| uses: actions/setup-dotnet@v5 | ||
| with: | ||
| dotnet-version: '9.0.x' | ||
| source-url: https://pkgs.dev.azure.com/microsoft/windows.ai.toolkit/_packaging/Neutron/nuget/v3/index.json | ||
| env: | ||
| NUGET_AUTH_TOKEN: ${{ secrets.AZURE_DEVOPS_PAT }} | ||
|
|
||
| - name: Format version for JS | ||
| shell: pwsh | ||
| run: | | ||
| # Release: 0.9.0.41 -> 0.9.0-41 | ||
| $version = "${{ inputs.version }}" | ||
| $versionParts = $version -split '\.' | ||
| $baseVersion = ($versionParts[0..2]) -join '.' | ||
| $buildNumber = $versionParts[3] | ||
| $version = "$baseVersion-$buildNumber" | ||
| Write-Host "Modified version for JS: $version" | ||
| Write-Host "ProjectVersion=$version" >> $env:GITHUB_ENV | ||
|
|
||
| # need to use direct git commands to clone from Azure DevOps instead of actions/checkout | ||
| - name: Checkout test-data-shared from Azure DevOps | ||
| shell: pwsh | ||
| working-directory: ${{ github.workspace }}\.. | ||
| run: | | ||
| $pat = "${{ secrets.AZURE_DEVOPS_PAT }}" | ||
| $encodedPat = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$pat")) | ||
|
|
||
| # Configure git to use the PAT | ||
| git config --global http.https://dev.azure.com.extraheader "AUTHORIZATION: Basic $encodedPat" | ||
|
|
||
| # Clone with LFS to parent directory | ||
| git lfs install | ||
| git clone --depth 1 https://dev.azure.com/microsoft/windows.ai.toolkit/_git/test-data-shared test-data-shared | ||
|
|
||
| Write-Host "Clone completed successfully to ${{ github.workspace }}\..\test-data-shared" | ||
|
|
||
| - name: Checkout specific commit in test-data-shared | ||
| shell: pwsh | ||
| working-directory: ${{ github.workspace }}\..\test-data-shared | ||
| run: | | ||
| Write-Host "Current directory: $(Get-Location)" | ||
| git checkout 231f820fe285145b7ea4a449b112c1228ce66a41 | ||
| if ($LASTEXITCODE -ne 0) { | ||
| Write-Error "Git checkout failed." | ||
| exit 1 | ||
| } | ||
| Write-Host "`nDirectory contents:" | ||
| Get-ChildItem -Recurse -Depth 2 | ForEach-Object { Write-Host " $($_.FullName)" } | ||
|
|
||
|
|
||
| - name: npm install (WinML) | ||
| if: ${{ inputs.useWinML == true }} | ||
| working-directory: sdk_v2\js | ||
| run: npm install --winml | ||
|
|
||
| - name: npm install (Standard) | ||
| if: ${{ inputs.useWinML == false }} | ||
| working-directory: sdk_v2\js | ||
| run: npm install | ||
|
|
||
| - name: Set package version | ||
| working-directory: sdk_v2\js | ||
| run: npm version ${{ env.ProjectVersion }} --no-git-tag-version --allow-same-version | ||
|
|
||
| - name: Run tests | ||
| working-directory: sdk_v2\js | ||
| run: npm test | ||
|
|
||
| - name: Build package | ||
| working-directory: sdk_v2\js | ||
| run: npm run build | ||
|
|
||
| - name: Pack npm package | ||
| working-directory: sdk_v2\js | ||
| run: npm pack | ||
|
|
||
| - name: Rename WinML artifact | ||
| if: ${{ inputs.useWinML == true }} | ||
| shell: pwsh | ||
| working-directory: sdk_v2\js | ||
| run: | | ||
| $tgz = Get-ChildItem *.tgz | Select-Object -First 1 | ||
| if ($tgz) { | ||
| $newName = $tgz.Name -replace '^foundry-local-sdk-', 'foundry-local-sdk-winml-' | ||
| Rename-Item -Path $tgz.FullName -NewName $newName | ||
| Write-Host "Renamed $($tgz.Name) to $newName" | ||
| } | ||
|
|
||
| - name: Upload npm packages | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: js-sdk | ||
| path: sdk_v2\js\*.tgz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| name: SDK V2 Build | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - 'sdk_v2/**' | ||
| - '.github/workflows/sdk_v2/**' | ||
| push: | ||
| paths: | ||
| - 'sdk_v2/**' | ||
| - '.github/workflows/sdk_v2/**' | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build-cs: | ||
| uses: ./.github/workflows/build-cs-steps.yml | ||
| with: | ||
| version: '0.9.0.${{ github.run_number }}' | ||
| secrets: inherit | ||
| build-js: | ||
| uses: ./.github/workflows/build-js-steps.yml | ||
| with: | ||
| version: '0.9.0.${{ github.run_number }}' | ||
| secrets: inherit |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ __pycache__/ | |
|
|
||
| # node | ||
| node_modules/ | ||
| package-lock.json | ||
|
|
||
| # Rust build targets | ||
| target/ | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, secrets do not work very well for external contributions. External contributions come in mostly from forks of the repository. The forked repository does not inherit the secrets of the parent repository. And as a result, PRs created from forks will fail to run.
Let's not block this PR. But we need to think of another way to address this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, let me think on it