bootc/scripts/test-workflow.sh
gursewak1997 f8bd4576cf Add automated release pipeline for CentOS Stream
Implements weekly upstream rebase cadence automation:
- GitLab CI scheduled pipeline (every 6 hours)
- Automatic GitHub release detection
- JIRA ticket creation via API
- Spec file updates with changelog
- Automated MR creation with OSCI Bot integration
- TEST_MODE support for safe testing

Scripts:
- check-upstream-release.sh: Poll GitHub API for new releases
- create-release-mr.sh: Main automation orchestrator
- update-spec.py: Safe spec file updater
- create-jira.sh: JIRA API client
- test-workflow.sh: Local testing utility

Documentation:
- scripts/README.md: Technical documentation
- AUTOMATION-SETUP.md: Step-by-step setup guide
2026-07-06 16:42:32 -07:00

143 lines
4.3 KiB
Bash
Executable File

#!/bin/bash
# Test the release automation workflow locally (dry-run mode)
# This script simulates what the GitLab CI pipeline does without making actual changes
set -euo pipefail
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
echo "========================================="
echo "bootc Release Automation - Test Mode"
echo "========================================="
echo
cd "$REPO_ROOT"
# Step 1: Test release checker
echo "📡 Step 1: Checking for new releases..."
echo "----------------------------------------"
if ! "$SCRIPT_DIR/check-upstream-release.sh"; then
echo "❌ Failed to check releases"
exit 1
fi
echo
echo "📄 Release info:"
cat release.env
echo
source release.env
if [[ "$NEW_RELEASE" != "true" ]]; then
echo "✅ No new release detected"
echo "Current version: $CURRENT_VERSION"
echo "Latest upstream: $VERSION"
echo
echo "To test with a fake version, modify check-upstream-release.sh temporarily."
exit 0
fi
echo "🆕 New release detected: $VERSION"
echo
# Step 2: Test JIRA creation (optional, requires token)
echo "🎫 Step 2: Testing JIRA creation (optional)..."
echo "----------------------------------------"
if [[ -n "${JIRA_API_TOKEN:-}" ]]; then
echo "JIRA_API_TOKEN is set, testing creation..."
if JIRA_TICKET=$("$SCRIPT_DIR/create-jira.sh" "$VERSION"); then
echo "✅ JIRA ticket created: $JIRA_TICKET"
echo
echo "⚠️ WARNING: This created a REAL JIRA ticket!"
echo "You may want to close/delete it: https://issues.redhat.com/browse/$JIRA_TICKET"
else
echo "❌ JIRA creation failed (this is OK for testing)"
JIRA_TICKET="RHEL-TEST-001"
fi
else
echo "⏭️ Skipping JIRA creation (JIRA_API_TOKEN not set)"
JIRA_TICKET="RHEL-TEST-001"
fi
echo
# Step 3: Test spec file update (in a temporary copy)
echo "📝 Step 3: Testing spec file update..."
echo "----------------------------------------"
TEMP_SPEC=$(mktemp)
cp bootc.spec "$TEMP_SPEC"
if "$SCRIPT_DIR/update-spec.py" "$TEMP_SPEC" "$VERSION" "$JIRA_TICKET" "Test Bot <test@example.com>"; then
echo "✅ Spec file updated successfully"
echo
echo "Diff preview:"
diff -u bootc.spec "$TEMP_SPEC" || true
echo
else
echo "❌ Failed to update spec file"
rm -f "$TEMP_SPEC"
exit 1
fi
# Verify spec syntax
if rpmspec --parse "$TEMP_SPEC" > /dev/null 2>&1; then
echo "✅ Spec file syntax is valid"
else
echo "❌ Spec file has syntax errors"
rm -f "$TEMP_SPEC"
exit 1
fi
rm -f "$TEMP_SPEC"
echo
# Step 4: Simulate tarball download
echo "📦 Step 4: Checking tarball availability..."
echo "----------------------------------------"
DOWNLOAD_URL="https://github.com/containers/bootc/releases/download/${RELEASE_TAG}"
TARBALL_MAIN="bootc-${VERSION}.tar.zstd"
TARBALL_VENDOR="bootc-${VERSION}-vendor.tar.zstd"
if curl -I -s -f "${DOWNLOAD_URL}/${TARBALL_MAIN}" > /dev/null; then
echo "✅ Main tarball exists: ${TARBALL_MAIN}"
else
echo "❌ Main tarball not found: ${DOWNLOAD_URL}/${TARBALL_MAIN}"
fi
if curl -I -s -f "${DOWNLOAD_URL}/${TARBALL_VENDOR}" > /dev/null; then
echo "✅ Vendor tarball exists: ${TARBALL_VENDOR}"
else
echo "❌ Vendor tarball not found: ${DOWNLOAD_URL}/${TARBALL_VENDOR}"
fi
echo
# Summary
echo "========================================="
echo "✅ Test Complete!"
echo "========================================="
echo
echo "Summary:"
echo " • Release detection: ✅"
echo " • Spec file update: ✅"
echo " • Spec syntax validation: ✅"
echo " • Tarballs available: ✅"
if [[ -n "${JIRA_API_TOKEN:-}" ]]; then
echo " • JIRA creation: ✅ (real ticket created: $JIRA_TICKET)"
else
echo " • JIRA creation: ⏭️ (skipped, no token)"
fi
echo
echo "Next steps to test full workflow:"
echo " 1. Commit this automation to a test branch"
echo " 2. Configure GitLab CI/CD variables (see AUTOMATION-SETUP.md)"
echo " 3. Push the branch to GitLab"
echo " 4. Run pipeline manually: CI/CD → Pipelines → Run Pipeline"
echo " 5. Add variable: TEST_MODE=true for dry-run"
echo
echo "The real workflow will:"
echo " • Download tarballs"
echo " • Upload to lookaside cache with centpkg"
echo " • Create git branch and commit"
echo " • Push to GitLab and create MR"
echo