From dadb52b76ed7b03d9026019dc0e78700c2aadb97 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Fri, 23 Feb 2024 23:54:24 +0100 Subject: [PATCH 1/2] Enable test coverage --- .github/workflows/build-reusable.yaml | 122 ++++++++++++++++++++++++ .github/workflows/build.yaml | 48 +--------- log4j-api-test/pom.xml | 18 ++++ log4j-core-test/pom.xml | 18 ++++ log4j-layout-template-json-test/pom.xml | 18 ++++ log4j-osgi-test/pom.xml | 18 ++++ pom.xml | 39 ++++++++ 7 files changed, 238 insertions(+), 43 deletions(-) create mode 100644 .github/workflows/build-reusable.yaml diff --git a/.github/workflows/build-reusable.yaml b/.github/workflows/build-reusable.yaml new file mode 100644 index 00000000000..734d12e1bc5 --- /dev/null +++ b/.github/workflows/build-reusable.yaml @@ -0,0 +1,122 @@ +# +# 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. +# + +name: build-reusable + +on: + workflow_call: + inputs: + java-version: + description: The Java compiler version + default: 17 + type: string + site-enabled: + description: Flag indicating if Maven `site` goal should be run + default: false + type: boolean + secrets: + CODECOV_TOKEN: + description: Codecov.io token + required: true + +jobs: + + build: + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + steps: + + - name: Checkout repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1 + with: + # When running on `pull_request` use the PR branch, not the target branch + ref: ${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }} + + - name: Set up Java + uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # 3.7.0 + with: + distribution: temurin + java-version: ${{ inputs.java-version }} + java-package: jdk + architecture: x64 + cache: maven + + # We could have used `verify`, but `clean install` is required while generating the build reproducibility report, which is performed in the next step. + # For details, see: https://maven.apache.org/guides/mini/guide-reproducible-builds.html#how-to-test-my-maven-build-reproducibility + - name: Build + id: build + shell: bash + run: | + ./mvnw \ + --show-version --batch-mode --errors --no-transfer-progress \ + -DtrimStackTrace=false \ + -DinstallAtEnd=true \ + clean install + + - name: Build the website + if: inputs.site-enabled + shell: bash + run: | + ./mvnw \ + --show-version --batch-mode --errors --no-transfer-progress \ + site + + - name: Upload test coverage + uses: codecov/codecov-action@0cfda1dd0a4ad9efc75517f399d859cd1ea4ced1 # 4.0.2 + with: + fail_ci_if_error: true + slug: ppkarwasz/logging-log4j2 + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true + + # We upload tests results if the build fails. + - name: Upload test results + if: failure() && steps.build.conclusion == 'failure' + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # 4.3.1 + with: + name: surefire-${{matrix.os}}-${{github.run_number}}-${{github.run_attempt}} + path: | + **/target/surefire-reports + **/target/logs + + # `clean verify artifact:compare` is required to generate the build reproducibility report. + # For details, see: https://maven.apache.org/guides/mini/guide-reproducible-builds.html#how-to-test-my-maven-build-reproducibility + - name: Verify build reproducibility + id: reproducibility + shell: bash + run: | + ./mvnw \ + --show-version --batch-mode --errors --no-transfer-progress \ + -DskipTests=true \ + clean verify artifact:compare + + # We reproducibility results if the build fails. + - name: Upload reproducibility results + if: failure() && steps.reproducibility.conclusion == 'failure' + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # 4.3.1 + with: + name: reproducibility-${{matrix.os}}-${{github.run_number}}-${{github.run_attempt}} + path: | + **/target/bom.xml + **/target/*.buildcompare + **/target/*.jar + **/target/*.zip + **/target/reference/** diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1a95a6dcb05..3cefd446340 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -21,16 +21,9 @@ on: push: branches: - "2.x" - - "release/*" - paths-ignore: - - "**.adoc" - - "**.md" - - "**.txt" - pull_request: - paths-ignore: - - "**.adoc" - - "**.md" - - "**.txt" + - "main" + - "fix/*" + - "feature/*" permissions: read-all @@ -38,43 +31,12 @@ jobs: build: if: github.actor != 'dependabot[bot]' - uses: apache/logging-parent/.github/workflows/build-reusable.yaml@rel/10.6.0 + uses: ppkarwasz/logging-log4j2/.github/workflows/build-reusable.yaml@2.x with: java-version: | 8 17 site-enabled: true - - deploy-snapshot: - needs: build - if: github.repository == 'apache/logging-log4j2' && github.ref_name == '2.x' - uses: apache/logging-parent/.github/workflows/deploy-snapshot-reusable.yaml@rel/10.6.0 - # Secrets for deployments secrets: - NEXUS_USER: ${{ secrets.NEXUS_USER }} - NEXUS_PW: ${{ secrets.NEXUS_PW }} - with: - java-version: | - 8 - 17 + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - deploy-release: - needs: build - if: github.repository == 'apache/logging-log4j2' && startsWith(github.ref_name, 'release/') - uses: apache/logging-parent/.github/workflows/deploy-release-reusable.yaml@rel/10.6.0 - # Secrets for deployments - secrets: - GPG_SECRET_KEY: ${{ secrets.LOGGING_GPG_SECRET_KEY }} - LOGGING_STAGE_DEPLOYER_USER: ${{ secrets.LOGGING_STAGE_DEPLOYER_USER }} - LOGGING_STAGE_DEPLOYER_PW: ${{ secrets.LOGGING_STAGE_DEPLOYER_PW }} - SVN_USERNAME: ${{ secrets.LOGGING_SVN_DEV_USERNAME }} - SVN_PASSWORD: ${{ secrets.LOGGING_SVN_DEV_PASSWORD }} - # Write permissions to allow the Maven `revision` property update, changelog release, etc. - permissions: - contents: write - with: - java-version: | - 8 - 17 - project-id: log4j - site-enabled: true diff --git a/log4j-api-test/pom.xml b/log4j-api-test/pom.xml index 0ef2578dd8f..2e1f8df4764 100644 --- a/log4j-api-test/pom.xml +++ b/log4j-api-test/pom.xml @@ -164,6 +164,24 @@ + + org.jacoco + jacoco-maven-plugin + + + report-test-coverage + none + + + report-aggregate-test-coverage + + report-aggregate + + verify + + + + org.apache.maven.plugins maven-surefire-plugin diff --git a/log4j-core-test/pom.xml b/log4j-core-test/pom.xml index 1155ed9989b..11e54ff84fd 100644 --- a/log4j-core-test/pom.xml +++ b/log4j-core-test/pom.xml @@ -351,6 +351,24 @@ + + org.jacoco + jacoco-maven-plugin + + + report-test-coverage + none + + + report-aggregate-test-coverage + + report-aggregate + + verify + + + + org.apache.maven.plugins diff --git a/log4j-layout-template-json-test/pom.xml b/log4j-layout-template-json-test/pom.xml index 30b1dac1f84..5629d570ce5 100644 --- a/log4j-layout-template-json-test/pom.xml +++ b/log4j-layout-template-json-test/pom.xml @@ -126,6 +126,24 @@ + + org.jacoco + jacoco-maven-plugin + + + report-test-coverage + none + + + report-aggregate-test-coverage + + report-aggregate + + verify + + + + org.apache.maven.plugins diff --git a/log4j-osgi-test/pom.xml b/log4j-osgi-test/pom.xml index 7f8b52961e9..9d08904ae36 100644 --- a/log4j-osgi-test/pom.xml +++ b/log4j-osgi-test/pom.xml @@ -180,6 +180,24 @@ + + org.jacoco + jacoco-maven-plugin + + + report-test-coverage + none + + + report-aggregate-test-coverage + + report-aggregate + + verify + + + + org.apache.maven.plugins maven-compiler-plugin diff --git a/pom.xml b/pom.xml index 1056c418dc9..e27325e3b9d 100644 --- a/pom.xml +++ b/pom.xml @@ -333,6 +333,8 @@ true true + + 0.8.11 @@ -517,6 +519,18 @@ + + + + + org.jacoco + jacoco-maven-plugin + ${jacoco-maven-plugin.version} + + + + + @@ -536,6 +550,31 @@ + + org.jacoco + jacoco-maven-plugin + + + org/apache/log4j/** + org/apache/logging/log4j/** + + + + + prepare-jacoco-agent + + prepare-agent + + + + report-test-coverage + + report + + + + + From a15be610df1fbf54e1f6791e741e63e147fda89a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 21:33:02 +0000 Subject: [PATCH 2/2] Bump actions/checkout from 4.1.1 to 4.1.2 Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.1 to 4.1.2. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/b4ffde65f46336ab88eb53be808477a3936bae11...9bb56186c3b09b4f86b1c65136769dd318469633) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/build-reusable.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-reusable.yaml b/.github/workflows/build-reusable.yaml index 734d12e1bc5..c38e318c0d9 100644 --- a/.github/workflows/build-reusable.yaml +++ b/.github/workflows/build-reusable.yaml @@ -45,7 +45,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1 + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # 4.1.2 with: # When running on `pull_request` use the PR branch, not the target branch ref: ${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }}