Skip to content

Commit f064db0

Browse files
authored
Update Build Script to Perform Additional Tasks (Azure#21993)
1 parent ba629dd commit f064db0

File tree

2 files changed

+70
-17
lines changed

2 files changed

+70
-17
lines changed

eng/precommit_local_build.py

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,17 @@ def get_artifacts_from_pom(pom_path: str, build_artifacts: list, debug: bool):
7373

7474
def main():
7575
parser = argparse.ArgumentParser(description='Runs compilation, testing, and linting for the passed artifacts.')
76-
parser.add_argument('--artifacts', '--a', type=str, default=None, help='Comma separated list of groupId:artifactId identifiers')
77-
parser.add_argument('--poms', '--p', type=str, default=None, help='Comma separated list of POM paths')
78-
parser.add_argument('--skip-tests', '--st', action='store_true', help='Skips running tests')
79-
parser.add_argument('--skip-javadocs', '--sj', action='store_true', help='Skips javadoc generation')
80-
parser.add_argument('--skip-checkstyle', '--sc', action='store_true', help='Skips checkstyle linting')
81-
parser.add_argument('--skip-spotbugs', '--ss', action='store_true', help='Skips spotbugs linting')
82-
parser.add_argument('--skip-revapi', '--sr', action='store_true', help='Skips revapi linting')
83-
parser.add_argument('--command-only', '--co', action='store_true', help='Indicates that only the command should be generated and not ran')
84-
parser.add_argument('--debug', '--d', action='store_true', help='Generates command with verbose logging')
76+
parser.add_argument('--artifacts', '-a', type=str, default=None, help='Comma separated list of groupId:artifactId identifiers')
77+
parser.add_argument('--poms', '-p', type=str, default=None, help='Comma separated list of POM paths')
78+
parser.add_argument('--skip-tests', '-st', action='store_true', help='Skips running tests')
79+
parser.add_argument('--skip-javadocs', '-sj', action='store_true', help='Skips javadoc generation')
80+
parser.add_argument('--skip-checkstyle', '-sc', action='store_true', help='Skips checkstyle linting')
81+
parser.add_argument('--skip-spotbugs', '-ss', action='store_true', help='Skips spotbugs linting')
82+
parser.add_argument('--skip-revapi', '-sr', action='store_true', help='Skips revapi linting')
83+
parser.add_argument('--skip-readme', '-smd', action='store_true', help='Skips README validation')
84+
parser.add_argument('--skip-changelog', '-scl', action='store_true', help='Skips CHANGELOG validation')
85+
parser.add_argument('--command-only', '-co', action='store_true', help='Indicates that only the command should be generated and not ran')
86+
parser.add_argument('--debug', '-d', action='store_true', help='Generates command with verbose logging')
8587
args = parser.parse_args()
8688

8789
if args.artifacts == None and args.poms == None:
@@ -101,23 +103,36 @@ def main():
101103
if build_artifacts.count == 0:
102104
raise ValueError('No build artifacts found.')
103105

104-
skip_arguments = []
106+
arguments = []
105107
if args.skip_tests:
106-
skip_arguments.append('"-DskipTests=true"')
108+
arguments.append('"-DskipTests=true"')
107109

108110
if args.skip_javadocs:
109-
skip_arguments.append('"-Dmaven.javadocs.skip=true"')
111+
arguments.append('"-Dmaven.javadocs.skip=true"')
110112

111113
if args.skip_checkstyle:
112-
skip_arguments.append('"-Dcheckstyle.skip=true"')
114+
arguments.append('"-Dcheckstyle.skip=true"')
113115

114116
if args.skip_spotbugs:
115-
skip_arguments.append('"-Dspotbugs.skip=true"')
117+
arguments.append('"-Dspotbugs.skip=true"')
116118

117119
if args.skip_revapi:
118-
skip_arguments.append('"-Drevapi.skip=true"')
120+
arguments.append('"-Drevapi.skip=true"')
119121

120-
maven_command = base_command.format(','.join(list(set(build_artifacts))), ' '.join(skip_arguments))
122+
if not args.skip_readme:
123+
arguments.append('"-Dverify-readme"')
124+
125+
if not args.skip_changelog:
126+
arguments.append('"-Dverify-changelog"')
127+
128+
# If Checkstyle, Spotbugs, or RevApi is being ran install sdk-build-tools to ensure the linting configuration is up-to-date.
129+
if not args.skip_checkstyle or not args.skip_spotbugs or not args.skip_revapi:
130+
if debug:
131+
print('Installing sdk-build-tools as Checkstyle, Spotbugs, or RevApi linting is being performed.')
132+
133+
os.system('mvn install -f ' + os.path.join('eng', 'code-quality-reports', 'pom.xml'))
134+
135+
maven_command = base_command.format(','.join(list(set(build_artifacts))), ' '.join(arguments))
121136

122137
print('Running Maven command: {}'.format(maven_command))
123138

sdk/parents/azure-client-sdk-parent/pom.xml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@
985985
</build>
986986
</profile>
987987

988-
<!-- Verify that there are no changes to readme file. Build fails if the there's a difference in README after running the embedme tool. -->
988+
<!-- Verify that there are no changes to README file. Build fails if the there's a difference in README after running the embedme tool. -->
989989
<profile>
990990
<id>verify-readme</id>
991991
<activation>
@@ -1022,6 +1022,44 @@
10221022
</build>
10231023
</profile>
10241024

1025+
<!-- Verify that the CHANGELOG is formatted correctly. -->
1026+
<profile>
1027+
<id>verify-changelog</id>
1028+
<activation>
1029+
<property>
1030+
<name>verify-changelog</name>
1031+
</property>
1032+
</activation>
1033+
<build>
1034+
<plugins>
1035+
<plugin>
1036+
<groupId>org.codehaus.mojo</groupId>
1037+
<artifactId>exec-maven-plugin</artifactId>
1038+
<version>1.2.1</version> <!-- {x-version-update;org.codehaus.mojo:exec-maven-plugin;external_dependency} -->
1039+
<executions>
1040+
<execution>
1041+
<id>verify-readme-codesnippet</id>
1042+
<phase>prepare-package</phase>
1043+
<goals>
1044+
<goal>exec</goal>
1045+
</goals>
1046+
<configuration>
1047+
<executable>pwsh</executable>
1048+
<arguments>
1049+
<argument>${project.basedir}/${relative.path.to.eng.folder}/eng/common/scripts/Verify-Changelog.ps1</argument>
1050+
<argument>-ChangeLogLocation</argument>
1051+
<argument>${project.basedir}/CHANGELOG.md</argument>
1052+
<argument>-VersionString</argument>
1053+
<argument>${project.version}</argument>
1054+
</arguments>
1055+
</configuration>
1056+
</execution>
1057+
</executions>
1058+
</plugin>
1059+
</plugins>
1060+
</build>
1061+
</profile>
1062+
10251063
<!-- Runs the dependency checker. -->
10261064
<profile>
10271065
<id>dependency-checker</id>

0 commit comments

Comments
 (0)