diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b121723d..298050e2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,9 +8,6 @@ on: paths-ignore: - "*.md" -env: - JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" - jobs: build: name: build @@ -20,13 +17,16 @@ jobs: matrix: java: [ '8', '11', '16' ] steps: - - uses: actions/checkout@v2 + - name: Checkout Code + uses: actions/checkout@v2 + - name: Setup JAVA uses: actions/setup-java@v2 with: distribution: "adopt" java-version: ${{ matrix.java }} - - uses: actions/cache@v2.1.6 + + - uses: actions/cache@v2 with: path: | ~/.m2/repository @@ -34,33 +34,47 @@ jobs: key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', '.mvn/wrapper/maven-wrapper.properties') }} restore-keys: | ${{ runner.os }}-maven- + - name: Build run: ./mvnw --batch-mode --no-transfer-progress --show-version --settings .github/maven/settings.xml verify + - name: Upload Test Reports + uses: actions/upload-artifact@v2 + if: ${{ always() }} + with: + name: test-reports-${{ matrix.java }} + path: '**/target/surefire-reports/**' + if-no-files-found: ignore + release: name: release - if: github.event_name == 'push' && github.repository == 'logstash/logstash-logback-encoder' && github.ref == 'refs/heads/main' && startsWith(github.event.commits[0].message, '[release]') runs-on: ubuntu-20.04 needs: [build] + if: github.event_name == 'push' && github.repository == 'logstash/logstash-logback-encoder' && github.ref == 'refs/heads/main' && startsWith(github.event.commits[0].message, '[release]') steps: - - uses: actions/checkout@v2 + - name: Checkout Code + uses: actions/checkout@v2 with: ref: main + - name: Setup JAVA uses: actions/setup-java@v2 with: distribution: "adopt" java-version: 1.8 + - name: Setup GPG run: .github/workflows/steps/setup-gpg.sh env: GPG_KEY: ${{ secrets.GPG_KEY }} GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + - name: Setup GIT run: | .github/workflows/steps/setup-git.sh git switch main - - uses: actions/cache@v2.1.6 + + - uses: actions/cache@v2 with: path: | ~/.m2/repository @@ -68,6 +82,7 @@ jobs: key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', '.mvn/wrapper/maven-wrapper.properties') }} restore-keys: | ${{ runner.os }}-maven- + - name: Release run: ./mvnw --batch-mode --no-transfer-progress --show-version --settings .github/maven/settings.xml --activate-profiles ossrh release:prepare release:perform env: diff --git a/.gitignore b/.gitignore index cf9cd470..c326d466 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ dependency-reduced-pom.xml -META-INF/ target/ .idea diff --git a/.mvn/jvm.config b/.mvn/jvm.config new file mode 100644 index 00000000..57b7147a --- /dev/null +++ b/.mvn/jvm.config @@ -0,0 +1 @@ +-XX:+TieredCompilation -XX:TieredStopAtLevel=1 \ No newline at end of file diff --git a/pom.xml b/pom.xml index 7b35bed1..c916b8e8 100644 --- a/pom.xml +++ b/pom.xml @@ -612,6 +612,18 @@ + + + github + + + env.CI + + + + true + + diff --git a/src/test/java/net/logstash/logback/test/TestExecutionLogger.java b/src/test/java/net/logstash/logback/test/TestExecutionLogger.java new file mode 100644 index 00000000..8d8fbf74 --- /dev/null +++ b/src/test/java/net/logstash/logback/test/TestExecutionLogger.java @@ -0,0 +1,45 @@ +/* + * Copyright 2013-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. + * 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. + */ +package net.logstash.logback.test; + +import org.junit.jupiter.api.extension.BeforeAllCallback; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; + +/** + * Simple JUnit5 test extension logging the name of each test before it starts to help + * troubleshooting output when running multiple tests at once. + */ +public class TestExecutionLogger implements BeforeEachCallback, BeforeAllCallback { + + @Override + public void beforeEach(ExtensionContext context) throws Exception { + + StringBuilder sb = new StringBuilder("---- Running "); + if (context.getTestClass().isPresent()) { + sb.append(context.getTestClass().get().getName()); + } + sb.append("#") + .append(context.getDisplayName()); + + System.out.println(sb); + } + + @Override + public void beforeAll(ExtensionContext context) throws Exception { + System.out.println("---- Initializing " + context.getTestClass().orElse(null)); + } +} diff --git a/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension b/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension new file mode 100644 index 00000000..0d0341f5 --- /dev/null +++ b/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension @@ -0,0 +1 @@ +net.logstash.logback.test.TestExecutionLogger \ No newline at end of file diff --git a/src/test/resources/junit-platform.properties b/src/test/resources/junit-platform.properties new file mode 100644 index 00000000..25ce5c98 --- /dev/null +++ b/src/test/resources/junit-platform.properties @@ -0,0 +1 @@ +junit.jupiter.extensions.autodetection.enabled = true