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
30 changes: 30 additions & 0 deletions .github/scripts/expected-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# CI-only: print the version strings the build is expected to embed, as `key=value` lines suitable for
# appending to $GITHUB_OUTPUT. Used to assert requirement 4 (dual-version reporting).
#
# mrtrix=<...> replicates MRtrix3's cmake/FindVersion.cmake exactly: `git describe --abbrev=8
# --dirty --always` when a tag is reachable, else the MRtrix3 base version.
# project=<...> the project version recorded by splice-project.sh (git describe of the project src);
# this is exactly what the build embeds via cmake/project_version.cpp.in.
#
# Usage: expected-versions.sh <mrtrix3_source_dir>
set -euo pipefail

MR_SRC="$1"

tag="$(git -C "$MR_SRC" describe --abbrev=0 2>/dev/null || true)"
commit="$(git -C "$MR_SRC" describe --abbrev=8 --dirty --always 2>/dev/null || true)"
if [ -n "$tag" ] && [ -n "$commit" ]; then
mrtrix="$commit"
else
# Fall back to the MRtrix3 base version declared in its top-level project().
mrtrix="$(grep -m1 -oE 'VERSION [0-9]+\.[0-9]+(\.[0-9]+)?' "$MR_SRC/CMakeLists.txt" | awk '{print $2}')"
fi

project=""
if [ -f cmake/spliced_project_version.txt ]; then
project="$(head -n1 cmake/spliced_project_version.txt)"
fi

echo "mrtrix=$mrtrix"
echo "project=$project"
50 changes: 50 additions & 0 deletions .github/scripts/shape-scenario.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
# CI-only: shape the spliced demo tree into one of the test scenarios. All demo-specific knowledge
# (command names, the demo's MRtrix3 dependencies) lives here, inside .github/, so the template proper
# stays project-agnostic.
#
# Environment:
# CMDFILE none | subset | all | pydep -> what to write into cmake/mrtrix3_commands.txt
# (pydep lists a single MRtrix3 *Python* command, named by PYDEP_CMD; this exercises
# the "Python dependency -> build the full C++ set" behaviour)
# PYDEP_CMD name of the MRtrix3 Python command to request when CMDFILE=pydep (default dwishellmath)
# DROP_PYTHON "true" to remove the demo's Python command (yields a no-Python, single-binary project)
# MULTI "true" to add a second C++ command. The demo's own core is split across a header and a
# COMPILED source (cpp/core/algo/geometric_mean.cpp), shared by both C++ commands; with
# more than one command sharing it the build collects that core into a branded
# lib<project>.so (over and above the MRtrix3 core's libmrtrix-core.so). A single command
# instead compiles the same core straight into the binary (no project library).
set -euo pipefail

: "${CMDFILE:=none}"

: "${PYDEP_CMD:=dwishellmath}"

case "$CMDFILE" in
none) : > cmake/mrtrix3_commands.txt ;;
subset) printf 'mrconvert\nmrcalc\nmrmath\n' > cmake/mrtrix3_commands.txt ;;
all) printf '*\n' > cmake/mrtrix3_commands.txt ;;
pydep) printf '%s\n' "$PYDEP_CMD" > cmake/mrtrix3_commands.txt ;;
*) echo "shape-scenario: unknown CMDFILE='$CMDFILE'" >&2; exit 2 ;;
esac
echo "shape-scenario: MRtrix3 command file ($CMDFILE):"; sed 's/^/ /' cmake/mrtrix3_commands.txt

if [ "${DROP_PYTHON:-}" = "true" ]; then
rm -rf python/demo_code/commands/demo_python python/demo_code/commands/demo_python.py
echo "shape-scenario: removed the demo Python command (no-Python project)"
fi

if [ "${MULTI:-}" = "true" ]; then
# A second C++ command that shares the demo's compiled core (geometric_mean.cpp, spliced from the
# demo source). Two commands sharing that real core source is what makes the build collect it into a
# branded lib<project>.so - no CI-synthesised core source is needed any more.
cp cpp/cmd/demo_cpp.cpp cpp/cmd/demo_cpp2.cpp
echo "shape-scenario: added demo_cpp2 (second C++ command sharing the demo's compiled core)"
if [ -f cpp/core/algo/geometric_mean.cpp ]; then
echo "shape-scenario: project compiled core present: cpp/core/algo/geometric_mean.cpp"
else
echo "shape-scenario: ERROR: expected demo compiled core cpp/core/algo/geometric_mean.cpp not found" >&2
echo "shape-scenario: (is DEMO_CODE_REF pinned to a revision that splits geometric_mean.h/.cpp?)" >&2
exit 1
fi
fi
Loading
Loading