update matrix to build packages

This commit is contained in:
Michael Legleux
2026-04-21 13:26:53 -07:00
parent eb9da2b331
commit ed77410100
10 changed files with 197 additions and 88 deletions

View File

@@ -32,6 +32,52 @@ We will further set additional CMake arguments as follows:
"""
def build_config_name(os_entry: dict, architecture: dict, build_type: str) -> str:
name = os_entry["distro_name"]
if (n := os_entry["distro_version"]) != "":
name += f"-{n}"
if (n := os_entry["compiler_name"]) != "":
name += f"-{n}"
if (n := os_entry["compiler_version"]) != "":
name += f"-{n}"
platform = architecture["platform"]
name += f"-{platform[platform.find('/') + 1:]}"
name += f"-{build_type.lower()}"
return name
def build_container_image(os_entry: dict) -> str:
return (
f"ghcr.io/xrplf/ci/{os_entry['distro_name']}-{os_entry['distro_version']}:"
f"{os_entry['compiler_name']}-{os_entry['compiler_version']}-sha-{os_entry['image_sha']}"
)
def generate_packaging_matrix(config: Config) -> list:
"""Emit packaging entries for each os entry with a 'packaging' field.
Packaging always uses Release build on linux/amd64.
"""
architecture = next(
(a for a in config.architecture if a["platform"] == "linux/amd64"),
None,
)
if architecture is None:
raise Exception("linux/amd64 architecture required for packaging")
entries = []
for os_entry in config.os:
for pkg_type in os_entry.get("packaging", []):
config_name = build_config_name(os_entry, architecture, "Release")
entries.append(
{
"pkg_type": pkg_type,
"artifact_name": f"xrpld-{config_name}",
"container_image": build_container_image(os_entry),
}
)
return entries
def generate_strategy_matrix(all: bool, config: Config) -> list:
configurations = []
for architecture, os, build_type, cmake_args in itertools.product(
@@ -223,17 +269,7 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
# Generate a unique name for the configuration, e.g. macos-arm64-debug
# or debian-bookworm-gcc-12-amd64-release.
config_name = os["distro_name"]
if (n := os["distro_version"]) != "":
config_name += f"-{n}"
if (n := os["compiler_name"]) != "":
config_name += f"-{n}"
if (n := os["compiler_version"]) != "":
config_name += f"-{n}"
config_name += (
f"-{architecture['platform'][architecture['platform'].find('/')+1:]}"
)
config_name += f"-{build_type.lower()}"
config_name = build_config_name(os, architecture, build_type)
if "-Dcoverage=ON" in cmake_args:
config_name += "-coverage"
if "-Dunity=ON" in cmake_args:
@@ -321,10 +357,19 @@ if __name__ == "__main__":
required=False,
type=Path,
)
parser.add_argument(
"-p",
"--packaging",
help="Emit the packaging matrix (derived from the 'packaging' field on os entries) instead of the build/test matrix.",
action="store_true",
)
args = parser.parse_args()
matrix = []
if args.config is None or args.config == "":
if args.packaging:
config_path = args.config if args.config else THIS_DIR / "linux.json"
matrix += generate_packaging_matrix(read_config(config_path))
elif args.config is None or args.config == "":
matrix += generate_strategy_matrix(
args.all, read_config(THIS_DIR / "linux.json")
)

View File

@@ -120,7 +120,8 @@
"distro_version": "9",
"compiler_name": "gcc",
"compiler_version": "12",
"image_sha": "ab4d1f0"
"image_sha": "ab4d1f0",
"packaging": ["rpm"]
},
{
"distro_name": "rhel",
@@ -162,7 +163,8 @@
"distro_version": "jammy",
"compiler_name": "gcc",
"compiler_version": "12",
"image_sha": "ab4d1f0"
"image_sha": "ab4d1f0",
"packaging": ["deb"]
},
{
"distro_name": "ubuntu",

View File

@@ -157,23 +157,24 @@ jobs:
id: version
uses: ./.github/actions/generate-version
package-deb:
needs: [should-run, build-test, generate-version]
uses: ./.github/workflows/reusable-package.yml
generate-packaging-matrix:
needs: should-run
if: ${{ needs.should-run.outputs.go == 'true' }}
uses: ./.github/workflows/reusable-strategy-matrix.yml
with:
pkg_type: deb
artifact_name: xrpld-ubuntu-jammy-gcc-12-amd64-release
version: ${{ needs.generate-version.outputs.version }}
container_image: ghcr.io/xrplf/ci/ubuntu-jammy:gcc-12@sha256:14e463a9a88060b5a1e579204525c4a6f23afdd0255446f8e4f5415ae0cedac6
mode: packaging
package-rpm:
needs: [should-run, build-test, generate-version]
package:
needs: [should-run, build-test, generate-version, generate-packaging-matrix]
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.generate-packaging-matrix.outputs.matrix) }}
uses: ./.github/workflows/reusable-package.yml
with:
pkg_type: rpm
artifact_name: xrpld-rhel-9-gcc-12-amd64-release
pkg_type: ${{ matrix.pkg_type }}
artifact_name: ${{ matrix.artifact_name }}
version: ${{ needs.generate-version.outputs.version }}
container_image: ghcr.io/xrplf/ci/rhel-9:gcc-12@sha256:196f97b62b8352da1b7cfa91c59d442cc4940eae89a05b547408f62cbddcb8b3
container_image: ${{ matrix.container_image }}
upload-recipe:
needs:

View File

@@ -53,20 +53,20 @@ jobs:
id: version
uses: ./.github/actions/generate-version
package-deb:
needs: [build-test, generate-version]
uses: ./.github/workflows/reusable-package.yml
generate-packaging-matrix:
if: ${{ github.repository == 'XRPLF/rippled' }}
uses: ./.github/workflows/reusable-strategy-matrix.yml
with:
pkg_type: deb
artifact_name: xrpld-ubuntu-jammy-gcc-12-amd64-release
version: ${{ needs.generate-version.outputs.version }}
container_image: ghcr.io/xrplf/ci/ubuntu-jammy:gcc-12@sha256:14e463a9a88060b5a1e579204525c4a6f23afdd0255446f8e4f5415ae0cedac6
mode: packaging
package-rpm:
needs: [build-test, generate-version]
package:
needs: [build-test, generate-version, generate-packaging-matrix]
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.generate-packaging-matrix.outputs.matrix) }}
uses: ./.github/workflows/reusable-package.yml
with:
pkg_type: rpm
artifact_name: xrpld-rhel-9-gcc-12-amd64-release
pkg_type: ${{ matrix.pkg_type }}
artifact_name: ${{ matrix.artifact_name }}
version: ${{ needs.generate-version.outputs.version }}
container_image: ghcr.io/xrplf/ci/rhel-9:gcc-12@sha256:196f97b62b8352da1b7cfa91c59d442cc4940eae89a05b547408f62cbddcb8b3
container_image: ${{ matrix.container_image }}

View File

@@ -116,20 +116,19 @@ jobs:
id: version
uses: ./.github/actions/generate-version
package-deb:
needs: [build-test, generate-version]
uses: ./.github/workflows/reusable-package.yml
generate-packaging-matrix:
uses: ./.github/workflows/reusable-strategy-matrix.yml
with:
pkg_type: deb
artifact_name: xrpld-ubuntu-jammy-gcc-12-amd64-release
version: ${{ needs.generate-version.outputs.version }}
container_image: ghcr.io/xrplf/ci/ubuntu-jammy:gcc-12@sha256:14e463a9a88060b5a1e579204525c4a6f23afdd0255446f8e4f5415ae0cedac6
mode: packaging
package-rpm:
needs: [build-test, generate-version]
package:
needs: [build-test, generate-version, generate-packaging-matrix]
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.generate-packaging-matrix.outputs.matrix) }}
uses: ./.github/workflows/reusable-package.yml
with:
pkg_type: rpm
artifact_name: xrpld-rhel-9-gcc-12-amd64-release
pkg_type: ${{ matrix.pkg_type }}
artifact_name: ${{ matrix.artifact_name }}
version: ${{ needs.generate-version.outputs.version }}
container_image: ghcr.io/xrplf/ci/rhel-9:gcc-12@sha256:196f97b62b8352da1b7cfa91c59d442cc4940eae89a05b547408f62cbddcb8b3
container_image: ${{ matrix.container_image }}

View File

@@ -62,8 +62,8 @@ jobs:
PKG_RELEASE: ${{ inputs.pkg_release }}
run: |
mkdir -p "${BUILD_DIR}/package/rpm"
sed -e "s/@xrpld_version@/${PKG_VERSION}/" \
-e "s/@pkg_release@/${PKG_RELEASE}/" \
sed -e "s|@xrpld_version@|${PKG_VERSION}|" \
-e "s|@pkg_release@|${PKG_RELEASE}|" \
package/rpm/xrpld.spec.in > "${BUILD_DIR}/package/rpm/xrpld.spec"
- name: Build package

View File

@@ -3,6 +3,11 @@ name: Generate strategy matrix
on:
workflow_call:
inputs:
mode:
description: 'What matrix to emit: "build-test" (default) or "packaging".'
required: false
type: string
default: "build-test"
os:
description: 'The operating system to use for the build ("linux", "macos", "windows").'
required: false
@@ -41,5 +46,11 @@ jobs:
id: generate
env:
GENERATE_CONFIG: ${{ inputs.os != '' && format('--config={0}.json', inputs.os) || '' }}
GENERATE_MODE: ${{ inputs.mode == 'packaging' && '--packaging --config=linux.json' || '' }}
GENERATE_OPTION: ${{ inputs.strategy_matrix == 'all' && '--all' || '' }}
run: ./generate.py ${GENERATE_OPTION} ${GENERATE_CONFIG} >> "${GITHUB_OUTPUT}"
run: |
if [ -n "${GENERATE_MODE}" ]; then
./generate.py ${GENERATE_MODE} >> "${GITHUB_OUTPUT}"
else
./generate.py ${GENERATE_OPTION} ${GENERATE_CONFIG} >> "${GITHUB_OUTPUT}"
fi