Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
Browse files Browse the repository at this point in the history
… harshan/migrate-to-esm/test-utils
  • Loading branch information
HarshaNalluru committed Mar 19, 2024
2 parents cf6e783 + 600c5de commit c72ed28
Show file tree
Hide file tree
Showing 2,002 changed files with 71,478 additions and 57,679 deletions.
499 changes: 207 additions & 292 deletions .vscode/cspell.json

Large diffs are not rendered by default.

34 changes: 20 additions & 14 deletions common/tools/dev-tool/test/customization/classes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,9 @@ class MyClass {}
parameters: [{ name: "foo", type: "string" }],
});
augmentConstructor(customConstructor, originalClass!);

assert.lengthOf(originalFile.getClass("MyClass")?.getConstructors()!, 1);
const constructorDeclarations = originalFile.getClass("MyClass")?.getConstructors()
assert.isDefined(constructorDeclarations);
if (constructorDeclarations) assert.lengthOf(constructorDeclarations, 1);
});

it("should replace the original constructor with the custom constructor", () => {
Expand All @@ -249,10 +250,13 @@ class MyClass {}
});
augmentConstructor(customConstructor, originalClass!);

assert.lengthOf(originalFile.getClass("MyClass")?.getConstructors()!, 1);
assert.isDefined(originalFile.getClass("MyClass")?.getConstructors()[0].getParameter("foo"));
const constructorDeclarations = originalFile.getClass("MyClass")?.getConstructors()
assert.isDefined(constructorDeclarations);
if (!constructorDeclarations) assert.fail("constructorDeclarations is undefined")
assert.lengthOf(constructorDeclarations, 1);
assert.isDefined(constructorDeclarations[0].getParameter("foo"));
assert.isUndefined(
originalFile.getClass("MyClass")?.getConstructors()[0].getParameter("bar"),
constructorDeclarations[0].getParameter("bar"),
);
});

Expand Down Expand Up @@ -285,32 +289,34 @@ class MyClass {}

augmentConstructor(customConstructor, originalClass!);

