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

Build on latest Java, test through lowest possible #254

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
16 changes: 13 additions & 3 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ on:

jobs:
tests:
name: "E2E tests on Java ${{ matrix.jdk }}"
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 1
matrix:
jdk: [ 8, 11, 17 ]
Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't got through all the changes, but a quick comment here. E2E tests are quite heavy and they hit Sonatype Nexus. That system "occasionally" has performance problems and I would prefer to not give it an extra load due to our tests. I'm really glad, the Sonatype guys are ok with us testing our e2e processes as some tests, but it's rather for smoke testing (the name could be somehow misleading, in fact they are smoke tests checking the end-to-end process with the real Nexus).

Maybe we could execute the compatTests on that way (with the real binaries)? Thanks to that we would know that JDK 8 execution is still ok, but Nexus would be not affected (which is irrelevant for that test anyway, as the REST calls on the server side shouldn't be JDK specified).

However, I'm not sure, if it would be easy to work with the compatTest to make it possible to execute them in that mode on CI (but still by default with the current JDK 11+, as we rather don't want to force developers to install all JDK 8, 11 and 17 on their machines*). WDYT?

* - I see nexusPublishPlugin.test.java which might be helpful for the default (non-CI) mode.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To reduce the load, we can reduce the matrix for push, but I think at least right before release it should be executed on all versions via workflow_dispatch. (Conditional CI matrix is possible without too much hassle.)

compatTests are by definition separated by Java versions, the task name contains it.
foojay-resolver does the installing on dev machines as well as CI, so it's not a big deal to have any version. That said I added auto for devs just to make it more native to the machine.

steps:
- name: Checkout project with submodules
uses: actions/checkout@v3
Expand All @@ -20,7 +26,7 @@ jobs:
- name: Setup JDK
uses: actions/setup-java@v3
with:
java-version: 11
java-version: 19
distribution: 'zulu'
- uses: gradle/gradle-build-action@v2
- name: Run sanity check
Expand All @@ -31,5 +37,9 @@ jobs:
ORG_GRADLE_PROJECT_sonatypePasswordE2E: ${{ secrets.SONATYPE_PASSWORD_E2E }}
ORG_GRADLE_PROJECT_signingKeyE2E: ${{ secrets.GPG_SIGNING_KEY_E2E }}
ORG_GRADLE_PROJECT_signingPasswordE2E: ${{ secrets.GPG_SIGNING_KEY_PASSPHRASE_E2E }}
run: |
./gradlew --stacktrace -Pe2eVerboseOutput e2eTest
run: >
./gradlew
--stacktrace
-PnexusPublishPlugin.test.java=${{ matrix.jdk }}
-Pe2eVerboseOutput
e2eTest
2 changes: 1 addition & 1 deletion .github/workflows/gradle-latest-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 11
java-version: 19
distribution: 'zulu'
- uses: gradle/gradle-build-action@v2

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/java-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:
openjdk:
strategy:
matrix:
jdk: [11, 17]
jdk: [8, 11, 17]
name: "OpenJDK ${{ matrix.jdk }}"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: ${{ matrix.jdk }}
java-version: 19
distribution: 'zulu'
- uses: gradle/gradle-build-action@v2
# Workaround https://github.com/ajoberstar/gradle-stutter/issues/22
Expand All @@ -32,8 +32,8 @@ jobs:
# java11=6.0.1,6.9.4,7.0.2,7.6.1,8.0.2,8.1.1,8.2-rc-1
# ->
# java11=8.2-rc-1
# The trick is that \2 will greedily eat everything before the last comma.
sed -r 's/^(.*?)=(.*),(.*)$/\1=\3/g' -i stutter.lockfile
# The trick is that \3 will greedily eat everything before the last comma.
sed -r 's/^(.*?)=(.*?),(.*),(.*?)$/\1=\2,\4/g' -i stutter.lockfile
cat stutter.lockfile
- name: Test cross Java versions compatibility
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 11
java-version: 19
distribution: 'zulu'
- uses: gradle/gradle-build-action@v2
with:
Expand Down
20 changes: 17 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ dependencies {
testImplementation("com.github.tomakehurst:wiremock:2.27.2")
testImplementation("ru.lanwen.wiremock:wiremock-junit5:1.3.1")
testImplementation("org.assertj:assertj-core:3.24.2")
// This cannot be updated to 5.x as it requires Java 11,
// but we are running CI on Java 8 in .github/workflows/java-versions.yml.
testImplementation("org.mockito:mockito-junit-jupiter:4.11.0")
testImplementation("org.mockito:mockito-junit-jupiter:5.4.0")
testImplementation("com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0")
}

Expand Down Expand Up @@ -251,6 +249,17 @@ tasks {
showStandardStreams = true
}
}
javaLauncher = project.javaToolchains.launcherFor {
languageVersion = providers
.gradleProperty("nexusPublishPlugin.test.java")
.map {
if (it == "auto") {
JavaLanguageVersion.of(JavaVersion.current().majorVersion)
} else {
JavaLanguageVersion.of(it)
}
}
}
}
withType<Test>().configureEach {
dependsOn(shadowJar)
Expand All @@ -260,6 +269,11 @@ tasks {
withType<Test>().matching { it.name.startsWith("compatTest") }.configureEach {
systemProperty("plugin.version", project.version)
}
named<Test>("test").configure {
javaLauncher = project.javaToolchains.launcherFor {
TWiStErRob marked this conversation as resolved.
Show resolved Hide resolved
languageVersion = JavaLanguageVersion.of(11)
}
}
}

publishing {
Expand Down
14 changes: 7 additions & 7 deletions buildSrc/src/main/kotlin/IdeaExtExtensions.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 the original author or authors.
* Copyright 2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,13 +24,13 @@ import java.io.File
import kotlin.math.min

fun IdeaProject.settings(configuration: ProjectSettings.() -> kotlin.Unit) =
(this as ExtensionAware).configure(configuration)
(this as ExtensionAware).configure(configuration)

fun ProjectSettings.copyright(configuration: CopyrightConfiguration.() -> kotlin.Unit) =
(this as ExtensionAware).configure(configuration)
(this as ExtensionAware).configure(configuration)

fun Project.readCopyrightHeader(licenseHeaderFile: File) =
licenseHeaderFile.readLines()
.map { line -> line.substring(min(line.length, 3)) }
.joinToString("\n")
.trim()
licenseHeaderFile.readLines()
.map { line -> line.substring(min(line.length, 3)) }
.joinToString("\n")
.trim()
6 changes: 6 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.configuration-cache=true

# Version of JDK to use for running tests.
# Possible values:
# - auto -> use Java running Gradle, best for local dev.
# - A Java major version number, like 8, 11 or 17.
nexusPublishPlugin.test.java=auto