Skip to content

Commit

Permalink
deps: updates build to compile with LTS JDK and bumps deps (#204)
Browse files Browse the repository at this point in the history
This moves to the same build infra as the rest of Zipkin, notably to allow compiling on JDK 11, 17 and 21. This also bumps all the dependencies.

This also migrates to junit5 which began with the helpful @TeamModerne tool, but needed a lot of fixing up due to custom rules.
```
./mvnw org.openrewrite.maven:rewrite-maven-plugin:run \
  -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-testing-frameworks:LATEST \
  -Drewrite.activeRecipes=org.openrewrite.java.testing.junit5.JUnit4to5Migration
```

Signed-off-by: Adrian Cole <adrian@tetrate.io>
Co-authored-by: Andriy Redko <drreta@gmail.com>
  • Loading branch information
codefromthecrypt and reta committed Jan 4, 2024
1 parent 9363776 commit 498be65
Show file tree
Hide file tree
Showing 61 changed files with 1,003 additions and 1,049 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@ on:

jobs:
create_release:
runs-on: ubuntu-20.04 # newest available distribution, aka focal
runs-on: ubuntu-22.04 # newest available distribution, aka jellyfish
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
# Prevent use of implicit GitHub Actions read-only token GITHUB_TOKEN. We don't deploy on
# the tag MAJOR.MINOR.PATCH event, but we still need to deploy the maven-release-plugin master commit.
token: ${{ secrets.GH_TOKEN }}
fetch-depth: 1 # only need the HEAD commit as license check isn't run
- name: Setup java
uses: actions/setup-java@v4
with:
distribution: 'zulu' # zulu as it supports a wide version range
java-version: '11' # earliest LTS and last that can compile the 1.6 release profile.
- name: Cache local Maven repository
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
Expand Down
23 changes: 16 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,29 @@ on:

jobs:
deploy:
runs-on: ubuntu-20.04 # newest available distribution, aka focal
runs-on: ubuntu-22.04 # newest available distribution, aka jellyfish
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1 # only needed to get the sha label
# Prevent use of implicit GitHub Actions read-only token GITHUB_TOKEN.
# We push Javadocs to the gh-pages branch on commit.
token: ${{ secrets.GH_TOKEN }}
fetch-depth: 0 # allow build-bin/idl_to_gh_pages to get the full history
- name: Setup java
uses: actions/setup-java@v4
with:
distribution: 'zulu' # zulu as it supports a wide version range
java-version: '11' # earliest LTS and last that can compile the 1.6 release profile.
- name: Cache local Maven repository
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-
# We can't cache Docker without using buildx because GH actions restricts /var/lib/docker
# That's ok because DOCKER_PARENT_IMAGE is always ghcr.io and local anyway.
# Don't attempt to cache Docker. Sensitive information can be stolen
# via forks, and login session ends up in ~/.docker. This is ok because
# we publish DOCKER_PARENT_IMAGE to ghcr.io, hence local to the runner.
- name: Deploy
env:
# GH_USER=<user that created GH_TOKEN>
Expand All @@ -51,7 +60,7 @@ jobs:
# - referenced in .settings.xml
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
# DOCKERHUB_USER=<typically dockerzipkindeployer>
# - only push top-level projects: zipkin zipkin-aws zipkin-dependencies zipkin-aws to Docker Hub, only on release
# - only push top-level projects: zipkin zipkin-aws zipkin-dependencies zipkin-gcp to Docker Hub, only on release
# - login like this: echo "$DOCKERHUB_TOKEN"| docker login -u "$DOCKERHUB_USER" --password-stdin
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
# DOCKERHUB_TOKEN=<access token for DOCKERHUB_USER>
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/docker_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ on:

jobs:
docker_push:
runs-on: ubuntu-20.04 # newest available distribution, aka focal
runs-on: ubuntu-22.04 # newest available distribution, aka jellyfish
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1 # only needed to get the sha label
# We can't cache Docker without using buildx because GH actions restricts /var/lib/docker
# That's ok because DOCKER_PARENT_IMAGE is always ghcr.io and local anyway.
# Don't attempt to cache Docker. Sensitive information can be stolen
# via forks, and login session ends up in ~/.docker. This is ok because
# we publish DOCKER_PARENT_IMAGE to ghcr.io, hence local to the runner.
- name: Docker Push
run: | # GITHUB_REF will be refs/tags/docker-MAJOR.MINOR.PATCH
build-bin/git/login_git &&
Expand Down
53 changes: 45 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,58 @@ on:
paths-ignore: '**/*.md'

jobs:
test-javadoc:
name: Test JavaDoc Builds
runs-on: ubuntu-22.04 # newest available distribution, aka jellyfish
if: "!contains(github.event.head_commit.message, 'maven-release-plugin')"
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # full git history for license check
- name: Setup java
uses: actions/setup-java@v4
with:
distribution: 'zulu' # zulu as it supports a wide version range
java-version: '11' # earliest LTS and last that can compile the 1.6 release profile.
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-jdk-11-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-jdk-11-maven-
- name: Build JavaDoc
run: ./mvnw clean javadoc:aggregate -Prelease

test:
runs-on: ubuntu-20.04 # newest available distribution, aka focal
name: test (JDK ${{ matrix.java_version }})
runs-on: ubuntu-22.04 # newest available distribution, aka jellyfish
if: "!contains(github.event.head_commit.message, 'maven-release-plugin')"
strategy:
fail-fast: false # don't fail fast as sometimes failures are operating system specific
matrix: # use latest available versions and be consistent on all workflows!
include:
- java_version: 11 # Last that can compile zipkin core to 1.6 for zipkin-reporter
maven_args: -Prelease -Dgpg.skip -Dmaven.javadoc.skip=true
- java_version: 21 # Most recent LTS
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0 # full git history for license check
- name: Setup java
uses: actions/setup-java@v4
with:
fetch-depth: 0 # full git history for license check
distribution: 'zulu' # zulu as it supports a wide version range
java-version: ${{ matrix.java_version }}
- name: Cache local Maven repository
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-
# We can't cache Docker without using buildx because GH actions restricts /var/lib/docker
# That's ok because DOCKER_PARENT_IMAGE is always ghcr.io and local anyway.
key: ${{ runner.os }}-jdk-${{ matrix.java_version }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-jdk-${{ matrix.java_version }}-maven-
# Don't attempt to cache Docker. Sensitive information can be stolen
# via forks, and login session ends up in ~/.docker. This is ok because
# we publish DOCKER_PARENT_IMAGE to ghcr.io, hence local to the runner.
- name: Test
run: build-bin/configure_test && build-bin/test
Binary file modified .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
20 changes: 18 additions & 2 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
# 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.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
30 changes: 7 additions & 23 deletions aws-junit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,21 @@
</dependency>

<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-sqs</artifactId>
<version>${aws-java-sdk.version}</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-jupiter.version}</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>compile</scope>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-sqs</artifactId>
<version>${aws-java-sdk.version}</version>
</dependency>

<dependency>
<groupId>org.elasticmq</groupId>
<artifactId>elasticmq-server_2.13</artifactId>
<version>1.0.0</version>
<version>1.5.4</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
Expand All @@ -63,19 +62,4 @@
</exclusions>
</dependency>
</dependencies>

<build>
<plugins>
<!-- Disable animal sniffer as it conflicts on ASM versions and this is a test module -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<executions>
<execution>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 The OpenZipkin Authors
* Copyright 2016-2024 The OpenZipkin Authors
*
* Licensed 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
Expand Down Expand Up @@ -30,73 +30,74 @@
import org.elasticmq.StrictSQSLimits$;
import org.elasticmq.rest.sqs.SQSRestServer;
import org.elasticmq.rest.sqs.SQSRestServerBuilder;
import org.junit.rules.ExternalResource;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import zipkin2.Span;
import zipkin2.codec.SpanBytesDecoder;

import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Collections.singletonList;

public class AmazonSQSRule extends ExternalResource {
public class AmazonSQSExtension implements BeforeEachCallback, AfterEachCallback {
SQSRestServer server;
int serverPort;
AmazonSQS client;
String queueUrl;

public AmazonSQSRule() {
public AmazonSQSExtension() {
}

// TODO: this shouldn't be called explicity. at some point, we should change this to jupiter and
// inject the queue URL as a parameter when used this way.
public AmazonSQSRule start() {
@Override public void beforeEach(ExtensionContext extensionContext) {
if (server == null) {
server = SQSRestServerBuilder.withDynamicPort()
.withSQSLimits(StrictSQSLimits$.MODULE$).start();
server =
SQSRestServerBuilder.withDynamicPort().withSQSLimits(StrictSQSLimits$.MODULE$).start();
serverPort = server.waitUntilStarted().localAddress().getPort();
}

if (client == null) {
client = AmazonSQSClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("x", "x")))
.withEndpointConfiguration(
new EndpointConfiguration(String.format("http://localhost:%d", serverPort),
null))
new EndpointConfiguration(String.format("http://localhost:%d", serverPort), null))
.build();
queueUrl = client.createQueue("zipkin").getQueueUrl();
}
return this;
}

public String queueUrl() {
return queueUrl;
}

@Override protected void before() {

if (client != null && queueUrl != null) {
client.purgeQueue(new PurgeQueueRequest(queueUrl));
}
}

@Override protected void after() {
if (server != null) {
@Override public void afterEach(ExtensionContext extensionContext) {
if (client != null) {
client.shutdown();
client = null;
}

if (server == null) {
server.stopAndWait();
server = null;
}
}

public String queueUrl() {
return queueUrl;
}

public int queueCount() {
String count = client
.getQueueAttributes(queueUrl, singletonList("ApproximateNumberOfMessages"))
String count = client.getQueueAttributes(queueUrl, singletonList("ApproximateNumberOfMessages"))
.getAttributes()
.get("ApproximateNumberOfMessages");

return Integer.parseInt(count);
}

public int notVisibleCount() {
String count = client
.getQueueAttributes(queueUrl, singletonList("ApproximateNumberOfMessagesNotVisible"))
.getAttributes()
.get("ApproximateNumberOfMessagesNotVisible");
String count =
client.getQueueAttributes(queueUrl, singletonList("ApproximateNumberOfMessagesNotVisible"))
.getAttributes()
.get("ApproximateNumberOfMessagesNotVisible");

return Integer.parseInt(count);
}
Expand All @@ -113,14 +114,13 @@ public List<Span> getSpans(boolean delete) {

while (result != null && result.getMessages().size() > 0) {

spans =
Stream.concat(spans, result.getMessages().stream().flatMap(AmazonSQSRule::decodeSpans));
spans = Stream.concat(spans,
result.getMessages().stream().flatMap(AmazonSQSExtension::decodeSpans));

result = client.receiveMessage(queueUrl);

if (delete) {
List<DeleteMessageRequest> deletes = result
.getMessages()
List<DeleteMessageRequest> deletes = result.getMessages()
.stream()
.map(m -> new DeleteMessageRequest(queueUrl, m.getReceiptHandle()))
.collect(Collectors.toList());
Expand All @@ -136,9 +136,8 @@ public void send(String body) {
}

static Stream<? extends Span> decodeSpans(Message m) {
byte[] bytes = m.getBody().charAt(0) == '['
? m.getBody().getBytes(UTF_8)
: Base64.decode(m.getBody());
byte[] bytes =
m.getBody().charAt(0) == '[' ? m.getBody().getBytes(UTF_8) : Base64.decode(m.getBody());
if (bytes[0] == '[') {
return SpanBytesDecoder.JSON_V2.decodeList(bytes).stream();
}
Expand Down
8 changes: 4 additions & 4 deletions brave/instrumentation-aws-java-sdk-core/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016-2023 The OpenZipkin Authors
Copyright 2016-2024 The OpenZipkin Authors
Licensed 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
Expand Down Expand Up @@ -75,9 +75,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.stefanbirkner</groupId>
<artifactId>system-rules</artifactId>
<version>1.19.0</version>
<groupId>uk.org.webcompere</groupId>
<artifactId>system-stubs-jupiter</artifactId>
<version>2.1.5</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Loading

0 comments on commit 498be65

Please sign in to comment.