launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #31356
[Merge] ~tushar5526/launchpad-buildd:local-ci-for-ubuntu-series into launchpad-buildd:master
Tushar Gupta has proposed merging ~tushar5526/launchpad-buildd:local-ci-for-ubuntu-series into launchpad-buildd:master.
Commit message:
feat: Add a script to test for multiple ubuntu series
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~tushar5526/launchpad-buildd/+git/launchpad-buildd/+merge/472321
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~tushar5526/launchpad-buildd:local-ci-for-ubuntu-series into launchpad-buildd:master.
diff --git a/Makefile b/Makefile
index 50c8db8..f1ee16e 100644
--- a/Makefile
+++ b/Makefile
@@ -18,14 +18,14 @@ realclean:
rm -f ../launchpad-buildd*deb
rm -f ../launchpad-buildd*changes
-.PHONY: all clean deb install realclean src check docs
+.PHONY: all clean deb install realclean src check docs test-ubuntu-series
check:
PYTHONPATH=$(CURDIR):$(PYTHONPATH) python3 -m testtools.run \
discover -v
install:
- sudo add-apt-repository ppa:launchpad/ppa \
+ sudo add-apt-repository -y ppa:launchpad/ppa \
&& sudo apt-get update \
&& cat system-dependencies.txt | sudo xargs apt-get install -y \
@@ -34,3 +34,6 @@ install-build-deps: install
docs:
sphinx-build -M html docs docs/_build
+
+test-ubuntu-series:
+ @./run-tests.sh
\ No newline at end of file
diff --git a/run-tests.sh b/run-tests.sh
new file mode 100755
index 0000000..3af0c80
--- /dev/null
+++ b/run-tests.sh
@@ -0,0 +1,87 @@
+#!/bin/bash
+
+# Function to calculate and print the duration
+print_duration() {
+ local START_TIME=$1
+ local END_TIME
+ END_TIME=$(date +%s)
+ local DURATION=$((END_TIME - START_TIME))
+ local MINUTES=$((DURATION / 60))
+ local SECONDS=$((DURATION % 60))
+ echo "🕒 Duration: ${MINUTES}m ${SECONDS}s"
+}
+
+cleanup_container() {
+ if [ "$CLEANUP" -eq 1 ]; then
+ echo "🧹 Cleaning up container $CONTAINER_NAME..."
+ lxc delete "$CONTAINER_NAME" --force
+ echo "🗑️ Container $CONTAINER_NAME has been removed."
+ else
+ echo "🛑 Skipping cleanup for container $CONTAINER_NAME."
+ fi
+}
+
+setup_lxc_container() {
+ # Exit immediately if any command fails
+ set -e
+
+ # Check if an LXC image argument is provided
+ if [ -z "$1" ]; then
+ echo "🚨 Usage: setup_lxc_container <lxc_image>"
+ return 1
+ fi
+
+ LXC_IMAGE=$1
+ CONTAINER_NAME="lp-buildd-$(uuidgen | cut -d'-' -f1)"
+ CLEANUP=${CLEANUP_CONTAINER:-1} # Default to 1 if not set
+
+
+
+ echo "🚀 Launching container $CONTAINER_NAME with image $LXC_IMAGE..."
+ # Launch LXC container
+ lxc launch "$LXC_IMAGE" "$CONTAINER_NAME"
+
+ echo "Sleeping for 5 seconds for container to boot up!"
+ sleep 5
+
+ echo "🔧 Setting up container $CONTAINER_NAME..."
+ lxc exec "$CONTAINER_NAME" -- sh -c "apt update && apt install -y make" &&
+ echo "📥 Cloning repository in container $CONTAINER_NAME..." &&
+ lxc exec "$CONTAINER_NAME" -- sh -c "git clone https://git.launchpad.net/launchpad-buildd /root/lp-buildd" &&
+ echo "🔨 Building and checking in container $CONTAINER_NAME..." &&
+ lxc exec "$CONTAINER_NAME" -- sh -c "cd /root/lp-buildd && make install-build-deps" &&
+ lxc exec "$CONTAINER_NAME" -- sh -c "cd /root/lp-buildd && make check" &&
+ echo "📦 Installing build dependencies and creating package in container $CONTAINER_NAME..." &&
+ lxc exec "$CONTAINER_NAME" -- sh -c "cd /root/lp-buildd && make deb" &&
+ echo "✅ Setup completed for container $CONTAINER_NAME based on image $LXC_IMAGE." ||
+ echo "❌ Setup failed for container $CONTAINER_NAME."
+}
+
+# Run the function for each series in parallel and log the output
+run_in_parallel() {
+ local SERIES_ARRAY=("ubuntu:24.04" "ubuntu:22.04" "ubuntu:20.04")
+
+ for SERIES in "${SERIES_ARRAY[@]}"; do
+ # Extract the series name for log file naming
+ # Start timing
+ SERIES_NAME=$(echo "$SERIES" | cut -d':' -f2)
+ # Run in background and log output to a file using tee
+ (
+ local START_TIME
+ START_TIME=$(date +%s)
+ echo "Starting setup for $SERIES..."
+ if setup_lxc_container "$SERIES"; then
+ echo "✅ Setup for $SERIES completed successfully: $(print_duration "$START_TIME")"
+ else
+ echo "❌ Setup for $SERIES failed: $(print_duration "$START_TIME")"
+ fi
+
+ cleanup_container
+ ) | tee "${SERIES_NAME}_setup.log" &
+ done
+
+ wait # Wait for all background jobs to finish
+}
+
+# Run the script in parallel for Noble, Focal, and Jammy
+run_in_parallel
Follow ups