Skip to content

Commit

Permalink
Update Build Script to Perform Additional Tasks (#21993)
Browse files Browse the repository at this point in the history
  • Loading branch information
alzimmermsft authored Jun 1, 2021
1 parent ba629dd commit f064db0
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 17 deletions.
47 changes: 31 additions & 16 deletions eng/precommit_local_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,17 @@ def get_artifacts_from_pom(pom_path: str, build_artifacts: list, debug: bool):

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

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

skip_arguments = []
arguments = []
if args.skip_tests:
skip_arguments.append('"-DskipTests=true"')
arguments.append('"-DskipTests=true"')

if args.skip_javadocs:
skip_arguments.append('"-Dmaven.javadocs.skip=true"')
arguments.append('"-Dmaven.javadocs.skip=true"')

if args.skip_checkstyle:
skip_arguments.append('"-Dcheckstyle.skip=true"')
arguments.append('"-Dcheckstyle.skip=true"')

if args.skip_spotbugs:
skip_arguments.append('"-Dspotbugs.skip=true"')
arguments.append('"-Dspotbugs.skip=true"')

if args.skip_revapi:
skip_arguments.append('"-Drevapi.skip=true"')
arguments.append('"-Drevapi.skip=true"')

maven_command = base_command.format(','.join(list(set(build_artifacts))), ' '.join(skip_arguments))
if not args.skip_readme:
arguments.append('"-Dverify-readme"')

if not args.skip_changelog:
arguments.append('"-Dverify-changelog"')

# If Checkstyle, Spotbugs, or RevApi is being ran install sdk-build-tools to ensure the linting configuration is up-to-date.
if not args.skip_checkstyle or not args.skip_spotbugs or not args.skip_revapi:
if debug:
print('Installing sdk-build-tools as Checkstyle, Spotbugs, or RevApi linting is being performed.')

os.system('mvn install -f ' + os.path.join('eng', 'code-quality-reports', 'pom.xml'))

maven_command = base_command.format(','.join(list(set(build_artifacts))), ' '.join(arguments))

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

Expand Down
40 changes: 39 additions & 1 deletion sdk/parents/azure-client-sdk-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@
</build>
</profile>

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

<!-- Verify that the CHANGELOG is formatted correctly. -->
<profile>
<id>verify-changelog</id>
<activation>
<property>
<name>verify-changelog</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version> <!-- {x-version-update;org.codehaus.mojo:exec-maven-plugin;external_dependency} -->
<executions>
<execution>
<id>verify-readme-codesnippet</id>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>pwsh</executable>
<arguments>
<argument>${project.basedir}/${relative.path.to.eng.folder}/eng/common/scripts/Verify-Changelog.ps1</argument>
<argument>-ChangeLogLocation</argument>
<argument>${project.basedir}/CHANGELOG.md</argument>
<argument>-VersionString</argument>
<argument>${project.version}</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<!-- Runs the dependency checker. -->
<profile>
<id>dependency-checker</id>
Expand Down

0 comments on commit f064db0

Please sign in to comment.