From b5c6f9f18bfe71dc2038693bdd8d0eb7b0aa5547 Mon Sep 17 00:00:00 2001 From: Torsten Wierschin Date: Fri, 17 Jul 2026 16:48:58 +0200 Subject: [PATCH] migration: add automate_migrate_Lts_DDS.sh to run clang-tidy and Strix (best-effort) inside Docker image\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- migration/automate_migrate_Lts_DDS.sh | 81 +++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100755 migration/automate_migrate_Lts_DDS.sh diff --git a/migration/automate_migrate_Lts_DDS.sh b/migration/automate_migrate_Lts_DDS.sh new file mode 100755 index 000000000..59a434ae5 --- /dev/null +++ b/migration/automate_migrate_Lts_DDS.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash +set -euo pipefail + +# automate_migrate_Lts_DDS.sh +# Run inside migration Docker image (migration-pipeline:ubuntu22.04) +# - Installs lightweight tooling (clang-tidy, clang-format, pip) +# - Runs clang-tidy fixes (safe checks) over Lts/DDS +# - Runs strix to generate tests for modified functions (if strix available) +# - Commits changes incrementally + +REPO_DIR="/repo" +MODULE="Lts/DDS" +BUILD_DIR="/repo/build_migrate_Lts_DDS" + +echo "This script must run inside the migration image with network access. It will attempt to install tools and +apply automated clang-tidy fixes. Review changes before pushing." + +apt-get update +apt-get install -y --no-install-recommends clang-tidy clang-format python3-pip git || true + +# Install strix via pip if available (strix has a pip package 'strix' — fallback: clone usestrix/strix) +if ! python3 -m pip show strix >/dev/null 2>&1; then + pip install --upgrade pip setuptools || true + if python3 -m pip install strix; then + echo "Installed strix via pip" + else + echo "strix pip install failed; cloning repository as fallback" + TMP=$(mktemp -d) + git clone --depth 1 https://github.com/usestrix/strix.git "$TMP" || true + if [ -d "$TMP" ]; then + pip install --upgrade "$TMP" || true + fi + fi +fi + +# Run clang-tidy fixes (safe subset) +# NOTE: This uses compile_commands from the build dir. Ensure build_migrate_Lts_DDS has been configured. +if [ ! -f "${BUILD_DIR}/compile_commands.json" ]; then + echo "Configuring build dir to generate compile_commands.json" + mkdir -p "${BUILD_DIR}" + cd "${BUILD_DIR}" + cmake -S "${REPO_DIR}" -B "${BUILD_DIR}" -G Ninja -DCMAKE_PREFIX_PATH=/opt/Qt/6.8.3/gcc_64:/usr/local -DCMAKE_CXX_STANDARD=20 -DMIGRATE_MODULE=${MODULE} -DBUILD_TESTING=OFF + cd "${REPO_DIR}" +fi + +# Safe checks: modernize-use-nullptr, modernize-loop-convert, readability-identifier-naming (no-apply) +CHECKS="-checks=modernize-*,-modernize-use-trailing-return-type,-modernize-raw-string-literal" + +# Run clang-tidy and auto-fix per file +FILES=$(git ls-files "${MODULE}" | grep -E "\.(cpp|cc|cxx|h|hpp)$" || true) +for f in $FILES; do + echo "Running clang-tidy on $f" + clang-tidy $f -p "${BUILD_DIR}" ${CHECKS} --format-style=file -fix -quiet || true +done + +# Format changed files +for f in $FILES; do + git ls-files -m | grep -q "^$f$" && clang-format -i "$f" || true +done + +# Commit changes if any +if [ -n "$(git status --porcelain)" ]; then + git add ${MODULE} + git commit -m "migrate(Lts/DDS): apply clang-tidy modernization fixes\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>" || true + echo "Committed automated clang-tidy fixes for ${MODULE}" +else + echo "No changes from clang-tidy" +fi + +# Attempt to run strix to produce tests (best-effort) +if python3 -m strix --help >/dev/null 2>&1; then + echo "Running strix to generate tests (best-effort)" + # Example invocation: strix --target --out tests/ + mkdir -p migration/strix-tests + # This is a placeholder; actual strix usage depends on build artifacts and symbols + echo "Stripe test generation placeholder: run strix manually against built binaries." +else + echo "strix not available; skipping test generation" +fi + +echo "Automated migration script finished. Review git status and run full builds."