Skip to content

Commit

Permalink
[typespec - pr] Validate all specs if any changes to common files (Az…
Browse files Browse the repository at this point in the history
  • Loading branch information
ckairen authored and harryli0108 committed Jul 28, 2023
1 parent 746c515 commit cb02be0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
14 changes: 0 additions & 14 deletions eng/pipelines/typespec-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,6 @@ trigger:
- main
- typespec-next

pr:
branches:
include:
- main
- typespec-next
paths:
include:
- .gitattributes
- .prettierrc.json
- package-lock.json
- package.json
- tsconfig.json
- eng

jobs:
- job: Validate_All_Specs
pool:
Expand Down
7 changes: 2 additions & 5 deletions eng/pipelines/typespec-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ pr:
include:
- main
- typespec-next
paths:
include:
- specification

jobs:
- job: Validate_Changed_Specs
- job: Validate_Impacted_Specs
pool:
name: azsdk-pool-mms-ubuntu-2204-general
vmImage: ubuntu-22.04
Expand All @@ -28,5 +25,5 @@ jobs:
$(Build.SourcesDirectory) `
"origin/${env:SYSTEM_PULLREQUEST_TARGETBRANCH}" `
"${env:SYSTEM_PULLREQUEST_SOURCECOMMITID}"
displayName: Validate Changed Specs
displayName: Validate Impacted Specs
condition: succeededOrFailed()
19 changes: 15 additions & 4 deletions eng/scripts/Get-TypeSpec-Folders.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,31 @@ param (
)

$changedFiles = @()
$allChangedFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse).Directory.FullName | ForEach-Object {[IO.Path]::GetRelativePath($($pwd.path), $_)}
$allChangedFiles = $allChangedFiles -replace '\\', '/'

if ([string]::IsNullOrEmpty($TargetBranch) -or [string]::IsNullOrEmpty($SourceBranch)) {
$changedFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse).Directory.FullName | ForEach-Object {[IO.Path]::GetRelativePath($($pwd.path), $_)}
$changedFiles = $changedFiles -replace '\\', '/'
$changedFiles = $allChangedFiles
}
else {
Write-Host "git -c core.quotepath=off -c i18n.logoutputencoding=utf-8 diff --name-only `"$TargetBranch...$SourceBranch`" -- | Where-Object {`$_.StartsWith('specification')}"
$changedFiles = git -c core.quotepath=off -c i18n.logoutputencoding=utf-8 diff --name-only `"$TargetBranch...$SourceBranch`" -- | Where-Object {$_.StartsWith('specification')}
Write-Host "git -c core.quotepath=off -c i18n.logoutputencoding=utf-8 diff --name-only `"$TargetBranch...$SourceBranch`" --"
$changedFiles = git -c core.quotepath=off -c i18n.logoutputencoding=utf-8 diff --name-only `"$TargetBranch...$SourceBranch`" --
$changedFiles = $changedFiles -replace '\\', '/'

Write-Host "changedFiles:"
foreach ($changedFile in $changedFiles) {
Write-Host " $changedFile"
}
Write-Host

$engFiles = $changedFiles | Where-Object {if ($_) { $_.StartsWith('eng') }}
$repoRootFiles = $changedFiles | Where-Object {$_ -notmatch [Regex]::Escape([IO.Path]::DirectorySeparatorChar)}
if ($engFiles -or $repoRootFiles) {
$changedFiles = $allChangedFiles
}
else {
$changedFiles = $changedFiles | Where-Object {if ($_) { $_.StartsWith('specification') }}
}
}

$typespecFolders = @()
Expand Down

0 comments on commit cb02be0

Please sign in to comment.