Skip to content

Commit

Permalink
build: updates to build and test with LTS JDKs
Browse files Browse the repository at this point in the history
This updates to build and test with LTS JDKs, using the same project setup as zipkin and zipkin-reporter

* moves off takari to normal maven wrapper, and updates all plugin versions
* removes retrolambda which is incompatible with recent JDKs
  * ports java 6 code to java 6 syntax
  * test release profile with JDK 11, which is last to compile java 1.6.
* adds opens configuration for old spring and grpc integration tests
* moves off abandoned powermock for mockito
  * bytebuddy no longer supports mocking System, so had to refactor code around currentTime
* updates GitHub Actions to build on first and last LTS (11, 21)
  * adds javadoc tests to ensure it will build prior to running deploy job

Signed-off-by: Adrian Cole <adrian@tetrate.io>
  • Loading branch information
Adrian Cole committed Dec 17, 2023
1 parent 5e15c20 commit 38c7b1f
Show file tree
Hide file tree
Showing 152 changed files with 2,781 additions and 1,634 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ can be automatically added by running `./mvnw com.mycila:license-maven-plugin:fo

```
/**
* Copyright 2020 The OpenZipkin Authors
* Copyright 2023 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
13 changes: 9 additions & 4 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 base commit as license check isn't run
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
13 changes: 9 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,22 @@ 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:
# 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/javadoc_to_gh_pages to get the full history
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') }}
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 brave to 1.6
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
16 changes: 12 additions & 4 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,19 @@ the following:

Before you do the first release of the year, move the SNAPSHOT version back and forth from whatever the current is.
In-between, re-apply the licenses.

Note: the command below is more complex than a normal project because this
project has a bom.
```bash
$ ./mvnw versions:set -DnewVersion=1.3.3-SNAPSHOT -DgenerateBackupPoms=false
$ ./mvnw com.mycila:license-maven-plugin:format
$ ./mvnw versions:set -DnewVersion=1.3.2-SNAPSHOT -DgenerateBackupPoms=false
$ git commit -am"Adjusts copyright headers for this year"
$ mvn=$PWD/mvnw
$ for p in ./bom .; do
(cd $p
$mvn versions:set -DnewVersion=2.17.1-SNAPSHOT -DgenerateBackupPoms=false
$mvn -o clean install -DskipTests
$mvn com.mycila:license-maven-plugin:format
$mvn versions:set -DnewVersion=2.17.0-SNAPSHOT -DgenerateBackupPoms=false)
done
$ git commit -asm"Adjusts copyright headers for this year"
```

## Manually releasing
Expand Down
8 changes: 3 additions & 5 deletions brave-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
<!-- use the same values in ../pom.xml -->
<zipkin.version>2.23.2</zipkin.version>
<zipkin-reporter.version>2.16.3</zipkin-reporter.version>

<nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
</properties>

<organization>
Expand Down Expand Up @@ -315,7 +313,7 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>${nexus-staging-maven-plugin.version}</version>
<version>1.6.13</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
Expand All @@ -326,12 +324,12 @@

<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M1</version>
<version>3.1.1</version>
</plugin>

<plugin>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<version>3.1.0</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand Down
11 changes: 0 additions & 11 deletions brave-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

<properties>
<main.basedir>${project.basedir}/..</main.basedir>
<main.java.version>1.8</main.java.version>
<main.signature.artifact>java18</main.signature.artifact>
</properties>

<dependencies>
Expand Down Expand Up @@ -61,15 +59,6 @@
</archive>
</configuration>
</plugin>
<plugin>
<groupId>net.orfjackal.retrolambda</groupId>
<artifactId>retrolambda-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 2013-2020 The OpenZipkin Authors
* Copyright 2013-2023 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 @@ -128,7 +128,7 @@ public final class IntegrationTestSpanHandler extends SpanHandler implements Tes

public IntegrationTestSpanHandler() {
// OrphanTracker detects to see if it should add "brave.flushed" or not, as it is used in
// production some times and avoiding this could be helpful. This forces a failed match,
// production sometimes and avoiding this could be helpful. This forces a failed match,
// so that we can detect orphans even when no data was added.
MutableSpan intentionallyWrongDefaultSpan = new MutableSpan();
intentionallyWrongDefaultSpan.tag("not", "me");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2020 The OpenZipkin Authors
* Copyright 2013-2023 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 @@ -45,7 +45,7 @@ public class IntegrationTestSpanHandlerTest {
assertThatThrownBy(spanHandler::takeLocalSpan)
.hasMessageStartingWith("Orphaned span found")
.hasMessageContaining("brave.flush")
.hasMessageEndingWith("Look for code missing span.flush() or span.finish().");
.hasMessageContaining("Look for code missing span.flush() or span.finish().");
}

@Test public void toString_includesSpans() {
Expand Down
51 changes: 36 additions & 15 deletions brave/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
<module.name>brave</module.name>

<main.basedir>${project.basedir}/..</main.basedir>
<main.java.version>1.6</main.java.version>
<main.signature.artifact>java16</main.signature.artifact>

<!-- disable errorprone cast warning as PendingSpans internally hacks equals -->
<errorprone.args>-Xep:EqualsUnsafeCast:OFF</errorprone.args>
Expand Down Expand Up @@ -61,19 +59,6 @@
<version>0.18</version>
<scope>test</scope>
</dependency>
<!-- to mock Platform calls -->
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.opentracing</groupId>
<artifactId>opentracing-api</artifactId>
Expand Down Expand Up @@ -136,4 +121,40 @@
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>release</id>
<properties>
<!-- The brave jar needs to be Java 1.6 bytecode -->
<main.java.version>1.6</main.java.version>
<main.signature.artifact>java16</main.signature.artifact>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${maven-enforcer-plugin.version}</version>
<executions>
<execution>
<id>enforce-java</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<!-- The only LTS JDK we support that can compile 1.6 bytecode is 11.
https://www.oracle.com/java/technologies/javase/12-relnote-issues.html -->
<requireJavaVersion>
<version>[11,12)</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
10 changes: 5 additions & 5 deletions brave/src/main/java/brave/Tracing.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2020 The OpenZipkin Authors
* Copyright 2013-2023 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 @@ -50,7 +50,7 @@
* for example via spring or when mocking.
*/
public abstract class Tracing implements Closeable {
static final AtomicReference<Tracing> CURRENT = new AtomicReference<>();
static final AtomicReference<Tracing> CURRENT = new AtomicReference<Tracing>();

public static Builder newBuilder() {
return new Builder();
Expand Down Expand Up @@ -148,7 +148,7 @@ public static final class Builder {
boolean alwaysSampleLocal = false, alwaysReportSpans = false, trackOrphans = false;
Propagation.Factory propagationFactory = B3Propagation.FACTORY;
ErrorParser errorParser = new ErrorParser();
Set<SpanHandler> spanHandlers = new LinkedHashSet<>(); // dupes not ok
Set<SpanHandler> spanHandlers = new LinkedHashSet<SpanHandler>(); // dupes not ok

Builder() {
defaultSpan.localServiceName("unknown");
Expand All @@ -162,7 +162,7 @@ public static final class Builder {
* @since 5.12
*/
public Set<SpanHandler> spanHandlers() {
return Collections.unmodifiableSet(new LinkedHashSet<>(spanHandlers));
return Collections.unmodifiableSet(new LinkedHashSet<SpanHandler>(spanHandlers));
}

/**
Expand Down Expand Up @@ -480,7 +480,7 @@ static final class Default extends Tracing {
defaultSpan.localIp(Platform.get().linkLocalIp());
}

Set<SpanHandler> spanHandlers = new LinkedHashSet<>(builder.spanHandlers);
Set<SpanHandler> spanHandlers = new LinkedHashSet<SpanHandler>(builder.spanHandlers);
// When present, the Zipkin handler is invoked after the user-supplied ones.
if (builder.zipkinSpanReporter != null) {
spanHandlers.add(
Expand Down
Loading

0 comments on commit 38c7b1f

Please sign in to comment.