From 792845b18cb970d3b2a38050c5ad8bd8b8eda528 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 2 Dec 2026 15:25:28 +0000 Subject: [PATCH 1/4] Pin commits, test the DEB in clean containers, stage published cores and payloads manifest.json pins every source component to a full commit SHA (core 9ad3eeb6, the removal of MetaProSIP from OpenMS develop; OpenMS-TOPP-GUI 5e581957; OpenMS-MetaProSIP 56962126, main with the bug fixes) and names its ref, the branch the commit is checked out as, because the version string of OpenMS is made from it. tools/ci/fetch_components.py fetches the components as pinned before the build and records what it fetched. Two more component modes: - published core: the SDK and installer DEB of an OpenMS nightly or release from archive.openms.de, checked to be one build (version, GNU build IDs); the core is unpacked from the DEB into the staging prefix and add-ons built from source build against the SDK; - artifact add-on: the runtime payload of an add-on's CI (e.g. MetaProSIP-payload-Linux-X64), pinned by sha256. cmake/stage_artifact.cmake checks checksum, platform, core build IDs against the staged core, inventory, overwritten files and duplicate registry names before staging. CI tests the DEB as users get it: install-test installs it with APT into a clean Ubuntu 24.04 container that gets only the DEB and MetaProSIP's fixtures (read-only) and reproduces both reference CSVs of MetaProSIP's TOPP test with the installed tool and FuzzyDiff (tools/ci/test_deb_install.sh), then does the same in the runtime image (docker/Dockerfile); upgrade-test installs OpenMS 3.6.0, whose package still contains MetaProSIP, first. build-info.json records the components, the DEB's checksum and the run. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0149aXmZhZtnMkPBQ7zPTrXN --- .github/workflows/build.yml | 237 +++++++++++++++++------ AGENTS.md | 9 +- CLAUDE.md | 9 +- CMakeLists.txt | 322 +++++++++++++++++++++---------- README.md | 121 +++++++++--- cmake/cpack_project_config.cmake | 23 ++- cmake/package.cmake | 46 ++++- cmake/stage_artifact.cmake | 215 +++++++++++++++++++++ cmake/stage_core_deb.cmake | 40 ++++ docker/Dockerfile | 11 ++ manifest.json | 36 ++-- tools/ci/fetch_components.py | 258 +++++++++++++++++++++++++ tools/ci/fetch_fixtures.sh | 50 +++++ tools/ci/test_deb_install.sh | 87 +++++++++ 14 files changed, 1232 insertions(+), 232 deletions(-) create mode 100644 cmake/stage_artifact.cmake create mode 100644 cmake/stage_core_deb.cmake create mode 100644 docker/Dockerfile create mode 100755 tools/ci/fetch_components.py create mode 100755 tools/ci/fetch_fixtures.sh create mode 100755 tools/ci/test_deb_install.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d979b7c..05c4530 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,14 +1,26 @@ name: "Build the Distribution" -# Builds the components of manifest.json (the OpenMS core and its add-ons) with the -# superbuild of this repository, tests the add-ons and the staged installation, and -# builds the combined package. +# Builds the components of a manifest (default manifest.json: the OpenMS core and its +# add-ons, each pinned to a commit) with the superbuild of this repository, tests the +# add-ons and the staged installation, builds the combined DEB, and then tests that DEB +# as users get it: +# install-test installs it into a clean Ubuntu 24.04 container (and into the runtime +# image, docker/Dockerfile) and reproduces the reference CSVs of MetaProSIP +# with the installed tools; +# upgrade-test installs it over OpenMS 3.6.0, whose package still contains MetaProSIP, +# and checks that it replaces that package and owns its files. # -# Pilot: Linux x64, DEB. Each component is checked out at the ref of the manifest -# first (its dependency script has to run before the build), and the superbuild builds -# those checkouts (DIST_SOURCE_DIR_). +# Pilot: Linux x64, DEB. tools/ci/fetch_components.py fetches the components as the +# manifest pins them (source at a commit, a published OpenMS nightly or release, the +# payload artifact of an add-on's CI) before the build, because their dependency scripts +# have to run first. on: workflow_dispatch: + inputs: + manifest: + description: "The manifest to build (a path in this repository)" + type: string + default: "manifest.json" push: branches: - main @@ -23,6 +35,12 @@ concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} +env: + MANIFEST: ${{ inputs.manifest || 'manifest.json' }} + # what the upgrade test installs first: the last OpenMS release whose package contains + # MetaProSIP itself + OLD_OPENMS_DEB_URL: https://archive.openms.de/openms/OpenMSInstaller/release/3.6.0/OpenMS-3.6.0-Debian-Linux-x86_64.deb + jobs: build: runs-on: ubuntu-24.04 @@ -32,60 +50,25 @@ jobs: with: persist-credentials: false - - name: Read the Manifest - id: manifest + # Source components at their pinned commits (checked out as a local branch named + # after their ref, which the version string of OpenMS is made from), with their + # build dependencies; a published core's SDK and installer; payload artifacts of + # add-ons (gh run download, so the token reads the other repositories' runs). + - name: Fetch the Components shell: bash + env: + GH_TOKEN: ${{ github.token }} run: | set -euo pipefail - ref() { jq -r --arg n "$1" '.components[] | select(.name == $n) | .ref' manifest.json; } - { - echo "openms=$(ref OpenMS)" - echo "gui=$(ref OpenMS-TOPP-GUI)" - echo "metaprosip=$(ref OpenMS-MetaProSIP)" - } | tee -a "$GITHUB_OUTPUT" - - # the branch or tag rather than the commit: the full version string of the core is - # made from the name of the branch - - name: Check out OpenMS - uses: actions/checkout@v6 - with: - repository: OpenMS/OpenMS - ref: ${{ steps.manifest.outputs.openms }} - path: _src/OpenMS - persist-credentials: false - - - name: Check out OpenMS-TOPP-GUI - uses: actions/checkout@v6 - with: - repository: OpenMS/OpenMS-TOPP-GUI - ref: ${{ steps.manifest.outputs.gui }} - path: _src/OpenMS-TOPP-GUI - persist-credentials: false - - - name: Check out OpenMS-MetaProSIP - uses: actions/checkout@v6 - with: - repository: OpenMS/OpenMS-MetaProSIP - ref: ${{ steps.manifest.outputs.metaprosip }} - path: _src/OpenMS-MetaProSIP - persist-credentials: false - - # The build dependencies, from the scripts of the components themselves - - name: Install the Dependencies - shell: bash - run: | - set -euxo pipefail - # the vcpkg registry of OpenMS; its history is needed for the version overrides - git -C _src/OpenMS submodule update --init vcpkg - bash _src/OpenMS/tools/ci/deps-ubuntu.sh --skip-gui-deps - bash _src/OpenMS-TOPP-GUI/tools/ci/deps-ubuntu.sh --skip-doc-deps - bash _src/OpenMS-MetaProSIP/tools/ci/deps-ubuntu.sh --skip-doc-deps + python3 tools/ci/fetch_components.py --manifest "$MANIFEST" --dest _src --install-deps # the tests of the GUI need no display echo "QT_QPA_PLATFORM=offscreen" >>"$GITHUB_ENV" - # The vcpkg executable comes from a GitHub release whose download now and then fails - # with a status curl does not retry; bootstrap here, up to 3 times. + # A core built from source only: the vcpkg executable comes from a GitHub release + # whose download now and then fails with a status curl does not retry; bootstrap + # here, up to 3 times. - name: Bootstrap vcpkg + if: ${{ hashFiles('_src/OpenMS/vcpkg.json') != '' }} shell: bash run: | cd _src/OpenMS/vcpkg @@ -98,6 +81,7 @@ jobs: - name: Restore the vcpkg Binary Cache id: vcpkg-cache + if: ${{ hashFiles('_src/OpenMS/vcpkg.json') != '' }} uses: actions/cache/restore@v5 with: path: ${{ github.workspace }}/.vcpkg-cache @@ -113,16 +97,13 @@ jobs: set -euxo pipefail mkdir -p "$GITHUB_WORKSPACE/.vcpkg-cache" export VCPKG_BINARY_SOURCES="clear;files,$GITHUB_WORKSPACE/.vcpkg-cache,readwrite" - cmake -S . -B build -G Ninja \ - -DDIST_PACKAGE_TYPE=deb \ - "-DDIST_SOURCE_DIR_OpenMS=$GITHUB_WORKSPACE/_src/OpenMS" \ - "-DDIST_SOURCE_DIR_OpenMS_TOPP_GUI=$GITHUB_WORKSPACE/_src/OpenMS-TOPP-GUI" \ - "-DDIST_SOURCE_DIR_OpenMS_MetaProSIP=$GITHUB_WORKSPACE/_src/OpenMS-MetaProSIP" + mapfile -t component_args <_src/cmake-args.txt + cmake -S . -B build -G Ninja -DDIST_PACKAGE_TYPE=deb "${component_args[@]}" cmake --build build # Saved once the dependencies are built, also when a later step fails - name: Save the vcpkg Binary Cache - if: ${{ !cancelled() && steps.vcpkg-cache.outputs.cache-matched-key != steps.vcpkg-cache.outputs.cache-primary-key && hashFiles('.vcpkg-cache/**') != '' }} + if: ${{ !cancelled() && steps.vcpkg-cache.outcome == 'success' && steps.vcpkg-cache.outputs.cache-matched-key != steps.vcpkg-cache.outputs.cache-primary-key && hashFiles('.vcpkg-cache/**') != '' }} uses: actions/cache/save@v5 with: path: ${{ github.workspace }}/.vcpkg-cache @@ -136,9 +117,145 @@ jobs: shell: bash run: cmake --build build --target package + # What exactly went into the package: the components as fetched (commits, published + # core version, SDK/installer checksums and build IDs, payload checksums and the runs + # that built them), the package and its checksum, and this run. + - name: Record the Build + shell: bash + env: + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + DIST_COMMIT: ${{ github.event.pull_request.head.sha || github.sha }} + run: | + set -euo pipefail + shopt -s nullglob + debs=(build/*.deb) + [[ ${#debs[@]} -eq 1 ]] || { echo "expected one DEB in build/, found ${#debs[@]}" >&2; exit 1; } + python3 - "${debs[0]}" <<'EOF' + import hashlib, json, os, subprocess, sys + deb = sys.argv[1] + record = json.load(open("_src/components.json")) + field = lambda f: subprocess.run(["dpkg-deb", "-f", deb, f], check=True, capture_output=True, text=True).stdout.strip() + record["package"] = { + "file": os.path.basename(deb), + "sha256": hashlib.sha256(open(deb, "rb").read()).hexdigest(), + "name": field("Package"), + "version": field("Version"), + } + record["distribution"] = {"commit": os.environ["DIST_COMMIT"], "manifest": os.environ["MANIFEST"]} + record["run"] = os.environ["RUN_URL"] + record["runner"] = {"os": os.environ.get("ImageOS", ""), "image_version": os.environ.get("ImageVersion", "")} + json.dump(record, open("build/build-info.json", "w"), indent=2) + print(json.dumps(record, indent=2)) + EOF + - name: Upload the Package uses: actions/upload-artifact@v4 with: name: OpenMS-Distribution-deb - path: build/*.deb + path: | + build/*.deb + build/build-info.json if-no-files-found: error + + # The DEB as users get it, in a clean Ubuntu 24.04 container (the release the build + # runner has): it gets only the DEB (/artifacts) and the fixtures of OpenMS-MetaProSIP at + # the commit the shipped tool was built from (/fixtures), both read-only. Then the same in + # the runtime image (docker/Dockerfile). + install-test: + needs: build + runs-on: ubuntu-24.04 + timeout-minutes: 60 + steps: + - uses: actions/checkout@v6 + with: + persist-credentials: false + sparse-checkout: | + tools/ci + docker + + - name: Download the Package + uses: actions/download-artifact@v4 + with: + name: OpenMS-Distribution-deb + path: ${{ runner.temp }}/package + + - name: Fetch the Fixtures of MetaProSIP + shell: bash + env: + PACKAGE_DIR: ${{ runner.temp }}/package + FIXTURES_CHECKOUT: ${{ runner.temp }}/metaprosip + run: bash tools/ci/fetch_fixtures.sh "$PACKAGE_DIR/build-info.json" "$FIXTURES_CHECKOUT" + + - name: Install into a Clean Container + shell: bash + env: + PACKAGE_DIR: ${{ runner.temp }}/package + FIXTURES: ${{ runner.temp }}/metaprosip/src/tests/topp + run: | + set -euo pipefail + mkdir -p "$RUNNER_TEMP/artifacts" + cp "$PACKAGE_DIR"/*.deb "$RUNNER_TEMP/artifacts/" + docker run --rm \ + -v "$RUNNER_TEMP/artifacts:/artifacts:ro" \ + -v "$FIXTURES:/fixtures:ro" \ + -v "$GITHUB_WORKSPACE/tools/ci:/ci:ro" \ + ubuntu:24.04 bash /ci/test_deb_install.sh + + - name: Test the Runtime Image + shell: bash + env: + FIXTURES: ${{ runner.temp }}/metaprosip/src/tests/topp + run: | + set -euo pipefail + docker build -f docker/Dockerfile -t openms-distribution:test "$RUNNER_TEMP/artifacts" + docker run --rm -e SKIP_INSTALL=1 \ + -v "$FIXTURES:/fixtures:ro" \ + -v "$GITHUB_WORKSPACE/tools/ci:/ci:ro" \ + openms-distribution:test bash /ci/test_deb_install.sh + + # Upgrade from the last OpenMS release that contained MetaProSIP (package openms 3.6.0): + # the distribution DEB must replace it, own MetaProSIP afterwards, and work. + upgrade-test: + needs: build + runs-on: ubuntu-24.04 + timeout-minutes: 60 + steps: + - uses: actions/checkout@v6 + with: + persist-credentials: false + sparse-checkout: tools/ci + + - name: Download the Package + uses: actions/download-artifact@v4 + with: + name: OpenMS-Distribution-deb + path: ${{ runner.temp }}/package + + - name: Fetch the Fixtures of MetaProSIP + shell: bash + env: + PACKAGE_DIR: ${{ runner.temp }}/package + FIXTURES_CHECKOUT: ${{ runner.temp }}/metaprosip + run: bash tools/ci/fetch_fixtures.sh "$PACKAGE_DIR/build-info.json" "$FIXTURES_CHECKOUT" + + - name: Download the Old OpenMS Package + shell: bash + run: | + mkdir -p "$RUNNER_TEMP/old" + curl --fail --silent --show-error --location --retry 3 -o "$RUNNER_TEMP/old/openms-old.deb" "$OLD_OPENMS_DEB_URL" + + - name: Upgrade in a Clean Container + shell: bash + env: + PACKAGE_DIR: ${{ runner.temp }}/package + FIXTURES: ${{ runner.temp }}/metaprosip/src/tests/topp + run: | + set -euo pipefail + mkdir -p "$RUNNER_TEMP/artifacts" + cp "$PACKAGE_DIR"/*.deb "$RUNNER_TEMP/artifacts/" + docker run --rm -e OLD_DEB=/old/openms-old.deb \ + -v "$RUNNER_TEMP/old:/old:ro" \ + -v "$RUNNER_TEMP/artifacts:/artifacts:ro" \ + -v "$FIXTURES:/fixtures:ro" \ + -v "$GITHUB_WORKSPACE/tools/ci:/ci:ro" \ + ubuntu:24.04 bash /ci/test_deb_install.sh diff --git a/AGENTS.md b/AGENTS.md index 524949a..5bdc284 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -3,7 +3,8 @@ A superbuild that builds the OpenMS core and its add-ons (manifest.json) into one staging prefix, tests them together and builds one package. See `README.md`. -- Configure: `cmake -S . -B build -G Ninja [-DDIST_PACKAGE_TYPE=deb] [-DDIST_SOURCE_DIR_=]` +- Fetch: `python3 tools/ci/fetch_components.py --manifest manifest.json --dest _src [--install-deps]` +- Configure: `cmake -S . -B build -G Ninja [-DDIST_PACKAGE_TYPE=deb] $(cat _src/cmake-args.txt)` - Build: `cmake --build build` (builds and tests every component; the core takes long) - Test: `ctest --test-dir build --output-on-failure` (the staged installation as a whole) - Package: `cmake --build build --target package` @@ -13,7 +14,11 @@ tests them together and builds one package. See `README.md`. - The components are built as they are; a change a component needs belongs in its repository (a PR there), not in a patch applied here. - The add-ons must have the version of the core (`find_package(OpenMS EXACT)`); bump - `version` and all refs together. + `version` and all pinned commits together. Pin full commit SHAs; `ref` is the branch name the + version string of OpenMS is made from. +- An artifact add-on (a payload of the add-on's CI) can only be combined with the core build it + was built against (GNU build IDs, `cmake/stage_artifact.cmake`): use the published core whose + SDK the add-on's CI used. Never relax that check. - An add-on's tests run before it is installed into the staging prefix: afterwards its build-tree tool registry would register its tools a second time. - When CI fails, investigate the root cause in the component before changing the superbuild. diff --git a/CLAUDE.md b/CLAUDE.md index e22b642..7fe9e26 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -3,7 +3,8 @@ A superbuild that builds the OpenMS core and its add-ons (manifest.json) into one staging prefix, tests them together and builds one package. See `README.md`. -- Configure: `cmake -S . -B build -G Ninja [-DDIST_PACKAGE_TYPE=deb] [-DDIST_SOURCE_DIR_=]` +- Fetch: `python3 tools/ci/fetch_components.py --manifest manifest.json --dest _src [--install-deps]` +- Configure: `cmake -S . -B build -G Ninja [-DDIST_PACKAGE_TYPE=deb] $(cat _src/cmake-args.txt)` - Build: `cmake --build build` (builds and tests every component; the core takes long) - Test: `ctest --test-dir build --output-on-failure` (the staged installation as a whole) - Package: `cmake --build build --target package` @@ -13,7 +14,11 @@ tests them together and builds one package. See `README.md`. - The components are built as they are; a change a component needs belongs in its repository (a PR there), not in a patch applied here. - The add-ons must have the version of the core (`find_package(OpenMS EXACT)`); bump - `version` and all refs together. + `version` and all pinned commits together. Pin full commit SHAs; `ref` is the branch name the + version string of OpenMS is made from. +- An artifact add-on (a payload of the add-on's CI) can only be combined with the core build it + was built against (GNU build IDs, `cmake/stage_artifact.cmake`): use the published core whose + SDK the add-on's CI used. Never relax that check. - An add-on's tests run before it is installed into the staging prefix: afterwards its build-tree tool registry would register its tools a second time. - When CI fails, investigate the root cause in the component before changing the superbuild. diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ac1ee1..5be73f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,27 +9,35 @@ #------------------------------------------------------------------------------ # OpenMS-Distribution: one installer of OpenMS together with its add-ons. # -# A superbuild over the components in manifest.json (each pinned to a ref): -# 1. the core (OpenMS) is built with its own preset and vcpkg, and installed into a -# staging prefix (DIST_STAGE_DIR); -# 2. each add-on (OpenMS-TOPP-GUI, OpenMS-MetaProSIP, ...) is built against that -# staging prefix exactly as against any installed OpenMS (find_package), its tests -# run, and it is installed into the same prefix; +# A superbuild over the components of a manifest (manifest.json; see README.md): +# 1. the core (OpenMS) goes into a staging prefix (DIST_STAGE_DIR): built from source +# with its own preset and vcpkg, or (published) unpacked from the DEB of an OpenMS +# nightly or release, whose SDK the add-ons then build against; +# 2. each add-on (OpenMS-TOPP-GUI, OpenMS-MetaProSIP, ...) goes into the same prefix: +# built from source against the core exactly as against any installed OpenMS +# (find_package), its tests run before it is installed; or (artifact) the runtime +# payload its own CI built and tested, after checking that it was built against +# exactly this core (GNU build IDs), that it is what its metadata lists, and that it +# overwrites nothing and registers no tool a second time (cmake/stage_artifact.cmake); # 3. the tests of this project check the staged installation as a whole (one tool # registry, every registered tool present and starting without help); -# 4. with DIST_PACKAGE_TYPE set, every component is reconfigured with that package -# type (as the release workflow of OpenMS does: build and test with PACKAGE_TYPE -# none, then reconfigure and package without relinking), and the target 'package' -# builds ONE package from the install components of all of them -# (CPACK_INSTALL_CMAKE_PROJECTS). +# 4. with DIST_PACKAGE_TYPE set, the components built from source are reconfigured with +# that package type (as the release workflow of OpenMS does: build and test with +# PACKAGE_TYPE none, then reconfigure and package without relinking), and the target +# 'package' builds ONE package from all components: the install components of those +# built here (CPACK_INSTALL_CMAKE_PROJECTS), the unpacked published core and the +# payloads (CPACK_INSTALLED_DIRECTORIES). # -# cmake -S . -B build -G Ninja [-DDIST_PACKAGE_TYPE=deb] +# python3 tools/ci/fetch_components.py --manifest manifest.json --dest _src +# cmake -S . -B build -G Ninja [-DDIST_PACKAGE_TYPE=deb] $(cat _src/cmake-args.txt) # cmake --build build # 1, 2 (and 4) # ctest --test-dir build # 3 # cmake --build build --target package # -# DIST_SOURCE_DIR_ (e.g. DIST_SOURCE_DIR_OpenMS_MetaProSIP) builds a local -# checkout instead of cloning the ref of the manifest. +# tools/ci/fetch_components.py fetches the components as the manifest pins them and writes +# the arguments that point the superbuild at them (DIST_SOURCE_DIR_, +# DIST_CORE_SDK_DIR and DIST_CORE_DEB, DIST_ARTIFACT_DIR_). Without +# DIST_SOURCE_DIR_, a source component is cloned at its pinned commit. #------------------------------------------------------------------------------ cmake_minimum_required(VERSION 3.24 FATAL_ERROR) @@ -40,17 +48,20 @@ include(ExternalProject) #------------------------------------------------------------------------------ # Options #------------------------------------------------------------------------------ -option(DIST_ENABLE_TESTING "Run the tests of each add-on before installing it, and add the tests of the staged installation." ON) -option(DIST_TEST_CORE "Also build and run the class and TOPP tests of the OpenMS core (long)." OFF) +option(DIST_ENABLE_TESTING "Run the tests of each add-on built from source before installing it, and add the tests of the staged installation." ON) +option(DIST_TEST_CORE "Also build and run the class and TOPP tests of the OpenMS core when it is built from source (long)." OFF) set(DIST_PACKAGE_TYPE "none" CACHE STRING "The combined package: none, deb or tgz") set_property(CACHE DIST_PACKAGE_TYPE PROPERTY STRINGS none deb tgz) if(NOT DIST_PACKAGE_TYPE MATCHES "^(none|deb|tgz)$") message(FATAL_ERROR "DIST_PACKAGE_TYPE must be none, deb or tgz (is '${DIST_PACKAGE_TYPE}')") endif() +set(DIST_MANIFEST "${PROJECT_SOURCE_DIR}/manifest.json" CACHE FILEPATH "The manifest of the distribution") set(DIST_STAGE_DIR "${PROJECT_BINARY_DIR}/stage" CACHE PATH "The staging prefix the core and the add-ons are installed into") set(DIST_BUILD_TYPE "Release" CACHE STRING "CMAKE_BUILD_TYPE of the add-ons (the core uses its preset)") set(DIST_ADDON_PREFIX_PATH "" CACHE STRING "Further CMAKE_PREFIX_PATH entries of the add-ons (';'-separated), e.g. Qt") -set(DIST_OPENMS_CMAKE_ARGS "" CACHE STRING "Further configure arguments of the core (';'-separated)") +set(DIST_OPENMS_CMAKE_ARGS "" CACHE STRING "Further configure arguments of the core built from source (';'-separated)") +set(DIST_CORE_SDK_DIR "" CACHE PATH "Published core: the unpacked OpenMS SDK (tools/ci/fetch_components.py)") +set(DIST_CORE_DEB "" CACHE FILEPATH "Published core: the OpenMS installer DEB of the same build as the SDK") ## The preset of the core (CMakePresets.json of OpenMS) if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)$") @@ -67,143 +78,219 @@ set(DIST_OPENMS_PRESET "${_default_preset}" CACHE STRING "The CMake preset of Op #------------------------------------------------------------------------------ # The manifest #------------------------------------------------------------------------------ -set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/manifest.json") -file(READ "${PROJECT_SOURCE_DIR}/manifest.json" _manifest) +set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${DIST_MANIFEST}") +file(READ "${DIST_MANIFEST}" _manifest) string(JSON DIST_VERSION GET "${_manifest}" version) string(JSON _component_count LENGTH "${_manifest}" components) math(EXPR _last "${_component_count} - 1") -set(DIST_COMPONENTS) # the ExternalProject targets, core first +## the value of an optional member, or +function(_dist_json_or out_var default) + string(JSON _value ERROR_VARIABLE _error GET "${_manifest}" ${ARGN}) + if(_error) + set(_value "${default}") + endif() + set(${out_var} "${_value}" PARENT_SCOPE) +endfunction() + +set(DIST_COMPONENTS) # the components, core first set(DIST_CORE "") foreach(_i RANGE ${_last}) string(JSON _name GET "${_manifest}" components ${_i} name) - string(JSON _repo GET "${_manifest}" components ${_i} repository) - string(JSON _ref GET "${_manifest}" components ${_i} ref) string(JSON _kind GET "${_manifest}" components ${_i} kind) - string(JSON _pc_count LENGTH "${_manifest}" components ${_i} packaged_components) + _dist_json_or(_repo "" components ${_i} repository) + _dist_json_or(_ref "" components ${_i} ref) + _dist_json_or(_commit "" components ${_i} commit) + _dist_json_or(_deb_package "" components ${_i} deb_package) + _dist_json_or(_published "" components ${_i} published) + _dist_json_or(_artifact "" components ${_i} artifact) + string(MAKE_C_IDENTIFIER "${_name}" _id) + set(DIST_${_id}_NAME "${_name}") + set(DIST_${_id}_KIND "${_kind}") + set(DIST_${_id}_REPOSITORY "${_repo}") + set(DIST_${_id}_REF "${_ref}") + set(DIST_${_id}_COMMIT "${_commit}") + if(_deb_package STREQUAL "") + string(TOLOWER "${_name}" _deb_package) + endif() + set(DIST_${_id}_DEB_PACKAGE "${_deb_package}") + set(_packaged) - if(_pc_count GREATER 0) + string(JSON _pc_count ERROR_VARIABLE _error LENGTH "${_manifest}" components ${_i} packaged_components) + if(NOT _error AND _pc_count GREATER 0) math(EXPR _pc_last "${_pc_count} - 1") foreach(_j RANGE ${_pc_last}) string(JSON _pc GET "${_manifest}" components ${_i} packaged_components ${_j}) list(APPEND _packaged "${_pc}") endforeach() endif() - string(MAKE_C_IDENTIFIER "${_name}" _id) - set(DIST_${_id}_NAME "${_name}") - set(DIST_${_id}_REPOSITORY "${_repo}") - set(DIST_${_id}_REF "${_ref}") - set(DIST_${_id}_KIND "${_kind}") set(DIST_${_id}_PACKAGED_COMPONENTS ${_packaged}) - set(DIST_SOURCE_DIR_${_id} "" CACHE PATH "Local checkout of ${_name} to build instead of ${_repo} at ${_ref}") + if(_kind STREQUAL "core") if(DIST_CORE) - message(FATAL_ERROR "manifest.json: more than one component of kind 'core' (${DIST_CORE}, ${_id})") + message(FATAL_ERROR "${DIST_MANIFEST}: more than one component of kind 'core' (${DIST_CORE}, ${_id})") + endif() + if(_artifact) + message(FATAL_ERROR "${DIST_MANIFEST}: the core cannot be an artifact (use 'published')") endif() set(DIST_CORE ${_id}) list(PREPEND DIST_COMPONENTS ${_id}) + set(DIST_${_id}_MODE source) + if(_published) + set(DIST_${_id}_MODE published) + endif() elseif(_kind STREQUAL "addon") + if(_published) + message(FATAL_ERROR "${DIST_MANIFEST}: ${_name}: only the core can be 'published'") + endif() list(APPEND DIST_COMPONENTS ${_id}) + set(DIST_${_id}_MODE source) + if(_artifact) + set(DIST_${_id}_MODE artifact) + string(JSON DIST_${_id}_ARTIFACT_SHA256 GET "${_artifact}" sha256) + set(DIST_ARTIFACT_DIR_${_id} "" CACHE PATH "${_name}: the downloaded payload artifact (tools/ci/fetch_components.py)") + endif() else() - message(FATAL_ERROR "manifest.json: component ${_name} has the unknown kind '${_kind}' (core or addon)") + message(FATAL_ERROR "${DIST_MANIFEST}: component ${_name} has the unknown kind '${_kind}' (core or addon)") endif() - if(DIST_SOURCE_DIR_${_id}) - message(STATUS "${_name}: local checkout ${DIST_SOURCE_DIR_${_id}}") + + if(DIST_${_id}_MODE STREQUAL "source") + if(_repo STREQUAL "" OR _commit STREQUAL "") + message(FATAL_ERROR "${DIST_MANIFEST}: ${_name} is built from source and needs 'repository' and 'commit'") + endif() + set(DIST_SOURCE_DIR_${_id} "" CACHE PATH "Local checkout of ${_name} to build instead of ${_repo} at ${_commit}") + if(DIST_SOURCE_DIR_${_id}) + message(STATUS "${_name}: source, local checkout ${DIST_SOURCE_DIR_${_id}}") + else() + message(STATUS "${_name}: source, ${_repo} at ${_commit} (${_ref})") + endif() + elseif(DIST_${_id}_MODE STREQUAL "published") + if(NOT IS_DIRECTORY "${DIST_CORE_SDK_DIR}" OR NOT EXISTS "${DIST_CORE_DEB}") + message(FATAL_ERROR "${_name} is a published core: set DIST_CORE_SDK_DIR and DIST_CORE_DEB " + "(tools/ci/fetch_components.py fetches both and writes the arguments)") + endif() + file(STRINGS "${DIST_CORE_SDK_DIR}/lib/cmake/OpenMS/OpenMSConfig.cmake" _fs REGEX "^set\\(OpenMS_VERSION_FULLSTRING ") + string(REGEX REPLACE "^set\\(OpenMS_VERSION_FULLSTRING \"([^\"]*)\"\\).*" "\\1" DIST_CORE_FULLSTRING "${_fs}") + message(STATUS "${_name}: published, OpenMS ${DIST_CORE_FULLSTRING} (SDK ${DIST_CORE_SDK_DIR}, installer ${DIST_CORE_DEB})") else() - message(STATUS "${_name}: ${_repo} at ${_ref}") + if(NOT IS_DIRECTORY "${DIST_ARTIFACT_DIR_${_id}}") + message(FATAL_ERROR "${_name} is an artifact: set DIST_ARTIFACT_DIR_${_id} " + "(tools/ci/fetch_components.py downloads it and writes the argument)") + endif() + message(STATUS "${_name}: artifact ${DIST_ARTIFACT_DIR_${_id}}") endif() endforeach() if(NOT DIST_CORE) - message(FATAL_ERROR "manifest.json: no component of kind 'core'") + message(FATAL_ERROR "${DIST_MANIFEST}: no component of kind 'core'") endif() message(STATUS "OpenMS distribution ${DIST_VERSION}, staged in ${DIST_STAGE_DIR}") -## Where the sources come from: a local checkout, or a clone of the ref +## Where the sources of a component built from source come from: a local checkout, or a +## clone of the pinned commit function(_dist_source_args out_var id) - set(_args) if(DIST_SOURCE_DIR_${id}) - list(APPEND _args SOURCE_DIR "${DIST_SOURCE_DIR_${id}}" DOWNLOAD_COMMAND "" UPDATE_COMMAND "") + set(_args SOURCE_DIR "${DIST_SOURCE_DIR_${id}}" DOWNLOAD_COMMAND "" UPDATE_COMMAND "") else() - list(APPEND _args GIT_REPOSITORY "${DIST_${id}_REPOSITORY}" GIT_TAG "${DIST_${id}_REF}" GIT_PROGRESS TRUE - UPDATE_DISCONNECTED TRUE) - ## a shallow clone needs a branch or tag; a commit is cloned in full - if(NOT DIST_${id}_REF MATCHES "^[0-9a-f]+$") - list(APPEND _args GIT_SHALLOW TRUE) - endif() + set(_args GIT_REPOSITORY "${DIST_${id}_REPOSITORY}" GIT_TAG "${DIST_${id}_COMMIT}" GIT_PROGRESS TRUE + UPDATE_DISCONNECTED TRUE) endif() set(${out_var} ${_args} PARENT_SCOPE) endfunction() -## Reconfiguring a component for packaging (DIST_PACKAGE_TYPE): the core installs its -## runtime dependencies (vcpkg libraries) and the add-ons drop the RPATH entries of the -## staging prefix only with a package type. Linux packages of the components are DEB ones; -## the generator of the combined package is chosen below. +## Reconfiguring a component built from source for packaging (DIST_PACKAGE_TYPE): the core +## installs its runtime dependencies (vcpkg libraries) and the add-ons drop the RPATH +## entries of the staging prefix only with a package type. Linux packages of the +## components are DEB ones; the generator of the combined package is chosen below. if(NOT DIST_PACKAGE_TYPE STREQUAL "none") set(_component_package_type deb) endif() +function(_dist_package_configure id) + if(_component_package_type) + ExternalProject_Add_Step(${id} package_configure + COMMAND ${CMAKE_COMMAND} -DPACKAGE_TYPE=${_component_package_type} + DEPENDEES install + COMMENT "Reconfiguring ${DIST_${id}_NAME} for packaging (PACKAGE_TYPE=${_component_package_type})" + ) + endif() +endfunction() #------------------------------------------------------------------------------ # The core #------------------------------------------------------------------------------ -_dist_source_args(_core_source ${DIST_CORE}) -if(NOT DIST_SOURCE_DIR_${DIST_CORE}) - ## the vcpkg registry of OpenMS (its history is needed for the version overrides) - list(APPEND _core_source GIT_SUBMODULES vcpkg) -endif() -if(DIST_TEST_CORE) - set(_core_testing -DENABLE_CLASS_TESTING=ON -DENABLE_TOPP_TESTING=ON) - set(_core_test_args TEST_BEFORE_INSTALL TRUE TEST_COMMAND ${CMAKE_COMMAND} -E chdir ctest --output-on-failure) -else() - set(_core_testing -DENABLE_CLASS_TESTING=OFF -DENABLE_TOPP_TESTING=OFF) - set(_core_test_args) -endif() -string(REPLACE ";" "|" _core_extra_args "${DIST_OPENMS_CMAKE_ARGS}") +if(DIST_${DIST_CORE}_MODE STREQUAL "source") + _dist_source_args(_core_source ${DIST_CORE}) + if(NOT DIST_SOURCE_DIR_${DIST_CORE}) + ## the vcpkg registry of OpenMS (its history is needed for the version overrides) + list(APPEND _core_source GIT_SUBMODULES vcpkg) + endif() + if(DIST_TEST_CORE) + set(_core_testing -DENABLE_CLASS_TESTING=ON -DENABLE_TOPP_TESTING=ON) + set(_core_test_args TEST_BEFORE_INSTALL TRUE TEST_COMMAND ${CMAKE_COMMAND} -E chdir ctest --output-on-failure) + else() + set(_core_testing -DENABLE_CLASS_TESTING=OFF -DENABLE_TOPP_TESTING=OFF) + set(_core_test_args) + endif() + string(REPLACE ";" "|" _core_extra_args "${DIST_OPENMS_CMAKE_ARGS}") -## The configuration of the core is the one OpenMS-TOPP-GUI and OpenMS-MetaProSIP build -## their CI core with (.github/actions/openms-core there): the libraries and the TOPP -## tools, none of the optional dependencies that take long to build (ONNX Runtime, the -## Thermo bridge). -ExternalProject_Add(${DIST_CORE} - ${_core_source} - PREFIX "${PROJECT_BINARY_DIR}/${DIST_CORE}" - BINARY_DIR "${PROJECT_BINARY_DIR}/${DIST_CORE}/build" - LIST_SEPARATOR | - CONFIGURE_COMMAND ${CMAKE_COMMAND} -E chdir - ${CMAKE_COMMAND} --preset ${DIST_OPENMS_PRESET} -B - -DCMAKE_INSTALL_PREFIX=${DIST_STAGE_DIR} - "-DVCPKG_MANIFEST_FEATURES=isospec|eol-bspline|simde|nlohmann-json|sqlitecpp|opentims" - -DBUILD_TOPP_TOOLS=ON - -DINSTALL_OPENMS_EXAMPLES=ON - ${_core_testing} - -DENABLE_DOCS=OFF - -DENABLE_TUTORIALS=OFF - -DOPENMS_TEST_INSTALLED_CONSUMER=OFF - -DOPENMS_VERIFY_INTERFACE_HEADER_SETS=OFF - -DWITH_ONNX=OFF - -DWITH_THERMO_RAW=OFF - -DPACKAGE_TYPE=none - ${_core_extra_args} - BUILD_COMMAND ${CMAKE_COMMAND} --build - ${_core_test_args} - INSTALL_COMMAND ${CMAKE_COMMAND} --install - USES_TERMINAL_CONFIGURE TRUE - USES_TERMINAL_BUILD TRUE -) -if(_component_package_type) - ExternalProject_Add_Step(${DIST_CORE} package_configure - COMMAND ${CMAKE_COMMAND} -DPACKAGE_TYPE=${_component_package_type} - DEPENDEES install - COMMENT "Reconfiguring ${DIST_${DIST_CORE}_NAME} for packaging (PACKAGE_TYPE=${_component_package_type})" + ## The configuration of the core is the one OpenMS-TOPP-GUI and OpenMS-MetaProSIP build + ## their CI core with (.github/actions/openms-core there): the libraries and the TOPP + ## tools, none of the optional dependencies that take long to build (ONNX Runtime, the + ## Thermo bridge). + ExternalProject_Add(${DIST_CORE} + ${_core_source} + PREFIX "${PROJECT_BINARY_DIR}/${DIST_CORE}" + BINARY_DIR "${PROJECT_BINARY_DIR}/${DIST_CORE}/build" + LIST_SEPARATOR | + CONFIGURE_COMMAND ${CMAKE_COMMAND} -E chdir + ${CMAKE_COMMAND} --preset ${DIST_OPENMS_PRESET} -B + -DCMAKE_INSTALL_PREFIX=${DIST_STAGE_DIR} + "-DVCPKG_MANIFEST_FEATURES=isospec|eol-bspline|simde|nlohmann-json|sqlitecpp|opentims" + -DBUILD_TOPP_TOOLS=ON + -DINSTALL_OPENMS_EXAMPLES=ON + ${_core_testing} + -DENABLE_DOCS=OFF + -DENABLE_TUTORIALS=OFF + -DOPENMS_TEST_INSTALLED_CONSUMER=OFF + -DOPENMS_VERIFY_INTERFACE_HEADER_SETS=OFF + -DWITH_ONNX=OFF + -DWITH_THERMO_RAW=OFF + -DPACKAGE_TYPE=none + ${_core_extra_args} + BUILD_COMMAND ${CMAKE_COMMAND} --build + ${_core_test_args} + INSTALL_COMMAND ${CMAKE_COMMAND} --install + USES_TERMINAL_CONFIGURE TRUE + USES_TERMINAL_BUILD TRUE + ) + _dist_package_configure(${DIST_CORE}) + ## the add-ons build against the staged core + set(_addon_core_prefix "${DIST_STAGE_DIR}") +else() + ## The published core: the installer DEB unpacked into the staging prefix (and into + ## //payload for the package); the add-ons build against its SDK, which + ## tools/ci/fetch_components.py checked to be of the same build (GNU build IDs). + set(DIST_${DIST_CORE}_PAYLOAD_DIR "${PROJECT_BINARY_DIR}/${DIST_CORE}/payload") + ExternalProject_Add(${DIST_CORE} + PREFIX "${PROJECT_BINARY_DIR}/${DIST_CORE}" + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND ${CMAKE_COMMAND} -DDEB=${DIST_CORE_DEB} + -DPAYLOAD_DIR=${DIST_${DIST_CORE}_PAYLOAD_DIR} + -DSTAGE_DIR=${DIST_STAGE_DIR} + -P "${PROJECT_SOURCE_DIR}/cmake/stage_core_deb.cmake" ) + set(_addon_core_prefix "${DIST_CORE_SDK_DIR}") endif() #------------------------------------------------------------------------------ -# The add-ons: built against the staged core like against any installed OpenMS +# The add-ons built from source: against the core like against any installed OpenMS #------------------------------------------------------------------------------ -set(_addon_prefix_path "${DIST_STAGE_DIR}" ${DIST_ADDON_PREFIX_PATH}) +set(_addon_prefix_path "${_addon_core_prefix}" ${DIST_ADDON_PREFIX_PATH}) string(REPLACE ";" "|" _addon_prefix_path "${_addon_prefix_path}") +set(_source_addons) foreach(_id IN LISTS DIST_COMPONENTS) - if(_id STREQUAL DIST_CORE) + if(NOT DIST_${_id}_KIND STREQUAL "addon" OR NOT DIST_${_id}_MODE STREQUAL "source") continue() endif() _dist_source_args(_addon_source ${_id}) @@ -230,13 +317,36 @@ foreach(_id IN LISTS DIST_COMPONENTS) USES_TERMINAL_CONFIGURE TRUE USES_TERMINAL_BUILD TRUE ) - if(_component_package_type) - ExternalProject_Add_Step(${_id} package_configure - COMMAND ${CMAKE_COMMAND} -DPACKAGE_TYPE=${_component_package_type} - DEPENDEES install - COMMENT "Reconfiguring ${DIST_${_id}_NAME} for packaging (PACKAGE_TYPE=${_component_package_type})" - ) + _dist_package_configure(${_id}) + list(APPEND _source_addons ${_id}) +endforeach() + +#------------------------------------------------------------------------------ +# The add-ons taken as payloads of their own CI: staged after the core and the add-ons +# built here, so that the checks for overwritten files and registered tool names see all +# of them (cmake/stage_artifact.cmake) +#------------------------------------------------------------------------------ +set(_staged_before ${DIST_CORE} ${_source_addons}) +foreach(_id IN LISTS DIST_COMPONENTS) + if(NOT DIST_${_id}_MODE STREQUAL "artifact") + continue() endif() + set(DIST_${_id}_PAYLOAD_DIR "${PROJECT_BINARY_DIR}/${_id}/payload") + ExternalProject_Add(${_id} + PREFIX "${PROJECT_BINARY_DIR}/${_id}" + DEPENDS ${_staged_before} + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND ${CMAKE_COMMAND} -DNAME=${DIST_${_id}_NAME} + -DARTIFACT_DIR=${DIST_ARTIFACT_DIR_${_id}} + -DEXPECTED_SHA256=${DIST_${_id}_ARTIFACT_SHA256} + -DPAYLOAD_DIR=${DIST_${_id}_PAYLOAD_DIR} + -DSTAGE_DIR=${DIST_STAGE_DIR} + -DHOST_PROCESSOR=${CMAKE_HOST_SYSTEM_PROCESSOR} + -P "${PROJECT_SOURCE_DIR}/cmake/stage_artifact.cmake" + ) + list(APPEND _staged_before ${_id}) endforeach() #------------------------------------------------------------------------------ diff --git a/README.md b/README.md index e094623..a71686d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # OpenMS-Distribution -One installer of [OpenMS](https://github.com/OpenMS/OpenMS) together with its add-ons: -the OpenMS core plus the tools that live in their own repositories and are built against an +One installer of [OpenMS](https://github.com/OpenMS/OpenMS) together with its add-ons: the +OpenMS core plus the tools that live in their own repositories and are built against an installed OpenMS of the same version, such as [OpenMS-TOPP-GUI](https://github.com/OpenMS/OpenMS-TOPP-GUI) (TOPPView, TOPPAS, ...) and [OpenMS-MetaProSIP](https://github.com/OpenMS/OpenMS-MetaProSIP). @@ -11,33 +11,92 @@ signing, notarization) follow once the Linux package is established. ## How it works -`manifest.json` pins each component to a branch, tag or commit. A release pins tags. The -superbuild (`CMakeLists.txt`, CMake `ExternalProject`) then: +A manifest (`manifest.json` by default) pins every component. The superbuild +(`CMakeLists.txt`, CMake `ExternalProject`) then: -1. builds the **core** with its own preset and vcpkg and installs it into a staging prefix - (`/stage`); -2. builds each **add-on** against that staging prefix, exactly as against any installed OpenMS - (`find_package(OpenMS EXACT)`), runs its tests, and installs it into the same - prefix. Every add-on registers its tools with its own `share/OpenMS/TOOLS/.tsv` next to - the core's `OpenMS.tsv`; +1. puts the **core** into a staging prefix (`/stage`): built from source with its own + preset and vcpkg, or (*published*) unpacked from the DEB of an OpenMS nightly or release; +2. puts each **add-on** into the same prefix: built from source against the core exactly as + against any installed OpenMS (`find_package(OpenMS EXACT)`), its tests run before + it is installed; or (*artifact*) the runtime payload its own CI built and tested, after + checking it (see below). Every add-on registers its tools with its own + `share/OpenMS/TOOLS/.tsv` next to the core's `OpenMS.tsv`; 3. tests the staged installation as a whole (`ctest`): every tool name is registered once, every registered tool is installed, and every tool starts from the installation with a clean environment (`cmake/check_staged_installation.cmake`); -4. with `DIST_PACKAGE_TYPE=deb` (or `tgz`), reconfigures every component with a package type - (as the OpenMS release workflow does: build and test with `PACKAGE_TYPE=none`, then - reconfigure and package without relinking) and builds **one** package from the install - components of all of them (`CPACK_INSTALL_CMAKE_PROJECTS`; the components per project are in - the manifest). +4. with `DIST_PACKAGE_TYPE=deb` (or `tgz`), builds **one** package of all components: the + components built from source are reconfigured with a package type (as the OpenMS release + workflow does: build and test with `PACKAGE_TYPE=none`, then reconfigure and package without + relinking) and contribute their install components (`CPACK_INSTALL_CMAKE_PROJECTS`); the + published core and the payloads contribute their unpacked trees. The DEB `openms-distribution` provides, replaces and conflicts with the packages of the single -components (`openms`, `openms-gui`, `openms-metaprosip`). +components (`openms`, `openms-gui`, `openms-metaprosip`; the manifest's `deb_package`). + +CI (`.github/workflows/build.yml`) then tests the DEB as users get it: + +- **install-test**: a clean Ubuntu 24.04 container gets only the DEB and the fixtures of + OpenMS-MetaProSIP at the commit the shipped tool was built from (both read-only), installs the + DEB with APT, finds the executables through the package database, checks that MetaProSIP is + registered exactly once, and reproduces both reference CSVs of its TOPP test with the installed + tool and the installed `FuzzyDiff` (`tools/ci/test_deb_install.sh`). The same in the runtime + image (`docker/Dockerfile`: Ubuntu 24.04 with only the DEB installed). +- **upgrade-test**: installs OpenMS 3.6.0 (package `openms`, which still contains MetaProSIP) + first; the distribution DEB must replace it, own MetaProSIP afterwards, and pass the same test. + +`build-info.json`, uploaded next to the DEB, records what went into it: the commits of the +components, the published core's version, checksums and build IDs, the payloads' checksums and +the runs that built them, the DEB's checksum and version, and the run. + +## Manifest + +```json +{ + "version": "3.7.0", + "components": [ { "name": "OpenMS", "kind": "core", ... }, { "kind": "addon", ... } ] +} +``` + +Every component has `name`, `kind` (`core` — exactly one — or `addon`) and `deb_package` (the +package of that component alone, which the combined DEB replaces). Then one of: + +| Mode | Fields | | +|---|---|---| +| source | `repository`, `ref`, `commit`, `packaged_components` | Built here from `commit` (a full SHA). `ref` is the branch the commit is checked out as: the full version string of OpenMS (e.g. `3.7.0-pre-develop-`) is made from it. `packaged_components`: the install components that go into the package (`ALL`: everything `cmake --install` installs, as the OpenMS DEB does). | +| published (core) | `published: {"channel": "nightly"\|"release", "version": ""\|"latest"}` | The SDK and the installer DEB of that folder of archive.openms.de. They must come from one build (same version, same GNU build IDs of `libOpenMS`/`libOpenMS_CLI`). The add-ons built from source build against the SDK. | +| artifact (add-on) | `artifact: {"repository": "", "run_id": , "name": "", "sha256": ""}` | The runtime payload an add-on's CI uploaded (e.g. `MetaProSIP-payload-Linux-X64` of OpenMS-MetaProSIP, `tools/ci/payload.py` there). | + +The add-ons must have the version of the core: they find it with `find_package(OpenMS +EXACT)`. A release pins tags' commits and a released core. + +### Artifact add-ons + +An add-on payload (format 1) is a tarball of the add-on's runtime files relative to the +installation prefix, with a JSON file that lists them (paths, sizes, sha256), the tool commit, +the platform, and the core it was built against: the version and the **GNU build IDs** of the core +libraries its executables link. A build ID names one link of a library and survives stripping, +so the SDK and the installer of one OpenMS build agree, and no other build does. Before a payload +is staged (`cmake/stage_artifact.cmake`), the superbuild checks that + +1. the tarball is the one the manifest pins and the one its metadata names (sha256); +2. it is for this platform; +3. it was built against exactly the staged core (build IDs); +4. it holds exactly the listed files, with their checksums; +5. none of its files exists in the staging prefix already; +6. it registers no tool name that is registered already. + +Because of 3, a payload can only be combined with the core build it was built against. The +add-on's CI and this distribution therefore take the core from the same place: the published +nightly (or release) whose SDK the add-on was built against is the manifest's published core. ## Building -The build dependencies are those of the components (their `tools/ci/deps-*.sh`). +```bash +python3 tools/ci/fetch_components.py --manifest manifest.json --dest _src --install-deps +``` ```bash -cmake -S . -B build -G Ninja -DDIST_PACKAGE_TYPE=deb +cmake -S . -B build -G Ninja -DDIST_PACKAGE_TYPE=deb $(cat _src/cmake-args.txt) ``` ```bash @@ -52,16 +111,24 @@ ctest --test-dir build --output-on-failure cmake --build build --target package ``` +`fetch_components.py` fetches the components as the manifest pins them and writes the +arguments that point the superbuild at them (`_src/cmake-args.txt`) and a record of what it +fetched (`_src/components.json`). `--install-deps` runs the components' `tools/ci/deps-ubuntu.sh` +(with `sudo apt-get`). Downloading payload artifacts needs the GitHub CLI (`gh`) with a token. + Options: | Option | Default | | |---|---|---| | `DIST_PACKAGE_TYPE` | `none` | `deb` or `tgz` for the combined package | -| `DIST_SOURCE_DIR_` | | a local checkout to build instead of the ref of the manifest, e.g. `DIST_SOURCE_DIR_OpenMS_MetaProSIP` (the name with non-identifier characters replaced by `_`) | -| `DIST_ENABLE_TESTING` | `ON` | run the tests of each add-on before installing it, and the staged-installation test | -| `DIST_TEST_CORE` | `OFF` | also build and run the class and TOPP tests of the core (long) | -| `DIST_OPENMS_PRESET` | per host | the CMake preset of OpenMS the core is configured with | -| `DIST_OPENMS_CMAKE_ARGS` | | further configure arguments of the core | +| `DIST_MANIFEST` | `manifest.json` | the manifest | +| `DIST_SOURCE_DIR_` | | a checkout of a source component to build, e.g. `DIST_SOURCE_DIR_OpenMS_MetaProSIP` (the name with non-identifier characters replaced by `_`); without it, the pinned commit is cloned | +| `DIST_CORE_SDK_DIR`, `DIST_CORE_DEB` | | published core: the unpacked SDK and the installer | +| `DIST_ARTIFACT_DIR_` | | artifact add-on: the downloaded artifact | +| `DIST_ENABLE_TESTING` | `ON` | run the tests of each add-on built from source before installing it, and the staged-installation test | +| `DIST_TEST_CORE` | `OFF` | also build and run the class and TOPP tests of a core built from source (long) | +| `DIST_OPENMS_PRESET` | per host | the CMake preset of OpenMS a core built from source is configured with | +| `DIST_OPENMS_CMAKE_ARGS` | | further configure arguments of a core built from source | | `DIST_ADDON_PREFIX_PATH` | | further `CMAKE_PREFIX_PATH` entries of the add-ons (e.g. Qt) | | `DIST_STAGE_DIR` | `/stage` | the staging prefix | @@ -73,10 +140,12 @@ An add-on is a CMake project that - installs into the core's prefix layout (`bin/`, `share/OpenMS`, ...) and registers its TOPP tools in its own `share/OpenMS/TOOLS/.tsv`, - runs its tests with `ctest` against the installed core (`OPENMS_TOPP_BIN_DIR` for `FuzzyDiff`), -- puts what belongs into a package into named install components. +- puts what belongs into a package into named install components, +- optionally publishes a runtime payload from its CI (see OpenMS-MetaProSIP's + `tools/ci/payload.py`). -Add it to `manifest.json` (`kind: addon`, its `packaged_components`), and its dependency script -to `.github/workflows/build.yml`. +Add it to the manifest (`kind: addon`, its `deb_package`, and `packaged_components` or +`artifact`). ## License diff --git a/cmake/cpack_project_config.cmake b/cmake/cpack_project_config.cmake index e8be879..73cda1b 100644 --- a/cmake/cpack_project_config.cmake +++ b/cmake/cpack_project_config.cmake @@ -10,10 +10,15 @@ ## package: the version strings come from the configured core, which this project only ## builds after its own configure step. -file(STRINGS "${CPACK_DIST_CORE_BINARY_DIR}/CMakeCache.txt" _fullstring_line - REGEX "^CF_OPENMS_PACKAGE_VERSION_FULLSTRING:") -string(REGEX REPLACE "^[^=]*=" "" _fullstring "${_fullstring_line}") -if(_fullstring STREQUAL "") +if(CPACK_DIST_CORE_FULLSTRING) + ## a published core + set(_fullstring "${CPACK_DIST_CORE_FULLSTRING}") +elseif(EXISTS "${CPACK_DIST_CORE_BINARY_DIR}/CMakeCache.txt") + file(STRINGS "${CPACK_DIST_CORE_BINARY_DIR}/CMakeCache.txt" _fullstring_line + REGEX "^CF_OPENMS_PACKAGE_VERSION_FULLSTRING:") + string(REGEX REPLACE "^[^=]*=" "" _fullstring "${_fullstring_line}") +endif() +if(NOT _fullstring) set(_fullstring "${CPACK_PACKAGE_VERSION}") endif() @@ -34,7 +39,11 @@ if(CPACK_GENERATOR STREQUAL "DEB") string(REGEX REPLACE "[^A-Za-z0-9.+~]" "." _prerelease "${_prerelease}") set(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}~${_prerelease}") endif() - set(CPACK_DEBIAN_PACKAGE_PROVIDES "openms (= ${CPACK_DEBIAN_PACKAGE_VERSION}), openms-gui (= ${CPACK_DEBIAN_PACKAGE_VERSION}), openms-metaprosip (= ${CPACK_DEBIAN_PACKAGE_VERSION})") - set(CPACK_DEBIAN_PACKAGE_CONFLICTS "openms, openms-gui, openms-metaprosip") - set(CPACK_DEBIAN_PACKAGE_REPLACES "openms, openms-gui, openms-metaprosip") + set(_provides) + foreach(_package IN LISTS CPACK_DIST_DEB_PACKAGES) + list(APPEND _provides "${_package} (= ${CPACK_DEBIAN_PACKAGE_VERSION})") + endforeach() + string(JOIN ", " CPACK_DEBIAN_PACKAGE_PROVIDES ${_provides}) + string(JOIN ", " CPACK_DEBIAN_PACKAGE_CONFLICTS ${CPACK_DIST_DEB_PACKAGES}) + string(JOIN ", " CPACK_DEBIAN_PACKAGE_REPLACES ${CPACK_DIST_DEB_PACKAGES}) endif() diff --git a/cmake/package.cmake b/cmake/package.cmake index 839c4ec..a62408e 100644 --- a/cmake/package.cmake +++ b/cmake/package.cmake @@ -14,12 +14,32 @@ # CMakeLists.txt). Nothing is rebuilt here. #------------------------------------------------------------------------------ +## The installation prefix of the package: /usr for the DEB (as the packages of the single +## components), the root of the tarball otherwise. Set explicitly, because the trees below +## (CPACK_INSTALLED_DIRECTORIES) are placed relative to the root of the package, not to +## this prefix as the install components are. +if(DIST_PACKAGE_TYPE STREQUAL "deb") + set(CPACK_PACKAGING_INSTALL_PREFIX "/usr") + set(_dist_tree_destination "usr") +else() + set(CPACK_PACKAGING_INSTALL_PREFIX "/") + set(_dist_tree_destination ".") +endif() + +## Components built here: their install components (manifest: packaged_components). +## The published core and the payloads of add-ons: their unpacked trees, which are laid out +## as an installation prefix. set(CPACK_INSTALL_CMAKE_PROJECTS) +set(CPACK_INSTALLED_DIRECTORIES) foreach(_id IN LISTS DIST_COMPONENTS) - foreach(_component IN LISTS DIST_${_id}_PACKAGED_COMPONENTS) - list(APPEND CPACK_INSTALL_CMAKE_PROJECTS - "${PROJECT_BINARY_DIR}/${_id}/build" "${DIST_${_id}_NAME}" "${_component}" "/") - endforeach() + if(DIST_${_id}_MODE STREQUAL "source") + foreach(_component IN LISTS DIST_${_id}_PACKAGED_COMPONENTS) + list(APPEND CPACK_INSTALL_CMAKE_PROJECTS + "${PROJECT_BINARY_DIR}/${_id}/build" "${DIST_${_id}_NAME}" "${_component}" "/") + endforeach() + else() + list(APPEND CPACK_INSTALLED_DIRECTORIES "${DIST_${_id}_PAYLOAD_DIR}" "${_dist_tree_destination}") + endif() endforeach() set(CPACK_PACKAGE_NAME "OpenMS") @@ -36,9 +56,17 @@ foreach(_id IN LISTS DIST_COMPONENTS) endforeach() list(JOIN _component_names ", " _component_names) -## Read by cpack (CPACK_PROJECT_CONFIG_FILE): the full version string of the core is only -## known once the core is configured, i.e. after this project was. +## Read by cpack (CPACK_PROJECT_CONFIG_FILE): the full version string of a core built here is +## only known once the core is configured, i.e. after this project was; that of a published +## core is known now (its SDK). set(CPACK_DIST_CORE_BINARY_DIR "${PROJECT_BINARY_DIR}/${DIST_CORE}/build") +set(CPACK_DIST_CORE_FULLSTRING "${DIST_CORE_FULLSTRING}") +## the packages of the single components, which the combined one provides, replaces and +## conflicts with (manifest: deb_package) +set(CPACK_DIST_DEB_PACKAGES) +foreach(_id IN LISTS DIST_COMPONENTS) + list(APPEND CPACK_DIST_DEB_PACKAGES "${DIST_${_id}_DEB_PACKAGE}") +endforeach() ## this project enables no language, so CMAKE_SYSTEM_PROCESSOR is not set; the packages are ## built on the machine they are for set(CPACK_DIST_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}") @@ -49,9 +77,9 @@ list(APPEND CPACK_PRE_BUILD_SCRIPTS "${PROJECT_SOURCE_DIR}/cmake/cpack_clean_run if(DIST_PACKAGE_TYPE STREQUAL "deb") set(CPACK_GENERATOR "DEB") - ## One package for the core and its add-ons. It contains the files of the packages - ## openms, openms-gui, openms-metaprosip, ..., so it provides, replaces and conflicts with - ## them (the version-specific Provides are added in cmake/cpack_project_config.cmake). + ## One package for the core and its add-ons. It contains the files of the packages of the + ## single components (openms, openms-gui, ...), so it provides, replaces and conflicts with + ## them (added with their versions in cmake/cpack_project_config.cmake). set(CPACK_DEBIAN_PACKAGE_NAME "openms-distribution") set(CPACK_DEBIAN_PACKAGE_MAINTAINER "OpenMS Inc ") set(CPACK_DEBIAN_PACKAGE_SECTION "science") diff --git a/cmake/stage_artifact.cmake b/cmake/stage_artifact.cmake new file mode 100644 index 0000000..a15a80f --- /dev/null +++ b/cmake/stage_artifact.cmake @@ -0,0 +1,215 @@ +# Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin +# SPDX-License-Identifier: BSD-3-Clause +# +# -------------------------------------------------------------------------- +# $Maintainer: Timo Sachsenberg $ +# $Authors: Timo Sachsenberg $ +# -------------------------------------------------------------------------- + +## Run with 'cmake -P'. Matches the minimum the project requires. +cmake_minimum_required(VERSION 3.24 FATAL_ERROR) + +### An add-on taken as the runtime payload of its own CI (tools/ci/payload.py of the add-on, +### format 1): -payload.tar.gz (files relative to the installation prefix) and +### -payload.json (what they are and what they were built against). +### +### Before anything is staged, checks that +### 1. the tarball is the one the manifest pins (sha256) and the one its metadata names; +### 2. it is for this platform (operating system and processor); +### 3. it was built against exactly the staged core: the GNU build IDs of the core +### libraries it links equal those of the libraries in the staging prefix (a build ID +### names one link of a library and survives stripping, so the SDK and the installer +### of one OpenMS build agree, and no other build does); +### 4. it contains exactly the files its metadata lists, with their checksums; +### 5. none of its files exists in the staging prefix already (no component overwrites +### another one's file); +### 6. its tool registry registers no tool name that the staged registries already do. +### Then unpacks it into PAYLOAD_DIR (packaged from there by cmake/package.cmake) and copies +### it into the staging prefix. +### +### Arguments: +### NAME the component (for messages) +### ARTIFACT_DIR the downloaded artifact: one *-payload.tar.gz and one *-payload.json +### EXPECTED_SHA256 the sha256 of the tarball as the manifest pins it +### PAYLOAD_DIR where it is unpacked to (emptied first) +### STAGE_DIR the staging prefix +### HOST_PROCESSOR CMAKE_HOST_SYSTEM_PROCESSOR of the superbuild + +foreach(_required NAME ARTIFACT_DIR EXPECTED_SHA256 PAYLOAD_DIR STAGE_DIR HOST_PROCESSOR) + if(NOT DEFINED ${_required}) + message(FATAL_ERROR "stage_artifact.cmake: -D${_required}= is required") + endif() +endforeach() + +function(fail) + string(JOIN "" _msg ${ARGN}) + message(FATAL_ERROR "${NAME}: ${_msg}") +endfunction() + +find_program(READELF readelf REQUIRED) +## the GNU build ID of an ELF file, or empty +function(build_id out_var file) + execute_process(COMMAND "${READELF}" -n "${file}" OUTPUT_VARIABLE _notes RESULT_VARIABLE _rc ERROR_QUIET) + set(_id "") + if(_rc EQUAL 0 AND _notes MATCHES "Build ID: *([0-9a-f]+)") + set(_id "${CMAKE_MATCH_1}") + endif() + set(${out_var} "${_id}" PARENT_SCOPE) +endfunction() + +## the tool names a registry file registers (first column of lines that are no comments) +function(registered_tools out_var file) + file(STRINGS "${file}" _lines) + set(_names) + foreach(_line IN LISTS _lines) + string(STRIP "${_line}" _trimmed) + if(_trimmed STREQUAL "" OR _trimmed MATCHES "^#") + continue() + endif() + string(REPLACE "\t" ";" _fields "${_trimmed}") + list(GET _fields 0 _tool) + list(APPEND _names "${_tool}") + endforeach() + set(${out_var} ${_names} PARENT_SCOPE) +endfunction() + +#------------------------------------------------------------------------------ +# 1. the pinned tarball, as its metadata names it +#------------------------------------------------------------------------------ +file(GLOB _tarballs "${ARTIFACT_DIR}/*-payload.tar.gz") +file(GLOB _metas "${ARTIFACT_DIR}/*-payload.json") +list(LENGTH _tarballs _n_tar) +list(LENGTH _metas _n_meta) +if(NOT _n_tar EQUAL 1 OR NOT _n_meta EQUAL 1) + fail("${ARTIFACT_DIR} holds ${_n_tar} payload tarballs and ${_n_meta} metadata files, expected one each") +endif() +file(SHA256 "${_tarballs}" _sha) +if(NOT _sha STREQUAL EXPECTED_SHA256) + fail("the payload has sha256 ${_sha}, the manifest pins ${EXPECTED_SHA256}") +endif() +file(READ "${_metas}" _meta) +string(JSON _format GET "${_meta}" format) +if(NOT _format EQUAL 1) + fail("payload format ${_format}, this distribution reads format 1") +endif() +string(JSON _meta_sha GET "${_meta}" payload sha256) +if(NOT _meta_sha STREQUAL _sha) + fail("the metadata names a payload with sha256 ${_meta_sha}, the tarball has ${_sha}") +endif() + +#------------------------------------------------------------------------------ +# 2. this platform +#------------------------------------------------------------------------------ +string(JSON _os GET "${_meta}" platform os) +string(JSON _arch GET "${_meta}" platform arch) +if(NOT _os STREQUAL CMAKE_HOST_SYSTEM_NAME OR NOT _arch STREQUAL HOST_PROCESSOR) + fail("the payload is for ${_os} ${_arch}, this build is for ${CMAKE_HOST_SYSTEM_NAME} ${HOST_PROCESSOR}") +endif() + +#------------------------------------------------------------------------------ +# 3. built against exactly the staged core +#------------------------------------------------------------------------------ +string(JSON _n_libs LENGTH "${_meta}" core build_ids) +if(_n_libs EQUAL 0) + fail("the metadata records no build IDs of the core libraries") +endif() +math(EXPR _last "${_n_libs} - 1") +set(_mismatches) +foreach(_i RANGE ${_last}) + string(JSON _lib MEMBER "${_meta}" core build_ids ${_i}) + string(JSON _expected GET "${_meta}" core build_ids "${_lib}") + set(_actual "(missing)") + if(EXISTS "${STAGE_DIR}/${_lib}") + file(REAL_PATH "${STAGE_DIR}/${_lib}" _real) + build_id(_actual "${_real}") + endif() + if(NOT _actual STREQUAL _expected) + list(APPEND _mismatches "${_lib}: built against ${_expected}, the staged core has ${_actual}") + endif() +endforeach() +if(_mismatches) + string(JOIN "\n " _list ${_mismatches}) + fail("the payload was not built against the staged core:\n ${_list}\n" + "An add-on payload can only be combined with the core build it was built against: the core of " + "the manifest must be that build (e.g. the published nightly whose SDK the add-on's CI used).") +endif() + +#------------------------------------------------------------------------------ +# 4. exactly the listed files +#------------------------------------------------------------------------------ +set(_unpacked "${PAYLOAD_DIR}.unpacked") +file(REMOVE_RECURSE "${_unpacked}" "${PAYLOAD_DIR}") +file(ARCHIVE_EXTRACT INPUT "${_tarballs}" DESTINATION "${_unpacked}") +file(GLOB_RECURSE _present LIST_DIRECTORIES false RELATIVE "${_unpacked}" "${_unpacked}/*") +list(SORT _present) +string(JSON _n_files LENGTH "${_meta}" files) +math(EXPR _last "${_n_files} - 1") +set(_listed) +foreach(_i RANGE ${_last}) + string(JSON _path GET "${_meta}" files ${_i} path) + string(JSON _expected GET "${_meta}" files ${_i} sha256) + if(_path MATCHES "(^/|(^|/)\\.\\.(/|$))") + fail("the metadata lists the file '${_path}' outside the installation prefix") + endif() + if(NOT EXISTS "${_unpacked}/${_path}" OR IS_SYMLINK "${_unpacked}/${_path}") + fail("the payload lacks the listed file ${_path}") + endif() + file(SHA256 "${_unpacked}/${_path}" _actual) + if(NOT _actual STREQUAL _expected) + fail("${_path} has sha256 ${_actual}, the metadata lists ${_expected}") + endif() + list(APPEND _listed "${_path}") +endforeach() +list(SORT _listed) +if(NOT _present STREQUAL _listed) + fail("the payload holds files its metadata does not list (or lists twice):\n holds: ${_present}\n lists: ${_listed}") +endif() + +#------------------------------------------------------------------------------ +# 5. nothing overwritten +#------------------------------------------------------------------------------ +set(_conflicts) +foreach(_path IN LISTS _listed) + if(EXISTS "${STAGE_DIR}/${_path}" OR IS_SYMLINK "${STAGE_DIR}/${_path}") + list(APPEND _conflicts "${_path}") + endif() +endforeach() +if(_conflicts) + string(JOIN "\n " _list ${_conflicts}) + fail("files another component installed already:\n ${_list}") +endif() + +#------------------------------------------------------------------------------ +# 6. no tool name registered twice +#------------------------------------------------------------------------------ +set(_staged_tools) +file(GLOB _staged_registries "${STAGE_DIR}/share/OpenMS/TOOLS/*.tsv") +foreach(_registry IN LISTS _staged_registries) + registered_tools(_tools "${_registry}") + list(APPEND _staged_tools ${_tools}) +endforeach() +set(_duplicates) +file(GLOB _own_registries "${_unpacked}/share/OpenMS/TOOLS/*.tsv") +foreach(_registry IN LISTS _own_registries) + registered_tools(_tools "${_registry}") + foreach(_tool IN LISTS _tools) + if(_tool IN_LIST _staged_tools) + list(APPEND _duplicates "${_tool}") + endif() + list(APPEND _staged_tools "${_tool}") + endforeach() +endforeach() +if(_duplicates) + string(JOIN ", " _list ${_duplicates}) + fail("registers tools that are registered already: ${_list}. ToolHandler rejects a name registered " + "twice, which stops every TOPP tool from starting.") +endif() + +#------------------------------------------------------------------------------ +# stage +#------------------------------------------------------------------------------ +file(RENAME "${_unpacked}" "${PAYLOAD_DIR}") +file(COPY "${PAYLOAD_DIR}/" DESTINATION "${STAGE_DIR}") +string(JSON _tool_commit ERROR_VARIABLE _e GET "${_meta}" tool commit) +string(JSON _run ERROR_VARIABLE _e GET "${_meta}" run) +message(STATUS "${NAME}: staged the payload ${_sha} (tool commit ${_tool_commit}, built in ${_run}) in ${STAGE_DIR}") diff --git a/cmake/stage_core_deb.cmake b/cmake/stage_core_deb.cmake new file mode 100644 index 0000000..2df5002 --- /dev/null +++ b/cmake/stage_core_deb.cmake @@ -0,0 +1,40 @@ +# Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin +# SPDX-License-Identifier: BSD-3-Clause +# +# -------------------------------------------------------------------------- +# $Maintainer: Timo Sachsenberg $ +# $Authors: Timo Sachsenberg $ +# -------------------------------------------------------------------------- + +## Run with 'cmake -P'. Matches the minimum the project requires. +cmake_minimum_required(VERSION 3.24 FATAL_ERROR) + +### The published core: unpacks the OpenMS installer DEB (which installs into /usr) into +### PAYLOAD_DIR (its /usr becomes the root, as in an installation prefix; packaged from +### there by cmake/package.cmake) and copies that into the staging prefix. +### +### Arguments: +### DEB the OpenMS installer DEB +### PAYLOAD_DIR where its prefix is unpacked to (emptied first) +### STAGE_DIR the staging prefix + +foreach(_required DEB PAYLOAD_DIR STAGE_DIR) + if(NOT DEFINED ${_required}) + message(FATAL_ERROR "stage_core_deb.cmake: -D${_required}= is required") + endif() +endforeach() + +find_program(DPKG_DEB dpkg-deb REQUIRED) +set(_unpacked "${PAYLOAD_DIR}.unpacked") +file(REMOVE_RECURSE "${_unpacked}" "${PAYLOAD_DIR}") +execute_process(COMMAND "${DPKG_DEB}" -x "${DEB}" "${_unpacked}" COMMAND_ERROR_IS_FATAL ANY) +if(NOT IS_DIRECTORY "${_unpacked}/usr") + message(FATAL_ERROR "The installer ${DEB} does not install into /usr") +endif() +file(RENAME "${_unpacked}/usr" "${PAYLOAD_DIR}") +file(REMOVE_RECURSE "${_unpacked}") + +file(MAKE_DIRECTORY "${STAGE_DIR}") +## the contents of PAYLOAD_DIR (trailing slash), symbolic links as links +file(COPY "${PAYLOAD_DIR}/" DESTINATION "${STAGE_DIR}") +message(STATUS "Staged the published core ${DEB} in ${STAGE_DIR}") diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..ddffcb8 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,11 @@ +# Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin +# SPDX-License-Identifier: BSD-3-Clause +# +# The runtime image: Ubuntu 24.04 (the release the DEB is built on) with the distribution +# DEB installed, nothing else. The build context holds that one DEB: +# docker build -f docker/Dockerfile -t openms-distribution +FROM ubuntu:24.04 +COPY *.deb /tmp/openms/ +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends /tmp/openms/*.deb \ + && rm -rf /var/lib/apt/lists/* /tmp/openms diff --git a/manifest.json b/manifest.json index 1fda63e..975e506 100644 --- a/manifest.json +++ b/manifest.json @@ -1,37 +1,33 @@ { - "comment": "The components of the OpenMS distribution, each pinned to a branch, tag or commit. A release pins tags (v). The add-ons must have the version of the core: they find it with find_package(OpenMS EXACT).", + "comment": "The components of the OpenMS distribution. See README.md (Manifest) for the fields.", "version": "3.7.0", "components": [ { "name": "OpenMS", - "repository": "https://github.com/OpenMS/OpenMS.git", - "ref": "claude/admiring-tesla-n9a3lm", "kind": "core", - "packaged_components": [ - "ALL" - ] + "repository": "https://github.com/OpenMS/OpenMS.git", + "ref": "develop", + "commit": "9ad3eeb6df2a1db829ee424f924565cbd8a885fe", + "deb_package": "openms", + "packaged_components": ["ALL"] }, { "name": "OpenMS-TOPP-GUI", + "kind": "addon", "repository": "https://github.com/OpenMS/OpenMS-TOPP-GUI.git", "ref": "develop", - "kind": "addon", - "packaged_components": [ - "library_gui", - "GUIApplications", - "doc_gui" - ] + "commit": "5e581957e3e265099bfac2b0c616e937716cdf59", + "deb_package": "openms-gui", + "packaged_components": ["library_gui", "GUIApplications", "doc_gui"] }, { "name": "OpenMS-MetaProSIP", - "repository": "https://github.com/OpenMS/OpenMS-MetaProSIP.git", - "ref": "claude/admiring-tesla-n9a3lm", "kind": "addon", - "packaged_components": [ - "MetaProSIP", - "doc_metaprosip" - ] + "repository": "https://github.com/OpenMS/OpenMS-MetaProSIP.git", + "ref": "main", + "commit": "569621266456e842a7908fd0f08b460f03cb012f", + "deb_package": "openms-metaprosip", + "packaged_components": ["MetaProSIP", "doc_metaprosip"] } - ], - "comment_packaged_components": "packaged_components: the install components of each project that go into the combined package. 'ALL' is what a plain 'cmake --install' installs (the OpenMS deb packages the same). The add-ons list the components of their own packages (cmake/package_deb.cmake there)." + ] } diff --git a/tools/ci/fetch_components.py b/tools/ci/fetch_components.py new file mode 100755 index 0000000..2f3c0a8 --- /dev/null +++ b/tools/ci/fetch_components.py @@ -0,0 +1,258 @@ +#!/usr/bin/env python3 +# Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin +# SPDX-License-Identifier: BSD-3-Clause +# +# -------------------------------------------------------------------------- +# $Maintainer: Timo Sachsenberg $ +# $Authors: Timo Sachsenberg $ +# -------------------------------------------------------------------------- +"""Fetches the components of a distribution manifest for the superbuild. + + fetch_components.py --manifest manifest.json --dest _src [--install-deps] + +Per component (see README.md, Manifest): + source cloned at its pinned commit into /, checked out as a local branch + named after its ref (the full version string of OpenMS is made from the branch + name); the core also gets the vcpkg submodule. --install-deps runs the + component's tools/ci/deps-ubuntu.sh. + published (core) the SDK and the DEB installer of an OpenMS nightly or release from + archive.openms.de, which must come from one build: same version and the same + GNU build IDs of libOpenMS/libOpenMS_CLI in both. + artifact (add-on) the runtime payload of a CI run of the add-on (gh run download), checked + against the sha256 pinned in the manifest. + +Writes + /cmake-args.txt one -D argument per line for configuring the superbuild + /components.json what was fetched (commits, versions, checksums), for build-info.json +""" + +import argparse +import hashlib +import html.parser +import json +import os +import platform +import re +import shutil +import subprocess +import sys +import tarfile +import urllib.request + +ARCHIVE = os.environ.get("OPENMS_ARCHIVE_URL", "https://archive.openms.de/openms/OpenMSInstaller") + + +def log(msg): + print(msg, flush=True) + + +def run(cmd, cwd=None, capture=False): + log("+ " + " ".join(cmd)) + r = subprocess.run(cmd, cwd=cwd, check=True, text=True, capture_output=capture) + return r.stdout if capture else None + + +def c_identifier(name): + """The id CMake's string(MAKE_C_IDENTIFIER) makes of a component name.""" + ident = re.sub(r"[^A-Za-z0-9_]", "_", name) + return "_" + ident if ident[:1].isdigit() else ident + + +def sha256(path): + h = hashlib.sha256() + with open(path, "rb") as f: + for block in iter(lambda: f.read(1 << 20), b""): + h.update(block) + return h.hexdigest() + + +def build_id(path): + out = run(["readelf", "-n", path], capture=True) + m = re.search(r"Build ID:\s*([0-9a-f]+)", out) + return m.group(1) if m else None + + +def deb_arch(): + return {"x86_64": "x86_64", "aarch64": "aarch64", "arm64": "aarch64"}[platform.machine()] + + +# --------------------------------------------------------------------------- source +def fetch_source(comp, dest, install_deps): + path = os.path.join(dest, comp["name"]) + commit, ref = comp["commit"], comp["ref"] + if not re.fullmatch(r"[0-9a-f]{40}", commit): + sys.exit(f"ERROR: {comp['name']}: 'commit' must be a full 40-character SHA, is '{commit}'") + if not os.path.isdir(os.path.join(path, ".git")): + os.makedirs(path, exist_ok=True) + run(["git", "init", "-q"], cwd=path) + run(["git", "remote", "add", "origin", comp["repository"]], cwd=path) + run(["git", "fetch", "-q", "--depth", "1", "origin", commit], cwd=path) + # a local branch named after the ref, at the pinned commit + run(["git", "checkout", "-q", "-B", ref, commit], cwd=path) + head = run(["git", "rev-parse", "HEAD"], cwd=path, capture=True).strip() + if head != commit: + sys.exit(f"ERROR: {comp['name']}: checked out {head}, expected {commit}") + if comp["kind"] == "core": + # the vcpkg registry of OpenMS; its history is needed for the version overrides + run(["git", "submodule", "update", "--init", "vcpkg"], cwd=path) + if install_deps: + script = os.path.join(path, "tools", "ci", "deps-ubuntu.sh") + if os.path.exists(script): + flags = ["--skip-gui-deps"] if comp["kind"] == "core" else ["--skip-doc-deps"] + run(["bash", script] + flags) + return [f"-DDIST_SOURCE_DIR_{c_identifier(comp['name'])}={os.path.abspath(path)}"], { + "mode": "source", + "repository": comp["repository"], + "ref": ref, + "commit": commit, + } + + +# --------------------------------------------------------------------------- published +class _Links(html.parser.HTMLParser): + def __init__(self): + super().__init__() + self.links = [] + + def handle_starttag(self, tag, attrs): + if tag == "a": + self.links += [v for k, v in attrs if k == "href" and v] + + +def listing(url): + with urllib.request.urlopen(url, timeout=60) as r: + p = _Links() + p.feed(r.read().decode("utf-8", "replace")) + return [l.rstrip("/") for l in p.links if not l.startswith(("?", "/", "..", "http"))] + + +def download(url, path): + log(f"downloading {url}") + with urllib.request.urlopen(url, timeout=600) as r, open(path, "wb") as f: + shutil.copyfileobj(r, f) + + +def resolve_published(channel, version): + """The archive folder and the SDK and installer file names of a nightly or release. + 'latest': the newest folder that has both.""" + arch = deb_arch() + base = f"{ARCHIVE}/{channel}" + folders = [version] if version != "latest" else sorted( + (f for f in listing(base + "/") if re.fullmatch(r"[0-9][0-9.]*", f)), + key=lambda v: [int(x) for x in v.split(".")], reverse=True) + for folder in folders: + files = listing(f"{base}/{folder}/") + sdk = f"OpenMS-SDK-{folder}-Linux-{arch}.tar.gz" + debs = [f for f in files if re.fullmatch(rf"OpenMS-[0-9][^/]*-Debian-Linux-{arch}\.deb", f)] + if sdk in files and len(debs) == 1: + return folder, f"{base}/{folder}/{sdk}", f"{base}/{folder}/{debs[0]}" + if version != "latest": + sys.exit(f"ERROR: {base}/{folder} has no SDK {sdk} and exactly one OpenMS installer: {files}") + sys.exit(f"ERROR: no folder of {base} has an SDK and an installer for Linux-{arch}") + + +def fetch_published(comp, dest): + pub = comp["published"] + folder, sdk_url, deb_url = resolve_published(pub["channel"], pub.get("version", "latest")) + core_dir = os.path.join(dest, comp["name"] + "-published") + shutil.rmtree(core_dir, ignore_errors=True) + os.makedirs(core_dir) + sdk_tar = os.path.join(core_dir, os.path.basename(sdk_url)) + deb = os.path.join(core_dir, os.path.basename(deb_url)) + download(sdk_url, sdk_tar) + download(deb_url, deb) + with tarfile.open(sdk_tar) as t: + t.extractall(core_dir, filter="data") if hasattr(tarfile, "data_filter") else t.extractall(core_dir) + sdk_dirs = [d for d in os.listdir(core_dir) if os.path.isdir(os.path.join(core_dir, d)) and d.startswith("OpenMS-SDK-")] + if len(sdk_dirs) != 1: + sys.exit(f"ERROR: the SDK {sdk_tar} did not unpack into one OpenMS-SDK-* folder: {sdk_dirs}") + sdk_dir = os.path.join(core_dir, sdk_dirs[0]) + + # SDK and installer must come from one build of OpenMS + config = os.path.join(sdk_dir, "lib", "cmake", "OpenMS", "OpenMSConfig.cmake") + m = re.search(r'set\(OpenMS_VERSION_FULLSTRING "([^"]+)"\)', open(config).read()) + if not m: + sys.exit(f"ERROR: {config} names no OpenMS_VERSION_FULLSTRING") + fullstring = m.group(1) + deb_version = run(["dpkg-deb", "-f", deb, "Version"], capture=True).strip() + expected_deb_version = re.sub(r"[^A-Za-z0-9.+~]", ".", re.sub(r"-pre-", "~", fullstring, count=1)) + if deb_version != expected_deb_version: + sys.exit(f"ERROR: the installer ({deb_version}) and the SDK ({fullstring}) are not from one build") + deb_tree = os.path.join(core_dir, "deb") + run(["dpkg-deb", "-x", deb, deb_tree]) + build_ids = {} + for lib in ("libOpenMS.so", "libOpenMS_CLI.so"): + ids = {where: build_id(os.path.realpath(os.path.join(root, "lib", lib))) + for where, root in (("sdk", sdk_dir), ("deb", os.path.join(deb_tree, "usr")))} + if not ids["sdk"] or ids["sdk"] != ids["deb"]: + sys.exit(f"ERROR: {lib} of the SDK ({ids['sdk']}) and of the installer ({ids['deb']}) differ: not one build") + build_ids["lib/" + lib] = ids["sdk"] + shutil.rmtree(deb_tree) + log(f"OpenMS {fullstring} ({pub['channel']} {folder}): SDK and installer from one build") + return [f"-DDIST_CORE_SDK_DIR={sdk_dir}", f"-DDIST_CORE_DEB={deb}"], { + "mode": "published", + "channel": pub["channel"], + "version": folder, + "version_fullstring": fullstring, + "sdk": {"url": sdk_url, "sha256": sha256(sdk_tar)}, + "deb": {"url": deb_url, "sha256": sha256(deb), "version": deb_version}, + "build_ids": build_ids, + } + + +# --------------------------------------------------------------------------- artifact +def fetch_artifact(comp, dest): + art = comp["artifact"] + out = os.path.join(dest, comp["name"] + "-artifact") + shutil.rmtree(out, ignore_errors=True) + os.makedirs(out) + run(["gh", "run", "download", str(art["run_id"]), "--repo", art["repository"], "--name", art["name"], "--dir", out]) + payloads = [f for f in os.listdir(out) if f.endswith("-payload.tar.gz")] + metas = [f for f in os.listdir(out) if f.endswith("-payload.json")] + if len(payloads) != 1 or len(metas) != 1: + sys.exit(f"ERROR: the artifact {art['name']} of run {art['run_id']} holds no single payload: {os.listdir(out)}") + actual = sha256(os.path.join(out, payloads[0])) + if actual != art["sha256"]: + sys.exit(f"ERROR: {comp['name']}: the payload has sha256 {actual}, the manifest pins {art['sha256']}") + meta = json.load(open(os.path.join(out, metas[0]))) + return [f"-DDIST_ARTIFACT_DIR_{c_identifier(comp['name'])}={os.path.abspath(out)}"], { + "mode": "artifact", + "repository": art["repository"], + "run_id": art["run_id"], + "name": art["name"], + "sha256": actual, + "tool": meta.get("tool"), + "core": meta.get("core"), + "producer_run": meta.get("run"), + } + + +def main(): + ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + ap.add_argument("--manifest", default="manifest.json") + ap.add_argument("--dest", default="_src") + ap.add_argument("--install-deps", action="store_true") + args = ap.parse_args() + + manifest = json.load(open(args.manifest)) + os.makedirs(args.dest, exist_ok=True) + cmake_args, record = [f"-DDIST_MANIFEST={os.path.abspath(args.manifest)}"], {"version": manifest["version"], "components": []} + for comp in manifest["components"]: + if comp["kind"] == "core" and "published" in comp: + a, r = fetch_published(comp, args.dest) + elif comp["kind"] == "addon" and "artifact" in comp: + a, r = fetch_artifact(comp, args.dest) + else: + a, r = fetch_source(comp, args.dest, args.install_deps) + cmake_args += a + record["components"].append({"name": comp["name"], "kind": comp["kind"], **r}) + with open(os.path.join(args.dest, "cmake-args.txt"), "w") as f: + f.write("\n".join(cmake_args) + "\n") + with open(os.path.join(args.dest, "components.json"), "w") as f: + json.dump(record, f, indent=2) + f.write("\n") + log(json.dumps(record, indent=2)) + + +if __name__ == "__main__": + main() diff --git a/tools/ci/fetch_fixtures.sh b/tools/ci/fetch_fixtures.sh new file mode 100755 index 0000000..7b94000 --- /dev/null +++ b/tools/ci/fetch_fixtures.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin +# SPDX-License-Identifier: BSD-3-Clause +# +# -------------------------------------------------------------------------- +# $Maintainer: Timo Sachsenberg $ +# $Authors: Timo Sachsenberg $ +# -------------------------------------------------------------------------- +# +# Checks out src/tests/topp of OpenMS-MetaProSIP (the inputs, reference files and +# FuzzyDiff.ini of its TOPP tests) at the commit the packaged tool was built from, as +# build-info.json records it: the pinned commit of a source build, or the tool commit of +# a payload artifact. +# +# fetch_fixtures.sh +set -euo pipefail + +if [[ $# -ne 2 ]]; then + echo "Usage: $0 " >&2 + exit 2 +fi + +read -r repository commit < <(python3 - "$1" <<'EOF' +import json, sys +info = json.load(open(sys.argv[1])) +comps = [c for c in info["components"] if c["name"] == "OpenMS-MetaProSIP"] +if len(comps) != 1: + sys.exit("ERROR: build-info.json has no component OpenMS-MetaProSIP") +c = comps[0] +if c["mode"] == "source": + repository, commit = c["repository"], c["commit"] +elif c["mode"] == "artifact": + repository = "https://github.com/" + c["repository"] + ".git" + commit = (c.get("tool") or {}).get("commit", "") +else: + sys.exit(f"ERROR: unexpected mode {c['mode']} of OpenMS-MetaProSIP") +if not commit: + sys.exit("ERROR: build-info.json records no commit of OpenMS-MetaProSIP") +print(repository, commit) +EOF +) + +echo "Fixtures of $repository at $commit" +rm -rf "$2" +git init -q "$2" +git -C "$2" remote add origin "$repository" +git -C "$2" sparse-checkout set src/tests/topp +git -C "$2" fetch -q --depth 1 --filter=blob:none origin "$commit" +git -C "$2" checkout -q FETCH_HEAD +ls "$2/src/tests/topp/MetaProSIP_1_output_1.csv" "$2/src/tests/topp/FuzzyDiff.ini" >/dev/null diff --git a/tools/ci/test_deb_install.sh b/tools/ci/test_deb_install.sh new file mode 100755 index 0000000..2777044 --- /dev/null +++ b/tools/ci/test_deb_install.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash +# Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin +# SPDX-License-Identifier: BSD-3-Clause +# +# -------------------------------------------------------------------------- +# $Maintainer: Timo Sachsenberg $ +# $Authors: Timo Sachsenberg $ +# -------------------------------------------------------------------------- +# +# Installs the distribution DEB into a clean Ubuntu container and checks MetaProSIP as a +# user gets it: run as root inside the container (.github/workflows/build.yml). +# +# /artifacts/*.deb the distribution DEB (exactly one), read-only +# /fixtures src/tests/topp of OpenMS-MetaProSIP at the commit the shipped tool +# was built from (inputs, reference files, FuzzyDiff.ini), read-only +# +# Environment: +# OLD_DEB= upgrade test: install this older OpenMS package first (one that +# contains MetaProSIP itself, e.g. openms 3.6.0) and check that the +# distribution DEB replaces it and owns the files afterwards +# SKIP_INSTALL=1 the DEB is installed already (the runtime image): only check it +# +# The executables are located through the package database (dpkg-query -L), and the run +# uses the same inputs, reference files and FuzzyDiff tolerances as TOPP test 1 of +# OpenMS-MetaProSIP, in a clean environment (no OPENMS_* variables, no LD_LIBRARY_PATH). +set -euo pipefail +shopt -s nullglob + +fail() { + echo "ERROR: $*" >&2 + exit 1 +} + +export DEBIAN_FRONTEND=noninteractive + +if [[ "${SKIP_INSTALL:-}" == "1" ]]; then + package=$(dpkg-query -S /usr/bin/MetaProSIP | cut -d: -f1) +else + debs=(/artifacts/*.deb) + [[ ${#debs[@]} -eq 1 ]] || fail "expected exactly one DEB in /artifacts, found ${#debs[@]}" + package=$(dpkg-deb -f "${debs[0]}" Package) + apt-get update -qq + + if [[ -n "${OLD_DEB:-}" ]]; then + old_package=$(dpkg-deb -f "$OLD_DEB" Package) + apt-get install -y -qq "$OLD_DEB" + owner=$(dpkg-query -S /usr/bin/MetaProSIP | cut -d: -f1) + [[ "$owner" == "$old_package" ]] || fail "/usr/bin/MetaProSIP belongs to '$owner', expected the old package '$old_package'" + echo "Installed $old_package $(dpkg-query -W -f '${Version}' "$old_package"), which contains MetaProSIP." + fi + + apt-get install -y -qq "${debs[0]}" + + if [[ -n "${OLD_DEB:-}" ]]; then + if dpkg-query -W -f '${Status}' "$old_package" 2>/dev/null | grep -q 'install ok installed'; then + fail "the old package $old_package is still installed next to $package" + fi + echo "$package replaced $old_package." + fi +fi + +installed=$(dpkg-query -L "$package") +tool=$(awk '/\/bin\/MetaProSIP$/ { print }' <<<"$installed") +diff_tool=$(awk '/\/bin\/FuzzyDiff$/ { print }' <<<"$installed") +registry=$(awk '/\/share\/OpenMS\/TOOLS\/MetaProSIP\.tsv$/ { print }' <<<"$installed") +[[ -x "$tool" && -x "$diff_tool" && -f "$registry" ]] \ + || fail "$package does not install bin/MetaProSIP, bin/FuzzyDiff and share/OpenMS/TOOLS/MetaProSIP.tsv" +for f in "$tool" "$diff_tool" "$registry"; do + owner=$(dpkg-query -S "$f" | cut -d: -f1) + [[ "$owner" == "$package" ]] || fail "$f belongs to '$owner', expected '$package'" +done +awk -F '\t' '$1 == "MetaProSIP" { hits++ } END { exit (hits != 1) }' "$(dirname "$registry")"/*.tsv \ + || fail "MetaProSIP is not registered exactly once in $(dirname "$registry")" + +unset OPENMS_DATA_PATH OPENMS_TOOL_REGISTRY_PATH OPENMS_TTD_INTERNAL_PATH LD_LIBRARY_PATH +cd "$(mktemp -d)" +"$tool" -test \ + -in_mzML /fixtures/MetaProSIP_1_input.mzML \ + -in_fasta /fixtures/MetaProSIP_1_input.fasta \ + -in_featureXML /fixtures/MetaProSIP_1_input.featureXML \ + -out_csv group.csv -out_peptide_centric_csv peptide.csv +"$diff_tool" -test -ini /fixtures/FuzzyDiff.ini \ + -in1 group.csv -in2 /fixtures/MetaProSIP_1_output_1.csv +"$diff_tool" -test -ini /fixtures/FuzzyDiff.ini \ + -in1 peptide.csv -in2 /fixtures/MetaProSIP_1_output_2.csv + +echo "PASS: $package $(dpkg-query -W -f '${Version}' "$package"): MetaProSIP reproduces both reference CSVs." From 63cfba65a8aeb1ff3048a53ee5eb183e8bfe67d9 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 2 Dec 2026 16:49:26 +0000 Subject: [PATCH 2/4] Address review findings: idempotent staging, ref checkout, provenance - Staging a published core or an artifact again in the same build tree (a new pin, a package type added later, an earlier component staged again) failed: the artifact refused its own earlier files and deleted its payload before failing, and an earlier core's files stayed behind. Both now first remove what their earlier run staged (cmake/unstage_payload.cmake, only files still identical to what was copied), and their install steps depend on the DEB / payload files and the staging scripts. - A payload is listed before it is unpacked: only regular files (and directories) inside the installation prefix, so no entry can write outside the directory it is unpacked to. - Without fetch_components.py, a cloned source component is checked out as the branch 'ref' (right after the clone), so OpenMS gets the version string -pre-- instead of -pre-HEAD-. - A source component needs a non-empty packaged_components again; it was silently left out of the package while the DEB replaced its package. - DIST_OPENMS_CMAKE_ARGS with several arguments reached the core's configure as one argument. - build-info.json records the commit that was built (on a pull request the merge commit), the ref, and the head of the pull request separately. - Artifact downloads from other repositories use the secret DIST_ARTIFACT_TOKEN when set (the GITHUB_TOKEN covers this repository only), with an error naming it when the download fails. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0149aXmZhZtnMkPBQ7zPTrXN --- .github/workflows/build.yml | 15 ++++++++--- CMakeLists.txt | 43 +++++++++++++++++++++++++++---- README.md | 15 ++++++++--- cmake/stage_artifact.cmake | 45 ++++++++++++++++++++++++++++++--- cmake/stage_core_deb.cmake | 11 +++++--- cmake/unstage_payload.cmake | 49 ++++++++++++++++++++++++++++++++++++ tools/ci/fetch_components.py | 10 +++++++- 7 files changed, 169 insertions(+), 19 deletions(-) create mode 100644 cmake/unstage_payload.cmake diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 05c4530..7613bf0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -53,11 +53,13 @@ jobs: # Source components at their pinned commits (checked out as a local branch named # after their ref, which the version string of OpenMS is made from), with their # build dependencies; a published core's SDK and installer; payload artifacts of - # add-ons (gh run download, so the token reads the other repositories' runs). + # add-ons (gh run download). The GITHUB_TOKEN of this workflow cannot download the + # artifacts of other repositories: that needs the secret DIST_ARTIFACT_TOKEN, a token + # with Actions read access to the add-on repositories (only for artifact add-ons). - name: Fetch the Components shell: bash env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ secrets.DIST_ARTIFACT_TOKEN || github.token }} run: | set -euo pipefail python3 tools/ci/fetch_components.py --manifest "$MANIFEST" --dest _src --install-deps @@ -124,7 +126,10 @@ jobs: shell: bash env: RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - DIST_COMMIT: ${{ github.event.pull_request.head.sha || github.sha }} + # what was checked out and built: on a pull request the merge commit + # (refs/pull/N/merge), whose manifest and superbuild went into the package + DIST_COMMIT: ${{ github.sha }} + DIST_PR_HEAD: ${{ github.event.pull_request.head.sha }} run: | set -euo pipefail shopt -s nullglob @@ -141,7 +146,9 @@ jobs: "name": field("Package"), "version": field("Version"), } - record["distribution"] = {"commit": os.environ["DIST_COMMIT"], "manifest": os.environ["MANIFEST"]} + record["distribution"] = {"commit": os.environ["DIST_COMMIT"], "ref": os.environ["GITHUB_REF"], "manifest": os.environ["MANIFEST"]} + if os.environ.get("DIST_PR_HEAD"): + record["distribution"]["pull_request_head"] = os.environ["DIST_PR_HEAD"] record["run"] = os.environ["RUN_URL"] record["runner"] = {"os": os.environ.get("ImageOS", ""), "image_version": os.environ.get("ImageVersion", "")} json.dump(record, open("build/build-info.json", "w"), indent=2) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5be73f7..f94bfb2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,8 @@ # tools/ci/fetch_components.py fetches the components as the manifest pins them and writes # the arguments that point the superbuild at them (DIST_SOURCE_DIR_, # DIST_CORE_SDK_DIR and DIST_CORE_DEB, DIST_ARTIFACT_DIR_). Without -# DIST_SOURCE_DIR_, a source component is cloned at its pinned commit. +# DIST_SOURCE_DIR_, a source component is cloned at its pinned commit, checked +# out as the branch 'ref' like fetch_components.py does. #------------------------------------------------------------------------------ cmake_minimum_required(VERSION 3.24 FATAL_ERROR) @@ -59,7 +60,7 @@ set(DIST_MANIFEST "${PROJECT_SOURCE_DIR}/manifest.json" CACHE FILEPATH "The mani set(DIST_STAGE_DIR "${PROJECT_BINARY_DIR}/stage" CACHE PATH "The staging prefix the core and the add-ons are installed into") set(DIST_BUILD_TYPE "Release" CACHE STRING "CMAKE_BUILD_TYPE of the add-ons (the core uses its preset)") set(DIST_ADDON_PREFIX_PATH "" CACHE STRING "Further CMAKE_PREFIX_PATH entries of the add-ons (';'-separated), e.g. Qt") -set(DIST_OPENMS_CMAKE_ARGS "" CACHE STRING "Further configure arguments of the core built from source (';'-separated)") +set(DIST_OPENMS_CMAKE_ARGS "" CACHE STRING "Further configure arguments of the core built from source (';'-separated; a list value inside one argument with '|', e.g. -DFOO=a|b)") set(DIST_CORE_SDK_DIR "" CACHE PATH "Published core: the unpacked OpenMS SDK (tools/ci/fetch_components.py)") set(DIST_CORE_DEB "" CACHE FILEPATH "Published core: the OpenMS installer DEB of the same build as the SDK") @@ -158,6 +159,11 @@ foreach(_i RANGE ${_last}) if(_repo STREQUAL "" OR _commit STREQUAL "") message(FATAL_ERROR "${DIST_MANIFEST}: ${_name} is built from source and needs 'repository' and 'commit'") endif() + if(NOT DIST_${_id}_PACKAGED_COMPONENTS) + message(FATAL_ERROR "${DIST_MANIFEST}: ${_name} is built from source and needs a non-empty " + "'packaged_components' (the install components that go into the package; ALL for " + "everything it installs)") + endif() set(DIST_SOURCE_DIR_${_id} "" CACHE PATH "Local checkout of ${_name} to build instead of ${_repo} at ${_commit}") if(DIST_SOURCE_DIR_${_id}) message(STATUS "${_name}: source, local checkout ${DIST_SOURCE_DIR_${_id}}") @@ -197,6 +203,25 @@ function(_dist_source_args out_var id) set(${out_var} ${_args} PARENT_SCOPE) endfunction() +## A clone of the pinned commit is checked out as the local branch 'ref', as +## tools/ci/fetch_components.py does: the full version string of OpenMS is made from the +## branch name (a detached HEAD would give '-pre-HEAD-'). Right after the +## clone: the disconnected update step that follows leaves HEAD alone when it is at the +## pinned commit already (and the always-run 'update' step stays out of the build). +function(_dist_checkout_ref id) + if(DIST_SOURCE_DIR_${id} OR DIST_${id}_REF STREQUAL "") + return() + endif() + find_package(Git REQUIRED) + ExternalProject_Add_Step(${id} checkout_ref + COMMAND "${GIT_EXECUTABLE}" checkout -q -B "${DIST_${id}_REF}" "${DIST_${id}_COMMIT}" + WORKING_DIRECTORY + DEPENDEES download + DEPENDERS configure + COMMENT "Checking out ${DIST_${id}_NAME} ${DIST_${id}_COMMIT} as the branch ${DIST_${id}_REF}" + ) +endfunction() + ## Reconfiguring a component built from source for packaging (DIST_PACKAGE_TYPE): the core ## installs its runtime dependencies (vcpkg libraries) and the add-ons drop the RPATH ## entries of the staging prefix only with a package type. Linux packages of the @@ -230,8 +255,6 @@ if(DIST_${DIST_CORE}_MODE STREQUAL "source") set(_core_testing -DENABLE_CLASS_TESTING=OFF -DENABLE_TOPP_TESTING=OFF) set(_core_test_args) endif() - string(REPLACE ";" "|" _core_extra_args "${DIST_OPENMS_CMAKE_ARGS}") - ## The configuration of the core is the one OpenMS-TOPP-GUI and OpenMS-MetaProSIP build ## their CI core with (.github/actions/openms-core there): the libraries and the TOPP ## tools, none of the optional dependencies that take long to build (ONNX Runtime, the @@ -255,13 +278,14 @@ if(DIST_${DIST_CORE}_MODE STREQUAL "source") -DWITH_ONNX=OFF -DWITH_THERMO_RAW=OFF -DPACKAGE_TYPE=none - ${_core_extra_args} + ${DIST_OPENMS_CMAKE_ARGS} BUILD_COMMAND ${CMAKE_COMMAND} --build ${_core_test_args} INSTALL_COMMAND ${CMAKE_COMMAND} --install USES_TERMINAL_CONFIGURE TRUE USES_TERMINAL_BUILD TRUE ) + _dist_checkout_ref(${DIST_CORE}) _dist_package_configure(${DIST_CORE}) ## the add-ons build against the staged core set(_addon_core_prefix "${DIST_STAGE_DIR}") @@ -280,6 +304,10 @@ else() -DSTAGE_DIR=${DIST_STAGE_DIR} -P "${PROJECT_SOURCE_DIR}/cmake/stage_core_deb.cmake" ) + ## staged again when the installer changes (also with generators that do not track the + ## command line) or the staging scripts do + ExternalProject_Add_StepDependencies(${DIST_CORE} install "${DIST_CORE_DEB}" + "${PROJECT_SOURCE_DIR}/cmake/stage_core_deb.cmake" "${PROJECT_SOURCE_DIR}/cmake/unstage_payload.cmake") set(_addon_core_prefix "${DIST_CORE_SDK_DIR}") endif() @@ -317,6 +345,7 @@ foreach(_id IN LISTS DIST_COMPONENTS) USES_TERMINAL_CONFIGURE TRUE USES_TERMINAL_BUILD TRUE ) + _dist_checkout_ref(${_id}) _dist_package_configure(${_id}) list(APPEND _source_addons ${_id}) endforeach() @@ -346,6 +375,10 @@ foreach(_id IN LISTS DIST_COMPONENTS) -DHOST_PROCESSOR=${CMAKE_HOST_SYSTEM_PROCESSOR} -P "${PROJECT_SOURCE_DIR}/cmake/stage_artifact.cmake" ) + ## staged again when the downloaded payload changes or the staging scripts do + file(GLOB _artifact_files "${DIST_ARTIFACT_DIR_${_id}}/*-payload.tar.gz" "${DIST_ARTIFACT_DIR_${_id}}/*-payload.json") + ExternalProject_Add_StepDependencies(${_id} install ${_artifact_files} + "${PROJECT_SOURCE_DIR}/cmake/stage_artifact.cmake" "${PROJECT_SOURCE_DIR}/cmake/unstage_payload.cmake") list(APPEND _staged_before ${_id}) endforeach() diff --git a/README.md b/README.md index a71686d..45daabb 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,8 @@ is staged (`cmake/stage_artifact.cmake`), the superbuild checks that 1. the tarball is the one the manifest pins and the one its metadata names (sha256); 2. it is for this platform; 3. it was built against exactly the staged core (build IDs); -4. it holds exactly the listed files, with their checksums; +4. it holds exactly the listed files, with their checksums, and nothing but regular files inside + the installation prefix (checked before it is unpacked); 5. none of its files exists in the staging prefix already; 6. it registers no tool name that is registered already. @@ -89,6 +90,14 @@ Because of 3, a payload can only be combined with the core build it was built ag add-on's CI and this distribution therefore take the core from the same place: the published nightly (or release) whose SDK the add-on was built against is the manifest's published core. +Staging a payload (or a published core) again in the same build tree, after a new pin or when a +package type is added later, first removes the files the earlier run staged. + +Downloading the artifact of another repository needs a token with Actions read access to it; the +`GITHUB_TOKEN` of a workflow covers its own repository only. In CI, set the repository secret +`DIST_ARTIFACT_TOKEN` (a fine-grained token or GitHub App token with "Actions: read" on the +add-on repositories) before building a manifest with artifact add-ons. + ## Building ```bash @@ -122,13 +131,13 @@ Options: |---|---|---| | `DIST_PACKAGE_TYPE` | `none` | `deb` or `tgz` for the combined package | | `DIST_MANIFEST` | `manifest.json` | the manifest | -| `DIST_SOURCE_DIR_` | | a checkout of a source component to build, e.g. `DIST_SOURCE_DIR_OpenMS_MetaProSIP` (the name with non-identifier characters replaced by `_`); without it, the pinned commit is cloned | +| `DIST_SOURCE_DIR_` | | a checkout of a source component to build, e.g. `DIST_SOURCE_DIR_OpenMS_MetaProSIP` (the name with non-identifier characters replaced by `_`); without it, the pinned commit is cloned and checked out as the branch `ref` | | `DIST_CORE_SDK_DIR`, `DIST_CORE_DEB` | | published core: the unpacked SDK and the installer | | `DIST_ARTIFACT_DIR_` | | artifact add-on: the downloaded artifact | | `DIST_ENABLE_TESTING` | `ON` | run the tests of each add-on built from source before installing it, and the staged-installation test | | `DIST_TEST_CORE` | `OFF` | also build and run the class and TOPP tests of a core built from source (long) | | `DIST_OPENMS_PRESET` | per host | the CMake preset of OpenMS a core built from source is configured with | -| `DIST_OPENMS_CMAKE_ARGS` | | further configure arguments of a core built from source | +| `DIST_OPENMS_CMAKE_ARGS` | | further configure arguments of a core built from source (`;`-separated; a list value inside one argument with `\|`, e.g. `-DFOO=a\|b`) | | `DIST_ADDON_PREFIX_PATH` | | further `CMAKE_PREFIX_PATH` entries of the add-ons (e.g. Qt) | | `DIST_STAGE_DIR` | `/stage` | the staging prefix | diff --git a/cmake/stage_artifact.cmake b/cmake/stage_artifact.cmake index a15a80f..9719c85 100644 --- a/cmake/stage_artifact.cmake +++ b/cmake/stage_artifact.cmake @@ -25,13 +25,16 @@ cmake_minimum_required(VERSION 3.24 FATAL_ERROR) ### another one's file); ### 6. its tool registry registers no tool name that the staged registries already do. ### Then unpacks it into PAYLOAD_DIR (packaged from there by cmake/package.cmake) and copies -### it into the staging prefix. +### it into the staging prefix. Staging again in the same build tree first removes what the +### earlier run staged (cmake/unstage_payload.cmake), so checks 5 and 6 see only the files +### and tools of the other components. ### ### Arguments: ### NAME the component (for messages) ### ARTIFACT_DIR the downloaded artifact: one *-payload.tar.gz and one *-payload.json ### EXPECTED_SHA256 the sha256 of the tarball as the manifest pins it -### PAYLOAD_DIR where it is unpacked to (emptied first) +### PAYLOAD_DIR where it is unpacked to (what an earlier run unpacked there is +### removed from the staging prefix first) ### STAGE_DIR the staging prefix ### HOST_PROCESSOR CMAKE_HOST_SYSTEM_PROCESSOR of the superbuild @@ -46,6 +49,7 @@ function(fail) message(FATAL_ERROR "${NAME}: ${_msg}") endfunction() +include("${CMAKE_CURRENT_LIST_DIR}/unstage_payload.cmake") find_program(READELF readelf REQUIRED) ## the GNU build ID of an ELF file, or empty function(build_id out_var file) @@ -137,8 +141,43 @@ endif() #------------------------------------------------------------------------------ # 4. exactly the listed files #------------------------------------------------------------------------------ +## Only regular files (and directories) inside the prefix: listed before anything is +## extracted, so that no entry can write outside the directory it is unpacked to. +execute_process(COMMAND "${CMAKE_COMMAND}" -E tar tf "${_tarballs}" + OUTPUT_VARIABLE _names RESULT_VARIABLE _rc_names) +execute_process(COMMAND "${CMAKE_COMMAND}" -E tar tvf "${_tarballs}" + OUTPUT_VARIABLE _entries RESULT_VARIABLE _rc_entries) +if(NOT _rc_names EQUAL 0 OR NOT _rc_entries EQUAL 0) + fail("cannot list the payload ${_tarballs}") +endif() +string(REGEX REPLACE "\n$" "" _names "${_names}") +string(REGEX REPLACE "\n$" "" _entries "${_entries}") +string(REPLACE ";" "\\;" _names "${_names}") +string(REPLACE ";" "\\;" _entries "${_entries}") +string(REPLACE "\n" ";" _names "${_names}") +string(REPLACE "\n" ";" _entries "${_entries}") +list(LENGTH _names _n_names) +list(LENGTH _entries _n_entries) +if(NOT _n_names EQUAL _n_entries) + fail("cannot list the payload ${_tarballs} unambiguously (an entry name with a line break?)") +endif() +set(_bad_entries) +foreach(_name _entry IN ZIP_LISTS _names _entries) + string(SUBSTRING "${_entry}" 0 1 _type) + if(NOT _type MATCHES "^[-d]$" OR _name MATCHES "(^/|(^|/)\\.\\.(/|$))") + list(APPEND _bad_entries "${_entry}") + endif() +endforeach() +if(_bad_entries) + string(JOIN "\n " _list ${_bad_entries}) + fail("the payload holds entries that are no regular files inside the installation prefix:\n ${_list}") +endif() + +## what an earlier run of this step staged +dist_unstage_payload("${PAYLOAD_DIR}" "${STAGE_DIR}") + set(_unpacked "${PAYLOAD_DIR}.unpacked") -file(REMOVE_RECURSE "${_unpacked}" "${PAYLOAD_DIR}") +file(REMOVE_RECURSE "${_unpacked}") file(ARCHIVE_EXTRACT INPUT "${_tarballs}" DESTINATION "${_unpacked}") file(GLOB_RECURSE _present LIST_DIRECTORIES false RELATIVE "${_unpacked}" "${_unpacked}/*") list(SORT _present) diff --git a/cmake/stage_core_deb.cmake b/cmake/stage_core_deb.cmake index 2df5002..af7786d 100644 --- a/cmake/stage_core_deb.cmake +++ b/cmake/stage_core_deb.cmake @@ -11,11 +11,14 @@ cmake_minimum_required(VERSION 3.24 FATAL_ERROR) ### The published core: unpacks the OpenMS installer DEB (which installs into /usr) into ### PAYLOAD_DIR (its /usr becomes the root, as in an installation prefix; packaged from -### there by cmake/package.cmake) and copies that into the staging prefix. +### there by cmake/package.cmake) and copies that into the staging prefix. Staging again in +### the same build tree (e.g. another nightly) first removes the files of the earlier core +### from the staging prefix (cmake/unstage_payload.cmake), so none of them stays behind. ### ### Arguments: ### DEB the OpenMS installer DEB -### PAYLOAD_DIR where its prefix is unpacked to (emptied first) +### PAYLOAD_DIR where its prefix is unpacked to (what an earlier run unpacked there is +### removed from the staging prefix first) ### STAGE_DIR the staging prefix foreach(_required DEB PAYLOAD_DIR STAGE_DIR) @@ -24,9 +27,11 @@ foreach(_required DEB PAYLOAD_DIR STAGE_DIR) endif() endforeach() +include("${CMAKE_CURRENT_LIST_DIR}/unstage_payload.cmake") find_program(DPKG_DEB dpkg-deb REQUIRED) +dist_unstage_payload("${PAYLOAD_DIR}" "${STAGE_DIR}") set(_unpacked "${PAYLOAD_DIR}.unpacked") -file(REMOVE_RECURSE "${_unpacked}" "${PAYLOAD_DIR}") +file(REMOVE_RECURSE "${_unpacked}") execute_process(COMMAND "${DPKG_DEB}" -x "${DEB}" "${_unpacked}" COMMAND_ERROR_IS_FATAL ANY) if(NOT IS_DIRECTORY "${_unpacked}/usr") message(FATAL_ERROR "The installer ${DEB} does not install into /usr") diff --git a/cmake/unstage_payload.cmake b/cmake/unstage_payload.cmake new file mode 100644 index 0000000..13a039a --- /dev/null +++ b/cmake/unstage_payload.cmake @@ -0,0 +1,49 @@ +# Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin +# SPDX-License-Identifier: BSD-3-Clause +# +# -------------------------------------------------------------------------- +# $Maintainer: Timo Sachsenberg $ +# $Authors: Timo Sachsenberg $ +# -------------------------------------------------------------------------- + +### Included by the staging scripts (cmake/stage_core_deb.cmake, cmake/stage_artifact.cmake) +### so that staging a component again in the same build tree (a new pin, a package type +### added later, an earlier component staged again) starts from a staging prefix without +### that component. + +## Removes from what an earlier run staged from (the tree that run +## copied into the staging prefix), then itself. A staged file is removed only +## while it is still the one that was copied (same content, or the same target of a symbolic +## link), so a file of another component is never removed. +function(dist_unstage_payload payload_dir stage_dir) + if(NOT IS_DIRECTORY "${payload_dir}") + return() + endif() + file(GLOB_RECURSE _previous LIST_DIRECTORIES false RELATIVE "${payload_dir}" "${payload_dir}/*") + set(_removed 0) + foreach(_path IN LISTS _previous) + set(_old "${payload_dir}/${_path}") + set(_staged "${stage_dir}/${_path}") + if(IS_SYMLINK "${_old}") + if(IS_SYMLINK "${_staged}") + file(READ_SYMLINK "${_old}" _old_target) + file(READ_SYMLINK "${_staged}" _staged_target) + if(_old_target STREQUAL _staged_target) + file(REMOVE "${_staged}") + math(EXPR _removed "${_removed} + 1") + endif() + endif() + elseif(EXISTS "${_staged}" AND NOT IS_SYMLINK "${_staged}" AND NOT IS_DIRECTORY "${_staged}") + file(SHA256 "${_old}" _old_sha) + file(SHA256 "${_staged}" _staged_sha) + if(_old_sha STREQUAL _staged_sha) + file(REMOVE "${_staged}") + math(EXPR _removed "${_removed} + 1") + endif() + endif() + endforeach() + file(REMOVE_RECURSE "${payload_dir}") + if(_removed GREATER 0) + message(STATUS "Removed ${_removed} files of the earlier staging of ${payload_dir} from ${stage_dir}") + endif() +endfunction() diff --git a/tools/ci/fetch_components.py b/tools/ci/fetch_components.py index 2f3c0a8..799211f 100755 --- a/tools/ci/fetch_components.py +++ b/tools/ci/fetch_components.py @@ -206,7 +206,15 @@ def fetch_artifact(comp, dest): out = os.path.join(dest, comp["name"] + "-artifact") shutil.rmtree(out, ignore_errors=True) os.makedirs(out) - run(["gh", "run", "download", str(art["run_id"]), "--repo", art["repository"], "--name", art["name"], "--dir", out]) + try: + run(["gh", "run", "download", str(art["run_id"]), "--repo", art["repository"], "--name", art["name"], "--dir", out]) + except subprocess.CalledProcessError: + # Downloading an artifact of another repository needs a token with Actions read + # access to that repository; the GITHUB_TOKEN of a workflow covers its own one only. + sys.exit(f"ERROR: {comp['name']}: cannot download the artifact {art['name']} of run {art['run_id']} of " + f"{art['repository']}. It may have expired (artifacts are kept for a limited time), or the " + f"token (GH_TOKEN) has no Actions read access to {art['repository']}: in the CI of " + f"OpenMS-Distribution, set the secret DIST_ARTIFACT_TOKEN.") payloads = [f for f in os.listdir(out) if f.endswith("-payload.tar.gz")] metas = [f for f in os.listdir(out) if f.endswith("-payload.json")] if len(payloads) != 1 or len(metas) != 1: From 50c146ed101d50217bf85e72fd74ee9d096a80ef Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 3 Dec 2026 07:21:07 +0000 Subject: [PATCH 3/4] Record the pilot of a published core with a payload add-on manifests/pilot-published-artifact.json: the OpenMS nightly 2026.12.03 (the first nightly without MetaProSIP) as published core, OpenMS-TOPP-GUI from source against its SDK, and the MetaProSIP payload that OpenMS-MetaProSIP's CI built and tested against that nightly (run 47056224980, sha256 7d9d61a4). Built with the manifest input of build.yml. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0149aXmZhZtnMkPBQ7zPTrXN --- README.md | 5 ++++ manifests/pilot-published-artifact.json | 32 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 manifests/pilot-published-artifact.json diff --git a/README.md b/README.md index 45daabb..24cea7c 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,11 @@ package of that component alone, which the combined DEB replaces). Then one of: The add-ons must have the version of the core: they find it with `find_package(OpenMS EXACT)`. A release pins tags' commits and a released core. +`manifests/pilot-published-artifact.json` records the pilot of the published and artifact modes: the +OpenMS nightly 2026.12.03 as published core, OpenMS-TOPP-GUI from source, and the MetaProSIP payload +its CI built against that nightly. Build it with the `manifest` input of the workflow +(`workflow_dispatch`). Its pins expire with the nightly folder and the artifact. + ### Artifact add-ons An add-on payload (format 1) is a tarball of the add-on's runtime files relative to the diff --git a/manifests/pilot-published-artifact.json b/manifests/pilot-published-artifact.json new file mode 100644 index 0000000..8ae3310 --- /dev/null +++ b/manifests/pilot-published-artifact.json @@ -0,0 +1,32 @@ +{ + "comment": "Pilot of the published core and artifact add-on modes (README.md, Manifest): the OpenMS nightly 2026.12.03 (develop 414eb811, the first nightly without MetaProSIP) as published core, OpenMS-TOPP-GUI built from source against its SDK, and OpenMS-MetaProSIP as the runtime payload its CI built and tested against that nightly (main 0a84f6b, SDK mode). Pinned folders and artifacts expire (archive retention of nightlies, 90 days for the artifact): a record of the pilot, not a manifest to build later.", + "version": "3.7.0", + "components": [ + { + "name": "OpenMS", + "kind": "core", + "deb_package": "openms", + "published": {"channel": "nightly", "version": "2026.12.03"} + }, + { + "name": "OpenMS-TOPP-GUI", + "kind": "addon", + "repository": "https://github.com/OpenMS/OpenMS-TOPP-GUI.git", + "ref": "develop", + "commit": "5e581957e3e265099bfac2b0c616e937716cdf59", + "deb_package": "openms-gui", + "packaged_components": ["library_gui", "GUIApplications", "doc_gui"] + }, + { + "name": "OpenMS-MetaProSIP", + "kind": "addon", + "deb_package": "openms-metaprosip", + "artifact": { + "repository": "OpenMS/OpenMS-MetaProSIP", + "run_id": 47056224980, + "name": "MetaProSIP-payload-Linux-X64", + "sha256": "7d9d61a4115d6e6a2dbade9a500d59b0ced37a5cd410d519370567f8503ad108" + } + } + ] +} From 6fc6843f00c28360002bb38917e6446bcdb4831d Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 3 Dec 2026 07:30:20 +0000 Subject: [PATCH 4/4] Keep the component name in the record of an artifact add-on The record of an artifact add-on carried the artifact's name under "name", and it was merged after the component's own name, so build-info.json listed OpenMS-MetaProSIP as MetaProSIP-payload-Linux-X64 and fetch_fixtures.sh found no OpenMS-MetaProSIP: the install and upgrade tests of the pilot (manifests/pilot-published-artifact.json) failed before installing anything. The artifact's name is recorded as artifact_name, and the component's name and kind are now merged last, so no mode can replace them. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0149aXmZhZtnMkPBQ7zPTrXN --- tools/ci/fetch_components.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/ci/fetch_components.py b/tools/ci/fetch_components.py index 799211f..91841ee 100755 --- a/tools/ci/fetch_components.py +++ b/tools/ci/fetch_components.py @@ -227,7 +227,7 @@ def fetch_artifact(comp, dest): "mode": "artifact", "repository": art["repository"], "run_id": art["run_id"], - "name": art["name"], + "artifact_name": art["name"], "sha256": actual, "tool": meta.get("tool"), "core": meta.get("core"), @@ -253,7 +253,8 @@ def main(): else: a, r = fetch_source(comp, args.dest, args.install_deps) cmake_args += a - record["components"].append({"name": comp["name"], "kind": comp["kind"], **r}) + ## the component's name and kind last: no record of a mode may replace them + record["components"].append({**r, "name": comp["name"], "kind": comp["kind"]}) with open(os.path.join(args.dest, "cmake-args.txt"), "w") as f: f.write("\n".join(cmake_args) + "\n") with open(os.path.join(args.dest, "components.json"), "w") as f: