Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Build Script to Perform Additional Tasks #21993

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have an option to skip gpg check?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet, that could be added in the future

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