-
Notifications
You must be signed in to change notification settings - Fork 267
Build and Release Pipelines for Finetuning CLI #6449
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
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,142 @@ | ||
| param( | ||
| [string] $Version = (Get-Content "$PSScriptRoot/version.txt"), | ||
| [string] $SourceVersion = (git rev-parse HEAD), | ||
| [switch] $CodeCoverageEnabled, | ||
| [switch] $BuildRecordMode, | ||
| [string] $MSYS2Shell, # path to msys2_shell.cmd | ||
| [string] $OutputFileName | ||
| ) | ||
|
|
||
| # Remove any previously built binaries | ||
| go clean | ||
|
|
||
| if ($LASTEXITCODE) { | ||
| Write-Host "Error running go clean" | ||
| exit $LASTEXITCODE | ||
| } | ||
|
|
||
| # Run `go help build` to obtain detailed information about `go build` flags. | ||
| $buildFlags = @( | ||
| # remove all file system paths from the resulting executable. | ||
| # Instead of absolute file system paths, the recorded file names | ||
| # will begin either a module path@version (when using modules), | ||
| # or a plain import path (when using the standard library, or GOPATH). | ||
| "-trimpath", | ||
|
|
||
| # Use buildmode=pie (Position Independent Executable) for enhanced security across platforms | ||
| # against memory corruption exploits across all major platforms. | ||
| # | ||
| # On Windows, the -buildmode=pie flag enables Address Space Layout | ||
| # Randomization (ASLR) and automatically sets DYNAMICBASE and HIGH-ENTROPY-VA flags in the PE header. | ||
| "-buildmode=pie" | ||
| ) | ||
|
|
||
| if ($CodeCoverageEnabled) { | ||
| $buildFlags += "-cover" | ||
| } | ||
|
|
||
| # Build constraint tags | ||
| # cfi: Enable Control Flow Integrity (CFI), | ||
| # cfg: Enable Control Flow Guard (CFG), | ||
| # osusergo: Optimize for OS user accounts | ||
| $tagsFlag = "-tags=cfi,cfg,osusergo" | ||
|
|
||
| # ld linker flags | ||
| # -s: Omit symbol table and debug information | ||
| # -w: Omit DWARF symbol table | ||
| # -X: Set variable at link time. Used to set the version in source. | ||
|
|
||
| $ldFlag = "-ldflags=-s -w -X 'azure.ai.finetune/internal/cmd.Version=$Version' -X 'azure.ai.finetune/internal/cmd.Commit=$SourceVersion' -X 'azure.ai.finetune/internal/cmd.BuildDate=$(Get-Date -Format o)' " | ||
|
|
||
| if ($IsWindows) { | ||
| $msg = "Building for Windows" | ||
| Write-Host $msg | ||
| } | ||
| elseif ($IsLinux) { | ||
| Write-Host "Building for linux" | ||
| } | ||
| elseif ($IsMacOS) { | ||
| Write-Host "Building for macOS" | ||
| } | ||
|
|
||
| # Add output file flag based on specified output file name | ||
| $outputFlag = "-o=$OutputFileName" | ||
|
|
||
| # collect flags | ||
| $buildFlags += @( | ||
| $tagsFlag, | ||
| $ldFlag, | ||
| $outputFlag | ||
| ) | ||
|
|
||
| function PrintFlags() { | ||
| param( | ||
| [string] $flags | ||
| ) | ||
|
|
||
| # Attempt to format flags so that they are easily copy-pastable to be ran inside pwsh | ||
| $i = 0 | ||
| foreach ($buildFlag in $buildFlags) { | ||
| # If the flag has a value, wrap it in quotes. This is not required when invoking directly below, | ||
| # but when repasted into a shell for execution, the quotes can help escape special characters such as ','. | ||
| $argWithValue = $buildFlag.Split('=', 2) | ||
| if ($argWithValue.Length -eq 2 -and !$argWithValue[1].StartsWith("`"")) { | ||
| $buildFlag = "$($argWithValue[0])=`"$($argWithValue[1])`"" | ||
| } | ||
|
|
||
| # Write each flag on a newline with '`' acting as the multiline separator | ||
| if ($i -eq $buildFlags.Length - 1) { | ||
| Write-Host " $buildFlag" | ||
| } | ||
| else { | ||
| Write-Host " $buildFlag ``" | ||
| } | ||
| $i++ | ||
| } | ||
| } | ||
|
|
||
| $oldGOEXPERIMENT = $env:GOEXPERIMENT | ||
| # Enable the loopvar experiment, which makes the loop variaible for go loops like `range` behave as most folks would expect. | ||
| # the go team is exploring making this default in the future, and we'd like to opt into the behavior now. | ||
| $env:GOEXPERIMENT = "loopvar" | ||
|
|
||
| try { | ||
| Write-Host "Running: go build ``" | ||
| PrintFlags -flags $buildFlags | ||
| go build @buildFlags | ||
| if ($LASTEXITCODE) { | ||
| Write-Host "Error running go build" | ||
| exit $LASTEXITCODE | ||
| } | ||
|
|
||
| if ($BuildRecordMode) { | ||
| # Modify build tags to include record | ||
| $recordTagPatched = $false | ||
| for ($i = 0; $i -lt $buildFlags.Length; $i++) { | ||
| if ($buildFlags[$i].StartsWith("-tags=")) { | ||
| $buildFlags[$i] += ",record" | ||
| $recordTagPatched = $true | ||
| } | ||
| } | ||
| if (-not $recordTagPatched) { | ||
| $buildFlags += "-tags=record" | ||
| } | ||
| # Add output file flag for record mode | ||
| $recordOutput = "-o=$OutputFileName-record" | ||
| if ($IsWindows) { $recordOutput += ".exe" } | ||
| $buildFlags += $recordOutput | ||
|
|
||
| Write-Host "Running: go build (record) ``" | ||
| PrintFlags -flags $buildFlags | ||
| go build @buildFlags | ||
| if ($LASTEXITCODE) { | ||
| Write-Host "Error running go build (record)" | ||
| exit $LASTEXITCODE | ||
| } | ||
| } | ||
|
|
||
| Write-Host "go build succeeded" | ||
| } | ||
| finally { | ||
| $env:GOEXPERIMENT = $oldGOEXPERIMENT | ||
| } |
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 @@ | ||
| 0.0.6-preview |
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,32 @@ | ||
| # Continuous deployment trigger | ||
| trigger: | ||
| branches: | ||
| include: | ||
| - main | ||
| paths: | ||
| include: | ||
| - go.mod | ||
| - cli/azd/extensions/azure.ai.finetune | ||
| - eng/pipelines/release-azd-extension.yml | ||
| - /eng/pipelines/templates/jobs/build-azd-extension.yml | ||
| - /eng/pipelines/templates/jobs/cross-build-azd-extension.yml | ||
| - /eng/pipelines/templates/variables/image.yml | ||
|
|
||
| pr: | ||
| paths: | ||
| include: | ||
| - cli/azd/extensions/azure.ai.finetune | ||
| - eng/pipelines/release-azd-extension.yml | ||
| - eng/pipelines/templates/steps/publish-cli.yml | ||
| exclude: | ||
| - cli/azd/docs/** | ||
|
|
||
| extends: | ||
| template: /eng/pipelines/templates/stages/1es-redirect.yml | ||
| parameters: | ||
| stages: | ||
| - template: /eng/pipelines/templates/stages/release-azd-extension.yml | ||
| parameters: | ||
| AzdExtensionId: azure.ai.finetune | ||
| SanitizedExtensionId: azure-ai-finetune | ||
| AzdExtensionDirectory: cli/azd/extensions/azure.ai.finetune | ||
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.
Do we want to include the feature branch
Model-Customization-Devhere too?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.
I think we can wait for all the changes to go into main branch.