diff --git a/.github/workflows/archrules.yml b/.github/workflows/archrules.yml new file mode 100644 index 0000000..c001257 --- /dev/null +++ b/.github/workflows/archrules.yml @@ -0,0 +1,40 @@ +# action for evaluating archrules on a single project repo +name: Nebula ArchRules +on: + push: + branches: + - 'main' + pull_request: + +jobs: + buildmultijdk: + runs-on: ubuntu-latest + name: ArchRules + steps: + - uses: actions/checkout@v6 + - name: Setup git user + run: | + git config --global user.name "Nebula Plugin Maintainers" + git config --global user.email "nebula-plugins-oss@netflix.com" + - name: Set up JDKs + uses: actions/setup-java@v5 + with: + distribution: 'zulu' + java-version: 21 + java-package: jdk + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v5 + with: + cache-overwrite-existing: true + build-scan-publish: true + build-scan-terms-of-use-url: 'https://gradle.com/terms-of-service' + build-scan-terms-of-use-agree: 'yes' + - name: Gradle run archrules + run: ./gradlew --stacktrace archRulesConsoleReport archRulesMarkdownReport + - name: Arch Rule Reports stop summary + run: cat build/reports/archrules/report.md > $GITHUB_STEP_SUMMARY + - name: PR Comment + if: github.event_name == 'pull_request' + run: gh pr comment ${{ github.event.number }} -F build/reports/archrules/report.md + env: + GH_TOKEN: ${{ github.token }} \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dd4bc65..3050d7b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,7 @@ jobs: git config --global user.name "Nebula Plugin Maintainers" git config --global user.email "nebula-plugins-oss@netflix.com" - name: Set up JDKs - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: 'zulu' java-version: | diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2555cbe..11ac946 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -27,7 +27,7 @@ jobs: git config --global user.name "Nebula Plugin Maintainers" git config --global user.email "nebula-plugins-oss@netflix.com" - name: Set up JDKs - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: 'zulu' java-version: | diff --git a/.github/workflows/refresh-locks.yml b/.github/workflows/refresh-locks.yml index 20250a0..c0bdba0 100644 --- a/.github/workflows/refresh-locks.yml +++ b/.github/workflows/refresh-locks.yml @@ -15,7 +15,7 @@ jobs: git config --global user.name "Nebula Plugin Maintainers" git config --global user.email "nebula-plugins-oss@netflix.com" - name: Set up JDKs - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: 'zulu' java-version: 21 diff --git a/build.gradle.kts b/build.gradle.kts index 061271f..c5489f3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -31,7 +31,7 @@ contacts { dependencies { compileOnly("io.github.gradle-nexus:publish-plugin:2.0.0") - implementation("com.netflix.nebula:nebula-archrules-gradle-plugin:0.+") + implementation("com.netflix.nebula:nebula-archrules-gradle-plugin:1.+") implementation("com.netflix.nebula:nebula-oss-publishing-plugin:latest.release") implementation("com.netflix.nebula:gradle-contacts-plugin:latest.release") implementation("com.netflix.nebula:gradle-dependency-lock-plugin:latest.release") @@ -64,19 +64,24 @@ gradlePlugin { implementationClass = "nebula.plugin.plugin.NebulaPluginPlugin" tags.set(listOf("nebula", "nebula-plugin")) } - create("libraryPlugin") { + create("com.netflix.nebula.library") { id = "com.netflix.nebula.library" displayName = "Nebula Library Plugin" description = "Sets up publishing and release process for Nebula Libraries" implementationClass = "nebula.plugin.plugin.NebulaLibraryPlugin" tags.set(listOf("nebula")) } - create("rootPlugin") { + create("com.netflix.nebula.root") { id = "com.netflix.nebula.root" displayName = "Nebula Root Plugin" description = "Sets up publishing and release process for Nebula Multiproject Repos" implementationClass = "nebula.plugin.plugin.NebulaRootPlugin" tags.set(listOf("nebula")) + compatibility { + features { + configurationCache = true + } + } } create("com.netflix.nebula.oss.settings") { id = "com.netflix.nebula.oss.settings" diff --git a/gradle.lockfile b/gradle.lockfile index 62fa394..3d617e6 100644 --- a/gradle.lockfile +++ b/gradle.lockfile @@ -40,12 +40,12 @@ com.netflix.nebula:gradle-contacts-plugin:8.1.0=compileClasspath,runtimeClasspat com.netflix.nebula:gradle-dependency-lock-plugin:17.0.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.netflix.nebula:gradle-info-plugin:16.2.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.netflix.nebula:gradle-java-cross-compile-plugin:8.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.netflix.nebula:nebula-archrules-core:0.18.1=runtimeClasspath,testRuntimeClasspath -com.netflix.nebula:nebula-archrules-gradle-plugin:0.18.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.netflix.nebula:nebula-archrules-core:1.0.1=runtimeClasspath,testRuntimeClasspath +com.netflix.nebula:nebula-archrules-gradle-plugin:1.0.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.netflix.nebula:nebula-dependencies-comparison:0.2.1=runtimeClasspath,testRuntimeClasspath com.netflix.nebula:nebula-gradle-interop:3.1.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.netflix.nebula:nebula-oss-publishing-plugin:4.1.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.netflix.nebula:nebula-project-plugin:13.1.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +com.netflix.nebula:nebula-project-plugin:13.1.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.netflix.nebula:nebula-publishing-plugin:23.1.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.netflix.nebula:nebula-release-plugin:21.0.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath com.netflix.nebula:nebula-test:12.3.0=testCompileClasspath,testRuntimeClasspath diff --git a/src/main/kotlin/nebula/plugin/plugin/NebulaRootPlugin.kt b/src/main/kotlin/nebula/plugin/plugin/NebulaRootPlugin.kt index c798b03..4d96474 100644 --- a/src/main/kotlin/nebula/plugin/plugin/NebulaRootPlugin.kt +++ b/src/main/kotlin/nebula/plugin/plugin/NebulaRootPlugin.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nebula.plugin.plugin; +package nebula.plugin.plugin import io.github.gradlenexus.publishplugin.AbstractNexusStagingRepositoryTask import nebula.plugin.publishing.NebulaOssPublishingExtension @@ -35,6 +35,7 @@ class NebulaRootPlugin : Plugin { project.plugins.apply("com.netflix.nebula.info") project.plugins.apply("com.netflix.nebula.release") project.plugins.apply("com.netflix.nebula.oss-publishing") + project.plugins.apply("com.netflix.nebula.archrules.aggregate") project.extensions.findByType()?.apply { packageGroup.set("com.netflix") netflixOssRepository.set("gradle-plugins") diff --git a/src/test/kotlin/com/netflix/nebula/SupportedGradleVersion.kt b/src/test/kotlin/com/netflix/nebula/SupportedGradleVersion.kt index 09b8afb..b0728af 100644 --- a/src/test/kotlin/com/netflix/nebula/SupportedGradleVersion.kt +++ b/src/test/kotlin/com/netflix/nebula/SupportedGradleVersion.kt @@ -3,6 +3,6 @@ package com.netflix.nebula import nebula.test.dsl.Gradle enum class SupportedGradleVersion(val version: Gradle) { - MIN(Gradle.ofVersion("9.0.0")), + GRADLE_9_1(Gradle.ofVersion("9.1.0")), CURRENT(Gradle.current()) } \ No newline at end of file diff --git a/src/test/kotlin/nebula/plugin/plugin/NebulaRootPluginTest.kt b/src/test/kotlin/nebula/plugin/plugin/NebulaRootPluginTest.kt index c860f1a..2ea0084 100644 --- a/src/test/kotlin/nebula/plugin/plugin/NebulaRootPluginTest.kt +++ b/src/test/kotlin/nebula/plugin/plugin/NebulaRootPluginTest.kt @@ -1,14 +1,102 @@ package nebula.plugin.plugin +import com.netflix.nebula.SupportedGradleVersion import nebula.test.dsl.TestKitAssertions.assertThat +import nebula.test.dsl.plugins +import nebula.test.dsl.properties +import nebula.test.dsl.rootProject +import nebula.test.dsl.run +import nebula.test.dsl.subProject +import nebula.test.dsl.testProject +import nebula.test.dsl.withGradle import org.gradle.testfixtures.ProjectBuilder +import org.gradle.testkit.runner.TaskOutcome import org.junit.jupiter.api.Test +import org.junit.jupiter.api.io.TempDir +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource +import java.io.File class NebulaRootPluginTest { + @TempDir + lateinit var projectDir: File + @Test fun `plugin sets group`() { val project = ProjectBuilder.builder().build() project.plugins.apply("com.netflix.nebula.root") assertThat(project.group).isEqualTo("com.netflix.nebula") } + + @Test + fun `plugin applies archrules aggregate`() { + val project = ProjectBuilder.builder().build() + project.plugins.apply("com.netflix.nebula.root") + assertThat(project.plugins.findPlugin("com.netflix.nebula.archrules.aggregate")).isNotNull + } + + @ParameterizedTest + @EnumSource(SupportedGradleVersion::class) + fun `archrules aggregate`(gradle: SupportedGradleVersion) { + val runner = testProject(projectDir) { + properties { + buildCache(true) + configurationCache(true) + } + rootProject { + plugins { + id("com.netflix.nebula.root") + } + } + subProject(":sub1") { + plugins { + id("java") + id("com.netflix.nebula.library") + } + } + } + val result = runner.run("build", "--stacktrace") { + withGradle(gradle.version) + } + assertThat(result) + .hasNoMutableStateWarnings() + .hasNoDeprecationWarnings() + assertThat(result.task(":sub1:archRulesConsoleReport")) + .hasOutcome(TaskOutcome.SUCCESS) + assertThat(result.task(":archRulesAggregateMarkdownReport")) + .`as`("aggregate reports do not run by default") + .isNull() + } + + @ParameterizedTest + @EnumSource(SupportedGradleVersion::class) + fun `archrules aggregate markdown`(gradle: SupportedGradleVersion) { + val runner = testProject(projectDir) { + properties { + buildCache(true) + configurationCache(true) + } + rootProject { + plugins { + id("com.netflix.nebula.root") + } + } + subProject(":sub1") { + plugins { + id("java") + id("com.netflix.nebula.library") + } + } + } + + val result = runner.run("archRulesAggregateMarkdownReport") { + forwardOutput() + withGradle(gradle.version) + } + assertThat(result) + .hasNoMutableStateWarnings() + .hasNoDeprecationWarnings() + assertThat(result.task(":archRulesAggregateMarkdownReport")) + .hasOutcome(TaskOutcome.SUCCESS) + } } \ No newline at end of file