assert.lengthOf(originalFile.getClass("MyClass")?.getConstructors()!, 1);
assert.equal(originalFile.getClass("MyClass")?.getConstructors()[0].getJsDocs().length, 1);
const constructorDeclarations = originalFile.getClass("MyClass")?.getConstructors()
if (!constructorDeclarations) assert.fail("constructorDeclarations is undefined")
assert.lengthOf(constructorDeclarations, 1);
assert.equal(constructorDeclarations[0].getJsDocs().length, 1);
assert.equal(
originalFile.getClass("MyClass")?.getConstructors()[0].getJsDocs()[0].getDescription(),
constructorDeclarations[0].getJsDocs()[0].getDescription(),
"Customized docs",
);
assert.isDefined(
originalFile.getClass("MyClass")?.getConstructors()[0].getParameter("endpoint"),
constructorDeclarations[0].getParameter("endpoint"),
);
assert.isUndefined(
originalFile.getClass("MyClass")?.getConstructors()[0].getParameter("baseUrl"),
constructorDeclarations[0].getParameter("baseUrl"),
);
assert.include(
originalFile.getClass("MyClass")?.getConstructors()[0].getText(),
constructorDeclarations[0].getText(),
"console.log('custom');",
);
assert.include(
originalFile.getClass("MyClass")?.getConstructors()[0].getText(),
constructorDeclarations[0].getText(),
"console.log('original');",
);
assert.notInclude(
originalFile.getClass("MyClass")?.getConstructors()[0].getText(),
constructorDeclarations[0].getText(),
"// @azsdk-constructor-end",
);
assert.include(
originalFile.getClass("MyClass")?.getConstructors()[0].getText(),
constructorDeclarations[0].getText(),
"console.log('finish custom');",
);
});
Expand Down
8 changes: 6 additions & 2 deletions common/tools/dev-tool/test/customization/interfaces.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ describe("Interfaces", () => {
augmentInterface(customInterface, originalInterface, originalFile);

assert.isDefined(originalFile.getInterface("myInterface"));
assert.lengthOf(originalFile.getInterface("myInterface")?.getProperties()!, 2);
const props = originalFile.getInterface("myInterface")?.getProperties()
if (!props) assert.fail("myInterface#getProperties() is undefined")
assert.lengthOf(props, 2);
assert.isDefined(originalFile.getInterface("myInterface")?.getProperty("foo"));
assert.equal(
originalFile.getInterface("myInterface")?.getProperty("foo")?.getType().getText(),
Expand Down Expand Up @@ -67,7 +69,9 @@ describe("Interfaces", () => {
augmentInterface(customInterface, originalInterface, originalFile);

assert.isDefined(originalFile.getInterface("myInterface"));
assert.lengthOf(originalFile.getInterface("myInterface")?.getProperties()!, 2);
const props = originalFile.getInterface("myInterface")?.getProperties();
if (!props) assert.fail("myInterface#getProperties() is undefined")
assert.lengthOf(props, 2);
assert.isDefined(originalFile.getInterface("myInterface")?.getProperty("foo"));
assert.isDefined(originalFile.getInterface("myInterface")?.getProperty("baz"));

Expand Down
2 changes: 1 addition & 1 deletion eng/common/pipelines/templates/steps/bypass-local-dns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ steps:
condition: |
and(
succeededOrFailed(),
contains(variables['OSVmImage'], 'ubuntu'),
or(contains(variables['OSVmImage'], 'ubuntu'),contains(variables['OSVmImage'], 'linux')),
eq(variables['Container'], '')
)
19 changes: 14 additions & 5 deletions eng/common/pipelines/templates/steps/create-apireview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,37 @@ parameters:
ArtifactPath: $(Build.ArtifactStagingDirectory)
Artifacts: []
ConfigFileDir: $(Build.ArtifactStagingDirectory)/PackageInfo
MarkPackageAsShipped: false
GenerateApiReviewForManualOnly: false
ArtifactName: 'packages'
PackageName: ''

steps:
# ideally this should be done as initial step of a job in caller template
# We can remove this step later once it is added in caller
- template: /eng/common/pipelines/templates/steps/set-default-branch.yml

- ${{ each artifact in parameters.Artifacts }}:
# Automatic API review is generated for a package when pipeline runs irrespective of how pipeline gets triggered.
# Below condition ensures that API review is generated only for manual pipeline runs when flag GenerateApiReviewForManualOnly is set to true.
- ${{ if or(ne(parameters.GenerateApiReviewForManualOnly, true), eq(variables['Build.Reason'], 'Manual')) }}:
- task: Powershell@2
inputs:
filePath: $(Build.SourcesDirectory)/eng/common/scripts/Create-APIReview.ps1
arguments: >
-ArtifactList ('${{ convertToJson(parameters.Artifacts) }}' | ConvertFrom-Json | Select-Object Name)
-ArtifactPath ${{parameters.ArtifactPath}}
-APIViewUri $(azuresdk-apiview-uri)
-ArtifactName ${{ parameters.ArtifactName }}
-APIKey $(azuresdk-apiview-apikey)
-APILabel "Auto Review - $(Build.SourceVersion)"
-PackageName ${{artifact.name}}
-PackageName '${{parameters.PackageName}}'
-SourceBranch $(Build.SourceBranchName)
-DefaultBranch $(DefaultBranch)
-ConfigFileDir '${{parameters.ConfigFileDir}}'
-BuildId $(Build.BuildId)
-RepoName '$(Build.Repository.Name)'
-MarkPackageAsShipped $${{parameters.MarkPackageAsShipped}}
pwsh: true
workingDirectory: $(Pipeline.Workspace)
displayName: Create API Review for ${{ artifact.name}}
displayName: Create API Review
condition: >-
and(
succeededOrFailed(),
Expand Down
23 changes: 6 additions & 17 deletions eng/common/pipelines/templates/steps/git-push-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,14 @@ parameters:
SkipCheckingForChanges: false

steps:
- pwsh: |
echo "git add -A"
git add -A
echo "git diff --name-status --cached --exit-code"
git diff --name-status --cached --exit-code
if ($LastExitCode -ne 0) {
echo "##vso[task.setvariable variable=HasChanges]$true"
echo "Changes detected so setting HasChanges=true"
}
else {
echo "##vso[task.setvariable variable=HasChanges]$false"
echo "No changes so skipping code push"
}
- task: PowerShell@2
displayName: Check for changes
condition: and(succeeded(), eq(${{ parameters.SkipCheckingForChanges }}, false))
workingDirectory: ${{ parameters.WorkingDirectory }}
ignoreLASTEXITCODE: true
inputs:
pwsh: true
workingDirectory: ${{ parameters.WorkingDirectory }}
filePath: ${{ parameters.ScriptDirectory }}/check-for-git-changes.ps1
ignoreLASTEXITCODE: true

- pwsh: |
# Remove the repo owner from the front of the repo name if it exists there
Expand Down
Loading

0 comments on commit c72ed28

Please sign in to comment.