Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions eng/common/scripts/TypeSpec-Project-Sync.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ function AddSparseCheckoutPath([string]$subDirectory) {

function CopySpecToProjectIfNeeded([string]$specCloneRoot, [string]$mainSpecDir, [string]$dest, [string[]]$specAdditionalSubDirectories) {
$source = "$specCloneRoot/$mainSpecDir"
Copy-Item -Path $source -Destination $dest -Recurse -Force
Write-Host "Copying spec from $source to $dest"
# $mainSpecDir is the PR folder, we just need to copy its subfolders which include the typespec project folder
Get-ChildItem –Path "$source" -Exclude @("data-plane", "resource-manager")|

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can also sync these folders there isn't any real value in excluding them.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @weshaggard data-plane and resource-manager is useless for generating SDK from typespec, and it is huge, so we skip to copy them to our template folder.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know they have specs but are they really that big? Do we have any real data that says they make it take too much time? It just feels like if we can eliminate this special case it might make things easier.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we decide to exclude them after all, I think adding a comment explaining why is that would be worthwhile. Would be nice if it would say how big is the slowdown.

Foreach-Object {
Copy-Item -Path $_.FullName -Destination $dest -Recurse -Force
}

foreach ($additionalDir in $specAdditionalSubDirectories) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we are copying the entire rp folder do we even need additional directories any longer?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. We will copying entire rp folder. The dependency usually be defined via import *** in a .tsp file, now we have no way to identify what directories are needed for this typespec project, so the possible solution (maybe workaround now) is to sync down the entire rp folder.

$source = "$specCloneRoot/$additionalDir"
Expand Down Expand Up @@ -93,7 +97,15 @@ $configuration = Get-Content -Path $typespecConfigurationFile -Raw | ConvertFrom
$pieces = $typespecConfigurationFile.Path.Replace("\","/").Split("/")
$projectName = $pieces[$pieces.Count - 2]

$specSubDirectory = $configuration["directory"]
# clone the whole RP directory which is the parent of $configuration["directory"]
if ($configuration["directory"] -match "^[^/\\]+[\\/]+[^/\\]+")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What kind of pattern is this supposed to match?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just walk up the parents until we hit the "specification" folder?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It will get the top-level directory under specification.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regex doesn't say to me that it is looking for specification folder. What do we expect the values of $configuraion["directory"] to be? Are they relative paths from the specification folder? or from the root of the repo? If they are from the root I would expect this regex to have the work "specification" in it somewhere.

{
$specSubDirectory = $Matches[0]
}
else
{
throw "The directory in $typespecConfigurationFile is not expected"
}

if ( $configuration["repo"] -and $configuration["commit"]) {
$specCloneDir = GetSpecCloneDir $projectName
Expand Down