View on GitHub

Bacon @ Red Hat

CLI for ProjectNCL

Alignment Diff

Introduction

During alignment PNC (through Reqour) runs a manipulator on the upstream sources and commits the result on top of the original revision. bacon pnc build get-alignment-diff captures those changes as a diff that applies on top of the original upstream sources, so that the PNC build can be reproduced or reviewed elsewhere.

bacon pnc build get-alignment-diff BRJO2LNIL6QAA

The parts

The diff is split into up to four files, numbered in apply order. Only the files with changes are written.

File Required Content
*-1-build.diff yes The alignment itself: dependency, plugin and property changes, project version rewrites, generated files, anything not recognized
*-2-rerun-state.diff yes for Gradle/sbt GME/SMEG files that apply the alignment at build time (see below)
*-3-reproduce.diff no Removed repositories, to match the PNC build exactly
*-4-noise.diff no PME marker, build output the project does not ignore, PME stamp, reports and backups, formatting-only changes: never affects the build

Every part applies on its own on top of the upstream sources; applying all of them, in any order, reproduces the complete alignment. Applying them in numeric order is recommended:

git apply BRJO2LNIL6QAA-alignment-1-build.diff BRJO2LNIL6QAA-alignment-2-rerun-state.diff

Each file starts with comments describing its content, when it can be skipped, the project and its version change. A file grouping several categories has one commented section per category. The comments also list the removed repositories, the added files no rule recognized (kept in the build part) and any warning; git apply and patch ignore them.

The reproduce part only holds the repositories PNC removed from the pom.xml files, so that the build resolves from the PNC repository only. Apply it to reproduce the PNC build exactly; skip it when building outside PNC, where the removed repositories may still be needed to resolve the dependencies.

Where the diff comes from

The diff is read from the internal repository, either directly from the git provider (GitHub, GitHub Enterprise or GitLab) or through PNC, chosen with scmSource in the active profile (the same setting applies to the build sources):

scmSource Source
auto (default) The git provider, then PNC when the git provider fails or cannot be reached
direct The git provider only, with the profile’s githubToken or gitlabToken
orch PNC only (/builds/<id>/alignment-diff and /builds/<id>/scm-archive/content): PNC reads the repository through Reqour, so no access to the git provider and no git provider token are needed, only to PNC
- name: "default"
  scmSource: orch

Through PNC, the profile’s PNC login is needed (keycloak or ldapUsernamePassword): PNC passes it on to Reqour, which checks it again, so the account needs a role that may read builds in both. When PNC answers that it is busy, or that the git provider is rate-limiting it, the request is retried once if PNC asks to wait at most a minute; otherwise the error says how long to wait.

Through PNC, and directly from GitLab, binary files and files too large for the provider’s diff are included as git binary patches; directly from GitHub they stay Binary files ... differ. When the pre-alignment revision is not an ancestor of the aligned commit, the diff of the aligned commit against its parent is used instead, with a warning.

Internal repositories

The diff is read from the build’s internal repository on GitHub or GitLab (see the configuration guide for the tokens). GitLab does not return binary files, nor patches over its size limit, in a diff: bacon reads those files through the raw file API and writes them as text hunks or GIT binary patch blocks, so the parts still apply. Files that cannot be read, larger than 100 MiB, or read after 512 MiB of such files for the same diff, stay as Binary files ... differ and are listed in a warning; they cannot be applied from the diff.

Secrets in the diff

Known credentials are masked only in the metadata files the manipulators write (reports such as alignmentReport.json and manipulation.json, and their backups), so that the source and build files stay byte-exact and the diff applies. A secret committed in a source or build file of the repository appears in the diff as it is. Review the diff before sharing it outside the people who can read the internal repository.

Options

How the manipulators apply the alignment

The manipulators apply the alignment in two different ways, which is why the rerun-state part mentions GME and SMEG but not PME:

So PME changes never go to the rerun-state part: it is required for Gradle/sbt builds and simply absent for Maven builds. Leave it out only when running GME/SMEG again yourself, as they must start from the upstream state.

Project version

The project version change is reported in the same way whatever the manipulator, on a # Project version: <original> -> <aligned> line at the top of every part, and in the command output. The files holding it are listed in the manifest (--manifest). It is preceded by a # Project: <groupId>:<artifactId> line identifying the project: the root module recorded by the alignment report in the diff (the PME execution root, the GME root project), else the name PNC gave the build (its BREW_BUILD_NAME attribute), else unknown. The project version is read from:

Manipulator Source Part holding the change
PME the version rewritten in the pom.xml files build
GME originalVersion and version in manipulation.json rerun-state
SMEG version := in manipulations.sbt (the original version is not recorded) rerun-state

The project version change is part of the alignment whatever the manipulator, and is never optional: a project often uses its own version elsewhere (e.g. a property referencing its sibling modules), which the manipulator aligns together with the other properties, so the build part does not build without the version rewrite.