Skip to content

Commit

Permalink
Tweak GitHub build workflow (#1542)
Browse files Browse the repository at this point in the history
* Use official setup-java GitHub action
* Run build with GitHub workflow on pull requests
* Use actions/checkout@v2
* Try speeding up Maven builds by tuning JVM parameters
* Add cache to GitHub workflow
* Remove building old branches
* Remove build with Java 13

Java 13 removed support for emitting Java 6 bytecode.

https://www.oracle.com/technetwork/java/javase/12-relnote-issues-5211422.html#JDK-8028563
  • Loading branch information
joschi authored Feb 23, 2020
1 parent d5cc88e commit bf2464f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
30 changes: 20 additions & 10 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: Java CI
on:
pull_request:
branches:
- 4.1-maintenance
- 4.1-development
- 5.0-development
push:
branches:
- 3.0-maintenance
- 3.1-maintenance
- 3.2-maintenance
- 4.0-maintenance
- 4.1-maintenance
- 4.1-development
- 5.0-development
Expand All @@ -14,17 +15,26 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
java_version: [1.8, 11]
os: [ubuntu-latest, macOS-latest]
java_version: [8, 11]
os:
- ubuntu-latest
env:
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java_version }}
- uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Print Java and Maven versions
run: ./mvnw -B -s .github/settings.xml -v
run: ./mvnw -B -ff -s .github/settings.xml -v
- name: Build with Maven
run: ./mvnw -B -s .github/settings.xml install -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
run: ./mvnw -B -ff -s .github/settings.xml install -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
- name: Run tests
run: ./mvnw -B -s .github/settings.xml verify
run: ./mvnw -B -ff -s .github/settings.xml verify
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.codahale.metrics.collectd;

import com.codahale.metrics.Counter;
import com.codahale.metrics.Gauge;
import com.codahale.metrics.Histogram;
import com.codahale.metrics.Meter;
import com.codahale.metrics.MetricAttribute;
Expand All @@ -13,8 +12,10 @@
import org.junit.ClassRule;
import org.junit.Test;

import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

Expand Down Expand Up @@ -70,7 +71,7 @@ public void reportsDoubleGauges() throws Exception {

private <T extends Number> void reportsGauges(T value) throws Exception {
reporter.report(
map("gauge", (Gauge) () -> value),
map("gauge", () -> value),
map(),
map(),
map(),
Expand All @@ -82,7 +83,7 @@ private <T extends Number> void reportsGauges(T value) throws Exception {
@Test
public void reportsBooleanGauges() throws Exception {
reporter.report(
map("gauge", (Gauge) () -> true),
map("gauge", () -> true),
map(),
map(),
map(),
Expand All @@ -91,7 +92,7 @@ public void reportsBooleanGauges() throws Exception {
assertThat(nextValues(receiver)).containsExactly(1d);

reporter.report(
map("gauge", (Gauge) () -> false),
map("gauge", () -> false),
map(),
map(),
map(),
Expand All @@ -103,7 +104,7 @@ public void reportsBooleanGauges() throws Exception {
@Test
public void doesNotReportStringGauges() throws Exception {
reporter.report(
map("unsupported", (Gauge) () -> "value"),
map("unsupported", () -> "value"),
map(),
map(),
map(),
Expand Down Expand Up @@ -267,17 +268,17 @@ public void sanitizesMetricName() throws Exception {
}

private <T> SortedMap<String, T> map() {
return new TreeMap<>();
return Collections.emptySortedMap();
}

private <T> SortedMap<String, T> map(String name, T metric) {
final SortedMap<String, T> map = map();
map.put(name, metric);
return map;
final Map<String, T> map = Collections.singletonMap(name, metric);
return new TreeMap<>(map);
}

private List<Number> nextValues(Receiver receiver) throws Exception {
return receiver.next().getValues();
final ValueList valueList = receiver.next();
return valueList == null ? Collections.emptyList() : valueList.getValues();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void dispatch(Notification notification) {
}

public ValueList next() throws InterruptedException {
return queue.poll(1, TimeUnit.SECONDS);
return queue.poll(2, TimeUnit.SECONDS);
}

@Override
Expand Down

0 comments on commit bf2464f

Please sign in to comment.