Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
244 changes: 184 additions & 60 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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_<component>).
# 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
Expand All @@ -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
Expand All @@ -32,60 +50,27 @@ 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). 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: ${{ secrets.DIST_ARTIFACT_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
Expand All @@ -98,6 +83,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
Expand All @@ -113,16 +99,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
Expand All @@ -136,9 +119,150 @@ 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 }}
# 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
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"], "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)
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
9 changes: 7 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_<component>=<checkout>]`
- 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`
Expand All @@ -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 <version> 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.
Expand Down
9 changes: 7 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_<component>=<checkout>]`
- 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`
Expand All @@ -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 <version> 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.
Expand Down
Loading
Loading