Skip to content

Commit 687964c

Browse files
authored
Update CI to publish spector results (Azure#48006)
* temp ci changes to test * add warning when test file didn't exist * invoke coverage script * change mode * replace one more name * hide step in pr * toggle coverage * fix condition * test no spector name condition * add spector name back to ci * update owner of the typespec scripts * fix label
1 parent 0bdf77a commit 687964c

File tree

4 files changed

+33
-13
lines changed

4 files changed

+33
-13
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,3 +1111,6 @@
11111111

11121112
#PRLabel: %CodeGen %Client
11131113
/eng/packages/http-client-csharp/generator/Azure.Generator/ @JoshLove-msft @m-nash @jorgerangel-msft @jsquire @annelo-msft
1114+
1115+
#PRLabel: %CodeGen %Client
1116+
/eng/scripts/typespec/ @JoshLove-msft @m-nash @jorgerangel-msft @jsquire @annelo-msft

eng/packages/http-client-csharp/ci.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
trigger: none
1+
trigger:
2+
branches:
3+
include:
4+
- main
5+
paths:
6+
include:
7+
- eng/packages/http-client-csharp
28
pr:
39
branches:
410
include:
@@ -47,11 +53,11 @@ extends:
4753
ShouldPublish: ${{ parameters.ShouldPublish }}
4854
PublishPublic: ${{ parameters.PublishPublic }}
4955
PublishDependsOnTest: ${{ parameters.PublishPublic }}
50-
5156
ShouldRegenerate: ${{ parameters.ShouldRegenerate }}
5257
RegenerationJobCount: 5
5358
MinimumPerJob: 10
5459
OnlyGenerateTypespec: true
5560
TestMatrix:
5661
All:
5762
TestArguments: -UnitTests -GenerationChecks -Filter .NET
63+
SpectorName: "http-client-csharp"

eng/packages/http-client-csharp/generator/TestProjects/Spector.Tests/Infrastructure/SpectorServer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ internal static IEnumerable<string> GetScenariosPaths()
3838
}
3939
internal static string GetCoverageFilePath()
4040
{
41-
return Path.Combine(GetCoverageDirectory(), "tsp-spector-coverage-csharp-standard.json");
41+
return Path.Combine(GetCoverageDirectory(), "tsp-spector-coverage-azure.json");
4242
}
4343

4444
protected override void Stop(Process process)

eng/scripts/typespec/Test-Emitter.ps1

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,39 +20,50 @@ try {
2020
if ($UnitTests) {
2121
# test the emitter
2222
Invoke-LoggedCommand "npm run prettier" -GroupOutput -ErrorAction Continue
23-
if($LastExitCode)
24-
{
23+
if ($LastExitCode) {
2524
$errors += "Prettier failed"
2625
}
2726

2827
Invoke-LoggedCommand "npm run lint" -GroupOutput -ErrorAction Continue
29-
if($LastExitCode)
30-
{
28+
if ($LastExitCode) {
3129
$errors += "Lint failed"
3230
}
3331

3432
Invoke-LoggedCommand "npm run build:generator" -GroupOutput
3533
Invoke-LoggedCommand "npm run test:generator" -GroupOutput -ErrorAction Continue
36-
if($LastExitCode)
37-
{
34+
if ($LastExitCode) {
3835
$errors += "Genereator tests failed"
3936
}
4037

4138
Invoke-LoggedCommand "npm run build:emitter" -GroupOutput
4239
Invoke-LoggedCommand "npm run test:emitter" -GroupOutput -ErrorAction Continue
43-
if($LastExitCode)
44-
{
40+
if ($LastExitCode) {
4541
$errors += "Emitter tests failed"
4642
}
4743

4844
$testResultsFile = "$packageRoot/generator/Azure.Generator/test/TestResults/debug.trx"
4945

5046
# copy test results to the artifacts directory
51-
if(Test-Path $testResultsFile)
52-
{
47+
if (Test-Path $testResultsFile) {
48+
New-Item -ItemType Directory -Force -Path $testResultsPath | Out-Null
49+
Copy-Item -Path $testResultsFile -Destination $testResultsPath -Force
50+
}
51+
else {
52+
LogWarning "No test results file found at $testResultsFile"
53+
}
54+
55+
Invoke-LoggedCommand "$packageRoot/eng/scripts/Get-Spector-Coverage.ps1" -GroupOutput
56+
57+
$testResultsFile = "$packageRoot/generator/artifacts/coverage/tsp-spector-coverage-azure.json"
58+
59+
# copy test results to the artifacts directory
60+
if (Test-Path $testResultsFile) {
5361
New-Item -ItemType Directory -Force -Path $testResultsPath | Out-Null
5462
Copy-Item -Path $testResultsFile -Destination $testResultsPath -Force
5563
}
64+
else {
65+
LogWarning "No test results file found at $testResultsFile"
66+
}
5667
}
5768

5869
if ($GenerationChecks) {

0 commit comments

Comments
 (0)