Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add separate reproducibility check workflow #271

Open
wants to merge 12 commits into
base: feature/deployment-outputs
Choose a base branch
from
28 changes: 22 additions & 6 deletions .github/workflows/build-reusable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ on:
maven-args:
description: Additional Maven arguments
type: string
ref:
description: The branch, tag or SHA to checkout
# When running on `pull_request_target` use the PR branch, not the target branch
default: ${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }}
type: string
repository:
description: GitHub repository name with owner
default: ${{ github.repository }}
type: string
reproducibility-check-enabled:
description: Runs a reproducibility check on the build
default: true
Expand All @@ -39,6 +48,14 @@ on:
description: Flag indicating if Maven `site` goal should be run
default: false
type: boolean
test-report-enabled:
description: Enables the upload of test reports
default: true
type: boolean
test-report-suffix:
description: Suffix to add to the uploaded artifacts
default: ''
type: string

secrets:
DV_ACCESS_TOKEN:
Expand All @@ -64,8 +81,8 @@ jobs:
- name: Checkout repository
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # 4.2.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 }}
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}

- name: Set up Java
uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # 4.4.0
Expand Down Expand Up @@ -105,8 +122,7 @@ jobs:
with:
develocity-access-key: ${{ secrets.DV_ACCESS_TOKEN }}

# 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
# We use `install` instead of `verify`, otherwise the build website step below fails
- name: Build
id: build
shell: bash
Expand All @@ -119,10 +135,10 @@ jobs:

# We upload tests results.
- name: Upload test reports
if: always()
if: ${{ always() && inputs.test-report-enabled }}
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # 4.4.3
with:
name: surefire-${{matrix.os}}-${{github.run_number}}-${{github.run_attempt}}
name: "test-report-${{matrix.os}}-${{github.run_number}}-${{github.run_attempt}}${{inputs.test-report-suffix}}"
path: |
**/target/surefire-reports
**/target/logs
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/deploy-snapshot-reusable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ on:
project-version:
description: The version of the project
value: ${{ jobs.deploy.outputs.project-version }}
# Constant output for similarity with `deploy-release-reusable`
nexus-url:
description: The URL of the Nexus repository used
value: ${{ jobs.deploy.outputs.nexus-url }}
value: https://repository.apache.org/content/repositories/snapshots
secrets:
NEXUS_USERNAME:
description: Nexus snapshot repository username for deploying artifacts
Expand All @@ -44,7 +45,6 @@ jobs:
runs-on: ubuntu-latest
outputs:
project-version: ${{ steps.version.outputs.project-version }}
nexus-url: ${{ steps.nexus.outputs.nexus-url }}
steps:

- name: Checkout repository
Expand Down Expand Up @@ -74,7 +74,6 @@ jobs:
echo "project-version=$PROJECT_VERSION" >> $GITHUB_OUTPUT

- name: Upload to Nexus
id: nexus
shell: bash
env:
# `NEXUS_USERNAME` and `NEXUS_PASSWORD` are used in `~/.m2/settings.xml` created by `setup-java` action
Expand All @@ -85,5 +84,3 @@ jobs:
--show-version --batch-mode --errors --no-transfer-progress \
-P deploy
export NEXUS_URL=$(awk '/^(stagingRepository.url)/ { gsub(/(^.+=|\\)/, ""); print $1 }' target/nexus-staging/staging/*.properties)
# Export repository URL to calling workflow
echo "nexus-url=$NEXUS_URL" >> $GITHUB_OUTPUT
87 changes: 87 additions & 0 deletions .github/workflows/verify-reproducibility-reusable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#
# 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: verify-reproducibility-reusable

on:
workflow_call:
inputs:
java-version:
description: The Java compiler version
default: 17
type: string
maven-args:
description: Additional Maven arguments
type: string
nexus-url:
description: The URL of the reference Nexus repository
type: string
runs-on:
description: The type of runners to use as JSON array
default: '["ubuntu-latest"]'
type: string

env:
MAVEN_ARGS: ${{ inputs.maven-args }}

jobs:

build:

runs-on: ${{ matrix.os }}

strategy:
matrix:
os: ${{ fromJSON(inputs.runs-on) }}

steps:

- name: Checkout repository
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # 4.2.1
with:
ref: ${{ github.ref }}

- name: Set up Java
uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # 4.4.0
with:
distribution: zulu
java-version: ${{ inputs.java-version }}
cache: maven

# `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
shell: bash
run: |
./mvnw \
--show-version --batch-mode --errors --no-transfer-progress \
-DskipTests=true \
-Dreference.repo=${{ inputs.nexus-url }} \
clean verify artifact:compare

# Upload reproducibility results if the build fails.
- name: Upload reproducibility results
if: failure()
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # 4.4.3
with:
name: reproducibility-${{matrix.os}}-${{github.run_number}}-${{github.run_attempt}}
path: |
**/target/bom.xml
**/target/*.buildcompare
**/target/*.jar
**/target/*.zip
**/target/reference/**
11 changes: 11 additions & 0 deletions src/changelog/.11.x.x/verify_reproducibility_reusable.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://logging.apache.org/xml/ns"
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
type="changed">
<issue id="246" link="https://github.com/apache/logging-parent/pull/246"/>
<description format="asciidoc">
Adds a `verify_reproducibility-reusable.yaml` workflow to check reproducibility of artifacts in a Maven repo.
Deprecates the reproducibility check in `build-reusable.yaml`.
</description>
</entry>
4 changes: 3 additions & 1 deletion src/site/antora/modules/ROOT/pages/features.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ The provided reusable GitHub Actions workflows feature the following convenience

{project-github-url}/blob/main/.github/workflows/build-reusable.yaml[`build-reusable.yaml`]::
* Compiles using the specified Java compiler version
* Verifies reproducibility
* Submits build scans to the Develocity server

{project-github-url}/blob/main/.github/workflows/deploy-release-reusable.yaml[`deploy-release-reusable.yaml`]::
Expand All @@ -72,6 +71,9 @@ The provided reusable GitHub Actions workflows feature the following convenience
{project-github-url}/blob/main/.github/workflows/merge-dependabot-reusable.yaml[`merge-dependabot-reusable.yaml`]::
* Merges `dependabot` PRs along with changelog entries

{project-github-url}/blob/main/.github/workflows/merge-dependabot-reusable.yaml[`verify-reproducibility-reusable.yaml`]::
* Verifies reproducibility of a previous deployment workflow.

[#release-instructions]
=== Release instructions

Expand Down
Loading