Skip to content

Commit 79ba9a0

Browse files
authored
Code Quality Reports CI Template Follow-Up (Azure#26221)
Code Quality Reports CI Template Follow-Up
1 parent 3c75676 commit 79ba9a0

File tree

15 files changed

+77
-49
lines changed

15 files changed

+77
-49
lines changed

eng/code-quality-reports/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ trigger:
99
paths:
1010
include:
1111
- eng/code-quality-reports/
12+
- eng/pipelines/code-quality-reports.yml
1213

1314
pr:
1415
branches:
@@ -20,6 +21,7 @@ pr:
2021
paths:
2122
include:
2223
- eng/code-quality-reports/
24+
- eng/pipelines/code-quality-reports.yml
2325

2426
extends:
2527
template: /eng/pipelines/code-quality-reports.yml

eng/pipelines/code-quality-reports.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- '!sdk/**/test-recordings'
2121
- '!sdk/**/session-records'
2222

23-
- template: /eng/pipelines/steps/install-reporting-tools.yml
23+
- template: /eng/pipelines/templates/steps/install-reporting-tools.yml
2424

2525
- task: UsePythonVersion@0
2626
displayName: 'Use Python 3.6'
@@ -39,7 +39,7 @@ jobs:
3939
scriptPath: 'eng/versioning/update_versions.py'
4040
arguments: '--update-type library --build-type client --sr'
4141

42-
- template: /eng/pipelines/steps/generate-project-list.yml
42+
- template: /eng/pipelines/templates/steps/generate-project-list.yml
4343
parameters:
4444
Artifacts:
4545
- name: azure-core
@@ -56,7 +56,7 @@ jobs:
5656
displayName: 'Generate directories variable for sparse checkout'
5757
inputs:
5858
scriptPath: 'eng/scripts/generate_from_source_pom.py'
59-
arguments: '--set-pipeline-variable CheckoutDirectories --project-list $(ProjectList)'
59+
arguments: '--set-pipeline-variable CheckoutDirectories --set-skip-linting-projects SkipLintingProjects --project-list $(ProjectList)'
6060
workingDirectory: '$(System.DefaultWorkingDirectory)'
6161

6262
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
@@ -69,7 +69,7 @@ jobs:
6969
inputs:
7070
mavenPomFile: ClientFromSourcePom.xml
7171
goals: 'install'
72-
options: '$(DefaultOptions) -T 2C -DskipTests -Dgpg.skip -DtrimStackTrace=false -Dmaven.javadoc.skip=true -Dcodesnippet.skip=true -Dcheckstyle.skip -Dspotbugs.skip -Drevapi.skip=true -Djacoco.skip=true'
72+
options: '$(DefaultOptions) -T 2C -DskipTests -Dgpg.skip -DtrimStackTrace=false -Dmaven.javadoc.skip=true -Dcodesnippet.skip=true -Dcheckstyle.skip -Dspotbugs.skip -Drevapi.skip=true -Djacoco.skip=true --quiet'
7373
mavenOptions: '$(MemoryOptions) $(LoggingOptions)'
7474
javaHomeOption: 'JDKVersion'
7575
jdkVersionOption: $(JavaBuildVersion)
@@ -80,20 +80,20 @@ jobs:
8080
displayName: 'Run Linting'
8181
inputs:
8282
mavenPomFile: ClientFromSourcePom.xml
83-
goals: 'checkstyle:check spotbugs:check revapi:check'
84-
# Skip failing on Checkstyle, RevApi, and Spotbugs errors.
83+
goals: 'checkstyle:check spotbugs:check'
84+
# Skip failing on Checkstyle and Spotbugs errors.
8585
# This is being done as the error reporting will be captured, so if any error reports exist the build can be
8686
# failed later allowing all libraries to be validated.
87-
options: '$(DefaultOptions) -T 2C -Dcheckstyle.failOnViolation=false -Dcheckstyle.failsOnError=false -Dspotbugs.failOnError=false -Drevapi.failBuildOnProblemsFound=false'
87+
options: '$(DefaultOptions) -T 1C -Dcheckstyle.failOnViolation=false -Dcheckstyle.failsOnError=false -Dspotbugs.failOnError=false -pl "!com.azure:azure-sdk-from-source,$(SkipLintingProjects)"'
8888
mavenOptions: '$(MemoryOptions) $(LoggingOptions)'
8989
javaHomeOption: 'JDKVersion'
9090
jdkVersionOption: $(JavaBuildVersion)
9191
jdkArchitectureOption: 'x64'
9292
publishJUnitResults: false
9393

94-
- task: Powershell@2
94+
- task: PowerShell@2
9595
inputs:
96-
filePath: /eng/pipelines/scripts/Get-Linting-Reports.ps1
96+
filePath: $(System.DefaultWorkingDirectory)/eng/pipelines/scripts/Get-Linting-Reports.ps1
9797
arguments: -OutputDirectory $(Build.ArtifactStagingDirectory)/linting-reports
9898
pwsh: true
9999
workingDirectory: $(Pipeline.Workspace)
@@ -106,7 +106,7 @@ jobs:
106106
condition: always()
107107

108108
- pwsh: |
109-
if ((Get-ChildItem -Directory | Measure-Object).Count -gt 0) {
109+
if ((Get-ChildItem -Path $(Build.ArtifactStagingDirectory)/linting-reports -Directory | Measure-Object).Count -gt 0) {
110110
exit 1
111111
}
112112
displayName: 'Fail Pipeline if Linting Reports Exist'

eng/pipelines/scripts/Get-Linting-Reports.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ function WriteSpotbugsProcessedReport($SpotbugsXmlReport, $ReportOutputFolder) {
104104
Set-Location -ErrorAction Stop -LiteralPath (Join-Path $PSScriptRoot "../../../")
105105

106106
# Always create the output directory
107+
$OutputDirectory = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($OutputDirectory)
107108
New-Item -Path $OutputDirectory -ItemType Directory | Out-Null
108109

109110
$path = "sdk/*/"
@@ -125,7 +126,7 @@ foreach ($targetFolder in (Get-ChildItem -Path $path -Filter "target" -Directory
125126

126127
$spotbugsXmlReport = Join-Path $targetFolder.FullName "spotbugs.xml"
127128
if (Test-Path -Path $spotbugsXmlReport) {
128-
WriteSpotbugsProcessedReport $spotbugsXmlReport $OutputDirectory
129+
WriteSpotbugsProcessedReport $spotbugsXmlReport $reportOutputFolder
129130
}
130131

131132
$revapiReport = Join-Path $targetFolder.FullName "revapi.json"

eng/scripts/generate_from_source_pom.py

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
import xml.etree.ElementTree as ET
2727

2828
class Project:
29-
def __init__(self, identifier: str, module_path: str, parent_pom: str):
29+
def __init__(self, identifier: str, directory_path: str, module_path: str, parent_pom: str):
3030
self.identifier = identifier
31+
self.directory_path = directory_path
3132
self.module_path = module_path
3233
self.parent_pom = parent_pom
3334
self.dependencies: List[str] = []
@@ -41,7 +42,7 @@ def add_dependent(self, dependent: str):
4142
if dependent not in self.dependents:
4243
self.dependents.append(dependent)
4344

44-
default_project = Project(None, None, None)
45+
default_project = Project(None, None, None, None)
4546

4647
# azure-client-sdk-parent, azure-perf-test-parent, spring-boot-starter-parent, and azure-spring-boot-test-parent are
4748
# valid parent POMs for Track 2 libraries.
@@ -79,7 +80,7 @@ def add_dependent(self, dependent: str):
7980
maven_xml_namespace = '{http://maven.apache.org/POM/4.0.0}'
8081

8182
# Function that creates the aggregate POM.
82-
def create_from_source_pom(project_list: str, set_pipeline_variable: str):
83+
def create_from_source_pom(project_list: str, set_pipeline_variable: str, set_skip_linting_projects: str):
8384
project_list_identifiers = project_list.split(',')
8485

8586
# Get the artifact identifiers from client_versions.txt to act as our source of truth.
@@ -101,14 +102,14 @@ def create_from_source_pom(project_list: str, set_pipeline_variable: str):
101102
for project_identifier in dependent_modules:
102103
dependency_modules = resolve_project_dependencies(project_identifier, dependency_modules, projects)
103104

104-
modules: Set[str] = set()
105+
source_projects: Set[Project] = set()
105106

106-
# Finally map the project identifiers to relative module paths.
107-
add_module_paths(modules, project_list_identifiers, projects)
108-
add_module_paths(modules, dependent_modules, projects)
109-
add_module_paths(modules, dependency_modules, projects)
110-
111-
modules = sorted(modules)
107+
# Finally map the project identifiers to projects.
108+
add_source_projects(source_projects, project_list_identifiers, projects)
109+
add_source_projects(source_projects, dependent_modules, projects)
110+
add_source_projects(source_projects, dependency_modules, projects)
111+
112+
modules = list(set(sorted([p.module_path for p in source_projects])))
112113
with open(file=client_from_source_pom_path, mode='w') as fromSourcePom:
113114
fromSourcePom.write(pom_file_start)
114115

@@ -118,7 +119,18 @@ def create_from_source_pom(project_list: str, set_pipeline_variable: str):
118119
fromSourcePom.write(pom_file_end)
119120

120121
if set_pipeline_variable:
121-
print('##vso[task.setvariable variable={};]{}'.format(set_pipeline_variable, json.dumps(modules)))
122+
checkout_paths = list(set(sorted([p.directory_path for p in source_projects])))
123+
print('##vso[task.setvariable variable={};]{}'.format(set_pipeline_variable, json.dumps(checkout_paths)))
124+
125+
# Sets the DevOps variable that is used to skip certain projects during linting validation.
126+
if set_skip_linting_projects:
127+
skip_linting_projects = []
128+
for maven_identifier in sorted([p.identifier for p in source_projects]):
129+
if not project_uses_client_parent(projects.get(maven_identifier), projects):
130+
skip_linting_projects.append('!' + maven_identifier)
131+
132+
print('##vso[task.setvariable variable={};]{}'.format(set_skip_linting_projects, ','.join(list(set(skip_linting_projects)))))
133+
122134

123135
# Function that loads and parses client_versions.txt into a artifact identifier - source version mapping.
124136
def load_client_artifact_identifiers() -> Dict[str, str]:
@@ -174,18 +186,19 @@ def create_project_for_pom(pom_path: str, project_list_identifiers: list, artifa
174186
tree_root = tree.getroot()
175187

176188
project_identifier = create_artifact_identifier(tree_root)
177-
module_path = os.path.dirname(pom_path).replace(root_path, '').replace('\\', '/')
189+
module_path = pom_path.replace(root_path, '').replace('\\', '/')
190+
directory_path = module_path[:module_path.rindex('/')]
178191
parent_pom = get_parent_pom(tree_root)
179192

180193
# If this is one of the parent POMs, retain it as a project.
181194
if project_identifier in parent_pom_identifiers:
182-
return Project(project_identifier, module_path, parent_pom)
195+
return Project(project_identifier, directory_path, module_path, parent_pom)
183196

184197
# If the project isn't a track 2 POM skip it and not one of the project list identifiers.
185198
if not project_identifier in project_list_identifiers and not parent_pom in valid_parents:
186199
return
187200

188-
project = Project(project_identifier, module_path, parent_pom)
201+
project = Project(project_identifier, directory_path, module_path, parent_pom)
189202

190203
dependencies = {child:parent for parent in tree_root.iter() for child in parent if child.tag == maven_xml_namespace + 'dependency'}
191204

@@ -262,25 +275,34 @@ def get_dependency_version(element: ET.Element):
262275
def element_find(element: ET.Element, path: str):
263276
return element.find(maven_xml_namespace + path)
264277

265-
def add_module_paths(module_paths: Set[str], project_identifiers: Iterable[str], projects: Dict[str, Project]):
278+
def add_source_projects(source_projects: Set[Project], project_identifiers: Iterable[str], projects: Dict[str, Project]):
266279
for project_identifier in project_identifiers:
267280
project = projects[project_identifier]
268-
module_paths.add(project.module_path)
281+
source_projects.add(project)
269282

270283
while project.parent_pom is not None:
271284
project = projects.get(project.parent_pom, default_project)
272285
if project.module_path is not None:
273-
module_paths.add(project.module_path)
286+
source_projects.add(project)
287+
288+
def project_uses_client_parent(project: Project, projects: Dict[str, Project]) -> bool:
289+
while project.parent_pom is not None:
290+
if project.parent_pom == 'com.azure:azure-client-sdk-parent':
291+
return True
292+
project = projects.get(project.parent_pom, default_project)
293+
294+
return False
274295

275296
def main():
276297
parser = argparse.ArgumentParser(description='Generated an aggregate POM for a From Source run.')
277298
parser.add_argument('--project-list', '--pl', type=str)
278299
parser.add_argument('--set-pipeline-variable', type=str)
300+
parser.add_argument('--set-skip-linting-projects', type=str)
279301
args = parser.parse_args()
280302
if args.project_list == None:
281303
raise ValueError('Missing project list.')
282304
start_time = time.time()
283-
create_from_source_pom(args.project_list, args.set_pipeline_variable)
305+
create_from_source_pom(args.project_list, args.set_pipeline_variable, args.set_skip_linting_projects)
284306
elapsed_time = time.time() - start_time
285307

286308
print('Effective From Source POM File')

sdk/communication/azure-communication-chat/src/main/java/com/azure/communication/chat/ChatThreadAsyncClient.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,7 @@ Mono<Response<SendChatMessageResult>> sendMessage(SendChatMessageOptions options
497497
return this.chatThreadClient.sendChatMessageWithResponseAsync(chatThreadId, options, context)
498498
.onErrorMap(CommunicationErrorResponseException.class, e -> translateException(e))
499499
.map(result -> new SimpleResponse<SendChatMessageResult>(result, (result.getValue())));
500-
}
501-
catch (RuntimeException ex) {
500+
} catch (RuntimeException ex) {
502501
return monoError(logger, ex);
503502
}
504503
}

sdk/confidentialledger/azure-security-confidentialledger/src/test/java/com/azure/security/confidentialledger/ConfidentialLedgerBaseClientTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ protected void beforeTest() {
3636
}
3737

3838
@Test
39-
public void getLedgerEntries()
40-
{
39+
public void getLedgerEntries() {
4140
DynamicResponse response = client.getLedgerEntries().send();
4241

4342
assertEquals(200, response.getStatusCode());

sdk/cosmos/azure-cosmos-benchmark/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Licensed under the MIT License.
3535
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3636
<jacoco.min.linecoverage>0.01</jacoco.min.linecoverage>
3737
<jacoco.min.branchcoverage>0.01</jacoco.min.branchcoverage>
38+
<checkstyle.skip>true</checkstyle.skip>
39+
<spotbugs.skip>true</spotbugs.skip>
3840
<jacoco.skip>true</jacoco.skip>
3941
<codesnippet.skip>false</codesnippet.skip>
4042
<javadocDoclet></javadocDoclet>

sdk/cosmos/azure-cosmos-dotnet-benchmark/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Licensed under the MIT License.
3636
<jacoco.min.linecoverage>0.01</jacoco.min.linecoverage>
3737
<jacoco.min.branchcoverage>0.01</jacoco.min.branchcoverage>
3838
<checkstyle.skip>true</checkstyle.skip>
39+
<spotbugs.skip>true</spotbugs.skip>
3940
<jacoco.skip>true</jacoco.skip>
4041
<codesnippet.skip>false</codesnippet.skip>
4142
<javadocDoclet></javadocDoclet>

sdk/e2e/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
<relativePath>../parents/azure-client-sdk-parent</relativePath>
2020
</parent>
2121

22+
<properties>
23+
<relative.path.to.eng.folder>../..</relative.path.to.eng.folder>
24+
<checkstyle.skip>true</checkstyle.skip>
25+
<spotbugs.skip>true</spotbugs.skip>
26+
</properties>
27+
2228
<dependencies>
2329
<dependency>
2430
<groupId>com.azure</groupId>

sdk/keyvault/azure-security-test-keyvault-jca/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
<properties>
2121
<codesnippet.skip>false</codesnippet.skip>
22+
<spotbugs.skip>true</spotbugs.skip>
2223
<javadocDoclet></javadocDoclet>
2324
<javadocDocletOptions></javadocDocletOptions>
2425
</properties>

0 commit comments

Comments
 (0)