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

Improve integration test setup #1427

Merged
merged 1 commit into from
Nov 20, 2024
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
13 changes: 13 additions & 0 deletions .renovaterc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
"extends": [
"helpers:pinGitHubActionDigests"
],
"customManagers": [
{
"customType": "regex",
"fileMatch": [
"^integration-tests/.*(-init\\.patch|\\.sh)$"
],
"matchStrings": [
"\\b(?<packageName>[a-z0-9_.-]+?:[a-z0-9_.-]+?):(?<currentValue>[^:]+?):[a-zA-Z0-9_-]+\\b",
"<version>(?<currentValue>.*?)<!-- Renovate: (?<packageName>.*?) --></version>"
],
"datasourceTemplate": "maven"
}
],
Comment on lines +6 to +18
Copy link
Member Author

Choose a reason for hiding this comment

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

Tested using out internal Renovate testing setup.

"packageRules": [
{
"matchPackagePatterns": [
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/checkstyle-init.patch
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>${assertj.version}</version>
+ <version>3.26.3<!-- Renovate: org.assertj:assertj-bom --></version>
Copy link
Member Author

Choose a reason for hiding this comment

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

I opted for this syntax, as it's a single-line way (thus compatible with Renovate's regex manager) to link versions to their dependencies, without splitting this logic across files.

+ <scope>test</scope>
+ </dependency>
<dependency>
Expand Down
5 changes: 2 additions & 3 deletions integration-tests/checkstyle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ test_name="$(basename "${0}" .sh)"
project='checkstyle'
repository='https://github.com/checkstyle/checkstyle.git'
revision='checkstyle-10.20.1'
# XXX: Configure Renovate to manage the AssertJ version declared here.
additional_build_flags='-Perror-prone-compile,error-prone-test-compile -Dassertj.version=3.24.2 -Dmaven.compiler.failOnError=true'
additional_build_flags='-Perror-prone-compile,error-prone-test-compile -Dmaven.compiler.failOnError=true'
additional_source_directories='${project.basedir}${file.separator}src${file.separator}it${file.separator}java,${project.basedir}${file.separator}src${file.separator}xdocs-examples${file.separator}java'
patch_error_prone_flags=''
validation_error_prone_flags=''
Expand All @@ -33,4 +32,4 @@ fi
"${patch_error_prone_flags}" \
"${validation_error_prone_flags}" \
"${validation_build_flags}" \
$@
${@}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
${@}
"${@}"

My IntelliJ suggests this, and it seemed to work :).

Copy link
Member Author

@Stephan202 Stephan202 Nov 20, 2024

Choose a reason for hiding this comment

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

That works currently because we have only one additional flag to pass along (--sync), but is not what is intended: the idea is that remaining arguments are passed along individually.

Copy link
Member

Choose a reason for hiding this comment

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

Clear, lets merge!

26 changes: 15 additions & 11 deletions integration-tests/run-integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ shared_build_flags="
${additional_build_flags}
"

# XXX: Configure Renovate to manage the fmt-maven-plugin version declared here.
# XXX: Once GitHub actions uses Maven 3.9.2+, we can inline this variable with
# version reference `${fmt.version}`, and `-Dfmt.version=2.21.1` added to
# `shared_build_flags`.
format_goal='com.spotify.fmt:fmt-maven-plugin:2.21.1:format'
format_goal='com.spotify.fmt:fmt-maven-plugin:2.25:format'

error_prone_shared_flags='-XepExcludedPaths:(\Q${project.basedir}${file.separator}src${file.separator}\E(it|test|xdocs-examples)\Q${file.separator}resources\E|\Q${project.build.directory}${file.separator}\E).*'

Expand Down Expand Up @@ -124,14 +120,22 @@ pushd "${project_root}"
git config user.email || git config user.email '[email protected]'
git config user.name || git config user.name 'Integration Test'

# Prepare the code for analysis by (a) applying the minimal set of changes
# required to run Error Prone with Error Prone Support and (b) formatting the
# code using the same method by which it will be formatted after each
# compilation round. The initial formatting operation ensures that subsequent
# modifications can be rendered in a clean manner.
# Prepare the code for analysis by applying the minimal set of changes required
# to run Error Prone with Error Prone Support.
initial_patch="${integration_test_root}/${test_name}-init.patch"
git clean -fdx
git apply < "${integration_test_root}/${test_name}-init.patch"
git apply < "${initial_patch}"
git commit -m 'dependency: Introduce Error Prone Support' .
if [ -n "${do_sync}" ]; then
# The initial patch applied successfully, but if it was created against a
# different version, then offsets may have changed. Here we update the patch
# to exactly match the new state.
git diff HEAD~1 | "${grep_command}" -vP '^(diff|index)' > "${initial_patch}"
fi

# Format the patched code using the same method by which it will be formatted
# after each compilation round. This initial formatting operation ensures that
# subsequent modifications can be rendered in a clean manner.
mvn ${shared_build_flags} "${format_goal}"
git commit -m 'minor: Reformat using Google Java Format' .
diff_base="$(git rev-parse HEAD)"
Expand Down