Skip to content
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
12 changes: 10 additions & 2 deletions .github/workflows/update-smoke-test-latest-versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ jobs:
"maven-surefire.latest=${SUREFIRE_VERSION}" \
> dd-smoke-tests/maven/src/test/resources/latest-tool-versions.properties

printf '%s\n' \
"# Pinned latest eligible stable version (>=${MIN_DEPENDENCY_AGE_HOURS}h old) for the Maven instrumentation latestDepTest." \
"# Updated automatically by the update-smoke-test-latest-versions workflow." \
"maven-surefire.latest=${SUREFIRE_VERSION}" \
> dd-java-agent/instrumentation/maven/maven-3.2.1/src/test/resources/latest-tool-versions.properties

- name: Check for changes
id: check-changes
run: |
Expand All @@ -135,7 +141,8 @@ jobs:
if: steps.check-changes.outputs.has_changes == 'true'
run: |
git add dd-smoke-tests/gradle/src/test/resources/latest-tool-versions.properties \
dd-smoke-tests/maven/src/test/resources/latest-tool-versions.properties
dd-smoke-tests/maven/src/test/resources/latest-tool-versions.properties \
dd-java-agent/instrumentation/maven/maven-3.2.1/src/test/resources/latest-tool-versions.properties
git commit -m "chore: Update smoke test latest tool versions"

- name: Push changes
Expand All @@ -161,7 +168,8 @@ jobs:
--body "$(cat <<'EOF'
# What Does This Do

This PR updates the pinned latest eligible stable tool versions used by CI Visibility smoke tests.
This PR updates the pinned latest eligible stable tool versions used by CI Visibility smoke tests
and by the Maven instrumentation latestDepTest.
Only releases at least ${{ env.MIN_DEPENDENCY_AGE_HOURS }} hours old are eligible.

- Gradle: ${{ steps.update.outputs.gradle_line }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Stream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.maven.artifact.versioning.ComparableVersion;
import org.apache.maven.execution.ExecutionEvent;
import org.apache.maven.execution.MavenSession;
Expand All @@ -38,8 +35,6 @@
import org.junit.jupiter.params.provider.MethodSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;

public class MavenUtilsTest extends AbstractMavenTest {

Expand Down Expand Up @@ -481,38 +476,27 @@ private boolean assertGetContainer(ExecutionEvent executionEvent) {
}

private static String getLatestMavenSurefireVersion() {
OkHttpClient client = new OkHttpClient();
Request request =
new Request.Builder()
.url(
"https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/maven-metadata.xml")
.build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(response.body().byteStream());
doc.getDocumentElement().normalize();

NodeList versionList = doc.getElementsByTagName("latest");
if (versionList.getLength() > 0) {
String version = versionList.item(0).getTextContent();
if (!version.contains("alpha") && !version.contains("beta")) {
LOGGER.info("Will run the 'latest' tests with version {}", version);
return version;
}
}
} else {
LOGGER.warn(
"Could not get latest Maven Surefire version, response from repo.maven.apache.org is {}:{}",
response.code(),
response.body().string());
// The pinned value is bumped on a schedule by the update-smoke-test-latest-versions workflow.
// See latest-tool-versions.properties.
String version = loadLatestToolVersions().getProperty("maven-surefire.latest");
LOGGER.info("Will run the 'latest' tests with Maven Surefire version {}", version);
return version;
}

private static Properties loadLatestToolVersions() {
Properties properties = new Properties();
try (InputStream stream =
MavenUtilsTest.class
.getClassLoader()
.getResourceAsStream("latest-tool-versions.properties")) {
if (stream == null) {
throw new IllegalStateException(
"Could not find latest-tool-versions.properties on classpath");
}
} catch (Exception e) {
LOGGER.warn("Could not get latest Maven Surefire version", e);
properties.load(stream);
} catch (IOException e) {
throw new RuntimeException(e);
}
String hardcodedLatestVersion = "3.5.0"; // latest version that is known to work
LOGGER.info("Will run the 'latest' tests with hard-coded version {}", hardcodedLatestVersion);
return hardcodedLatestVersion;
return properties;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Pinned latest eligible stable version (>=48h old) for the Maven instrumentation latestDepTest.
# Updated automatically by the update-smoke-test-latest-versions workflow.
maven-surefire.latest=3.5.5
Loading