diff --git a/.github/workflows/build-reusable.yaml b/.github/workflows/build-reusable.yaml new file mode 100644 index 00000000000..c38e318c0d9 --- /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@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 }} + + - 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 f4baeb62d7f..9efdd5e85f6 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 + + + + +