-
Notifications
You must be signed in to change notification settings - Fork 954
feat: add dependency check step to build pipeline #16265
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
8 commits
Select commit
Hold shift + click to select a range
a33991b
feat: add dependency check step to build pipeline
tadelesh 6f8a7ff
fix: move depency check from build-test to analyze
tadelesh fa67dc1
fix: remove all -x flag in go build to show clear error log
tadelesh a93b1cc
fix: change param path and simplify implementation
tadelesh 9743fba
fix: remove unnecessary ignore package
tadelesh ac890fc
fix: use retract info to judge whether a package is deprecated
tadelesh 5c63780
fix: change path compare to more simple way
tadelesh 461b0e1
fix: some script refine
tadelesh 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
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,78 @@ | ||
| Param( | ||
| [string] $PackageDirectory | ||
| ) | ||
|
|
||
| . (Join-Path $PSScriptRoot .. common scripts common.ps1) | ||
|
|
||
| $sdks = Get-AllPackageInfoFromRepo | ||
|
|
||
| ## Create depcheck module | ||
| $workingPath = Join-Path $RepoRoot "sdk" "depcheck" | ||
| if (Test-Path -Path $workingPath) | ||
| { | ||
| Remove-Item -Path $workingPath -Recurse -Force | ||
| } | ||
| New-Item -ItemType Directory -Force -Path $workingPath | ||
|
|
||
| ## Init go mod | ||
| Set-Location $workingPath | ||
| Write-Host "##[command]Executing go mod init in " $workingPath | ||
| go mod init github.com/Azure/azure-sdk-for-go/sdk/depcheck | ||
| if ($LASTEXITCODE) { exit $LASTEXITCODE } | ||
|
|
||
| # Find whether latest version is in the `retract` section in `go.mod` to judge whether the package is temporarily deprecated. | ||
| function IsPackageDeprecated($sdk) | ||
| { | ||
| $RETRACT_SECTION_REGEX = "retract\s*((?<retract>(.|\s)*))" | ||
| $modContent = Get-Content (Join-Path $sdk.DirectoryPath 'go.mod') -Raw | ||
| if ($modContent -match $RETRACT_SECTION_REGEX) { | ||
| return $($matches["retract"]).Indexof($sdk.Version) -ne -1 | ||
| } | ||
| return $false | ||
| } | ||
|
|
||
| # Get all existed packages | ||
| $packagesImport = "" | ||
| foreach ($sdk in $sdks) | ||
| { | ||
| if ($sdk.Name -like "*internal*" -or (IsPackageDeprecated $sdk)) | ||
| { | ||
| continue | ||
| } | ||
| if ($sdk.Name -eq $PackageDirectory) | ||
| { | ||
| ## Add replace for new package | ||
| $modPath = Join-Path $RepoRoot "sdk" "depcheck" "go.mod" | ||
| Add-Content $modPath "`nreplace github.com/Azure/azure-sdk-for-go/$($sdk.Name) => ../../$($sdk.Name)`n" | ||
weshaggard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| $packagesImport = $packagesImport + "`t_ `"github.com/Azure/azure-sdk-for-go/$($sdk.Name)`"`n" | ||
| } | ||
|
|
||
| ## Add main.go | ||
| $mainPath = Join-Path $RepoRoot "sdk" "depcheck" "main.go" | ||
| New-Item -Path $mainPath -ItemType File -Value '' -Force | ||
| Add-Content $mainPath "package main | ||
|
|
||
| import ( | ||
| $packagesImport | ||
| ) | ||
|
|
||
| func main() { | ||
| } | ||
| " | ||
|
|
||
| ## Run go mod tidy | ||
| Write-Host "##[command]Executing go mod tidy in " $workingPath | ||
| go mod tidy | ||
| if ($LASTEXITCODE) { exit $LASTEXITCODE } | ||
|
|
||
| ## Run go build and go vet | ||
| Write-Host "##[command]Executing go build -v ./... in " $workingPath | ||
| go build -v ./... | ||
| if ($LASTEXITCODE) { exit $LASTEXITCODE } | ||
|
|
||
| Write-Host "##[command]Executing go vet ./... in " $workingPath | ||
| go vet ./... | ||
| if ($LASTEXITCODE) { exit $LASTEXITCODE } | ||
|
|
||
| Write-Host "Checking dependency has completed. All packages are compatible." | ||
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.