Skip to content

Commit

Permalink
Enable Develocity remote build cache on CI (#922)
Browse files Browse the repository at this point in the history
* initial config

* fix config

* Add clean to resolve failures seen in CI

* Use `satisfiesOnlyOnce(line -> assertThat(line).contains(":discover"))`

* Add license header exclusions

* Do not discover any annotation processors

---------

Co-authored-by: Tim te Beek <tim@moderne.io>
  • Loading branch information
nielsdebruin and timtebeek authored Jan 3, 2025
1 parent 4cea05b commit d953978
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 49 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ on:
schedule:
- cron: 0 17 * * *

env:
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.gradle_enterprise_cache_username }}
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.gradle_enterprise_cache_password }}
DEVELOCITY_ACCESS_KEY: ${{ secrets.gradle_enterprise_access_key }}

jobs:
build:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ pom.xml.versionsBackup
.project
.settings
.vscode/
.mvn/.develocity/
27 changes: 27 additions & 0 deletions .mvn/develocity.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<develocity>
<server>
<url>https://ge.openrewrite.org/</url>
</server>
<buildScan>
<publishing>
<onlyIf><![CDATA[!buildResult.failures.empty]]></onlyIf>
</publishing>
<capture>
<fileFingerprints>true</fileFingerprints>
</capture>
</buildScan>
<buildCache>
<local>
<storeEnabled>true</storeEnabled>
</local>
<remote>
<storeEnabled>#{isTrue(env['CI'])}</storeEnabled>
<server>
<credentials>
<username>#{env['GRADLE_ENTERPRISE_CACHE_USERNAME']}</username>
<password>#{env['GRADLE_ENTERPRISE_CACHE_PASSWORD']}</password>
</credentials>
</server>
</remote>
</buildCache>
</develocity>
7 changes: 7 additions & 0 deletions .mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<extensions>
<extension>
<groupId>com.gradle</groupId>
<artifactId>develocity-maven-extension</artifactId>
<version>1.23</version>
</extension>
</extensions>
16 changes: 0 additions & 16 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip
6 changes: 4 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,8 @@
<compilerArgs>
<arg>-Xlint:deprecation</arg>
<arg>-Xlint:unchecked</arg>
<!--<arg>-proc:full</arg>-->
</compilerArgs>
<proc>none</proc>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -496,13 +496,15 @@
<licenseSet>
<header>.mvn/licenseHeader.txt</header>
<excludes>
<exclude>pom.xml</exclude>
<exclude>*.xml</exclude>
<exclude>suppressions.xml</exclude>
<exclude>**/README.md</exclude>
<exclude>**/.sdkmanrc</exclude>
<exclude>src/test/resources-its/**</exclude>
<exclude>src/test/resources/**</exclude>
<exclude>src/main/resources/**</exclude>
<exclude>.moderne/</exclude>
<exclude>.mvn/</exclude>
</excludes>
</licenseSet>
</licenseSets>
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/org/openrewrite/maven/BasicIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
class BasicIT {

@MavenTest
@MavenGoal("clean")
@MavenGoal("package")
void groupid_artifactid_should_be_ok(MavenExecutionResult result) {
assertThat(result)
.isSuccessful()
Expand Down Expand Up @@ -81,6 +83,7 @@ void resolves_settings(MavenExecutionResult result) {
}

@MavenTest
@MavenGoal("clean")
@MavenGoal("${project.groupId}:${project.artifactId}:${project.version}:dryRun")
void snapshot_ok(MavenExecutionResult result) {
assertThat(result)
Expand Down
61 changes: 30 additions & 31 deletions src/test/java/org/openrewrite/maven/RewriteDiscoverIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@
@MavenJupiterExtension
@MavenOption(MavenCLIOptions.NO_TRANSFER_PROGRESS)
@MavenOption(MavenCLIExtra.MUTE_PLUGIN_VALIDATION_WARNING)
@MavenGoal("clean")
@MavenGoal("${project.groupId}:${project.artifactId}:${project.version}:discover")
class RewriteDiscoverIT {

@Nested
@MavenGoal("${project.groupId}:${project.artifactId}:${project.version}:discover")
class RecipeLookup {

@MavenTest
@SystemProperty(value = "detail", content = "true")
void rewrite_discover_detail(MavenExecutionResult result) {
assertThat(result)
.isSuccessful()
.out()
.info()
.anySatisfy(line -> assertThat(line).contains("options"));
.isSuccessful()
.out()
.info()
.anySatisfy(line -> assertThat(line).contains("options"));

assertThat(result).out().warn().isEmpty();
}
Expand All @@ -47,20 +47,20 @@ void rewrite_discover_detail(MavenExecutionResult result) {
@SystemProperty(value = "recipe", content = "org.openrewrite.JAVA.format.AutoFormAT")
void rewrite_discover_recipe_lookup_case_insensitive(MavenExecutionResult result) {
assertThat(result)
.isSuccessful()
.out()
.info()
.anySatisfy(line -> assertThat(line).contains("org.openrewrite.java.format.AutoFormat"));
.isSuccessful()
.out()
.info()
.anySatisfy(line -> assertThat(line).contains("org.openrewrite.java.format.AutoFormat"));
}

@MavenTest
@SystemProperty(value = "recursion", content = "1")
void rewrite_discover_recursion(MavenExecutionResult result) {
assertThat(result)
.isSuccessful()
.out()
.info()
.anySatisfy(line -> assertThat(line).contains("recipeList"));
.isSuccessful()
.out()
.info()
.anySatisfy(line -> assertThat(line).contains("recipeList"));

assertThat(result).out().warn().isEmpty();
}
Expand All @@ -69,38 +69,37 @@ void rewrite_discover_recursion(MavenExecutionResult result) {
@MavenTest
void rewrite_discover_default(MavenExecutionResult result) {
assertThat(result)
.isSuccessful()
.out()
.info()
.matches(logLines ->
logLines.stream().anyMatch(logLine -> logLine.contains("org.openrewrite.java.format.AutoFormat"))
)
.matches(logLines ->
logLines.stream().anyMatch(logLine -> logLine.contains("org.openrewrite.java.SpringFormat"))
);
.isSuccessful()
.out()
.info()
.matches(logLines ->
logLines.stream().anyMatch(logLine -> logLine.contains("org.openrewrite.java.format.AutoFormat"))
)
.matches(logLines ->
logLines.stream().anyMatch(logLine -> logLine.contains("org.openrewrite.java.SpringFormat"))
);

assertThat(result).out().warn().isEmpty();
}

@MavenTest
void rewrite_discover_rewrite_yml(MavenExecutionResult result) {
assertThat(result)
.isSuccessful()
.out()
.info()
.anySatisfy(line -> assertThat(line).contains("com.example.RewriteDiscoverIT.CodeCleanup"));
.isSuccessful()
.out()
.info()
.anySatisfy(line -> assertThat(line).contains("com.example.RewriteDiscoverIT.CodeCleanup"));

assertThat(result).out().warn().isEmpty();
}

@MavenTest
void rewrite_discover_multi_module(MavenExecutionResult result) {
assertThat(result)
.isSuccessful()
.out()
.info()
.anySatisfy(line -> assertThat(line).matches("^a.*SKIPPED$"))
.anySatisfy(line -> assertThat(line).matches("^b.*SKIPPED$"));
.isSuccessful()
.out()
.info()
.satisfiesOnlyOnce(line -> assertThat(line).contains(":discover"));

assertThat(result).out().warn().isEmpty();
}
Expand Down

0 comments on commit d953978

Please sign in to comment.