|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Test script for release workflow without actually releasing |
| 4 | +# Usage: ./scripts/test-release.sh |
| 5 | + |
| 6 | +set -e |
| 7 | + |
| 8 | +echo "🧪 Testing release workflow components..." |
| 9 | + |
| 10 | +# Check if we're in the right directory |
| 11 | +if [ ! -f "package.json" ] || [ ! -f ".releaserc.json" ]; then |
| 12 | + echo "❌ Error: Must run from project root directory" |
| 13 | + exit 1 |
| 14 | +fi |
| 15 | + |
| 16 | +# Check if Node.js is available |
| 17 | +if ! command -v node &> /dev/null; then |
| 18 | + echo "❌ Error: Node.js is required but not installed" |
| 19 | + exit 1 |
| 20 | +fi |
| 21 | + |
| 22 | +# Check if npm is available |
| 23 | +if ! command -v npm &> /dev/null; then |
| 24 | + echo "❌ Error: npm is required but not installed" |
| 25 | + exit 1 |
| 26 | +fi |
| 27 | + |
| 28 | +echo "✅ Node.js and npm are available" |
| 29 | + |
| 30 | +# Install dependencies |
| 31 | +echo "📦 Installing dependencies..." |
| 32 | +npm ci |
| 33 | + |
| 34 | +echo "✅ Dependencies installed" |
| 35 | + |
| 36 | +# Test semantic-release dry-run |
| 37 | +echo "🔍 Testing semantic-release dry-run..." |
| 38 | +npx semantic-release --dry-run |
| 39 | + |
| 40 | +echo "✅ Semantic-release dry-run completed" |
| 41 | + |
| 42 | +# Test version update script |
| 43 | +echo "🔧 Testing version update script..." |
| 44 | +./scripts/update-version.sh 9.9.9-test |
| 45 | + |
| 46 | +# Verify the change |
| 47 | +if grep -q "private let _version = \"9.9.9-test\"" Sources/Helpers/Version.swift; then |
| 48 | + echo "✅ Version update script works correctly" |
| 49 | +else |
| 50 | + echo "❌ Version update script failed" |
| 51 | + exit 1 |
| 52 | +fi |
| 53 | + |
| 54 | +# Revert the change |
| 55 | +git checkout -- Sources/Helpers/Version.swift |
| 56 | +echo "✅ Version change reverted" |
| 57 | + |
| 58 | +# Test workflow configuration |
| 59 | +echo "📋 Testing workflow configuration..." |
| 60 | + |
| 61 | +# Check if required files exist |
| 62 | +required_files=( |
| 63 | + ".github/workflows/release.yml" |
| 64 | + ".releaserc.json" |
| 65 | + "package.json" |
| 66 | + "scripts/update-version.sh" |
| 67 | + "Sources/Helpers/Version.swift" |
| 68 | +) |
| 69 | + |
| 70 | +for file in "${required_files[@]}"; do |
| 71 | + if [ -f "$file" ]; then |
| 72 | + echo "✅ $file exists" |
| 73 | + else |
| 74 | + echo "❌ $file missing" |
| 75 | + exit 1 |
| 76 | + fi |
| 77 | +done |
| 78 | + |
| 79 | +# Check semantic-release configuration |
| 80 | +if npx semantic-release --dry-run --help &> /dev/null; then |
| 81 | + echo "✅ Semantic-release is properly configured" |
| 82 | +else |
| 83 | + echo "❌ Semantic-release configuration error" |
| 84 | + exit 1 |
| 85 | +fi |
| 86 | + |
| 87 | +echo "" |
| 88 | +echo "🎉 All tests passed! The release workflow should work correctly." |
| 89 | +echo "" |
| 90 | +echo "To test the actual workflow:" |
| 91 | +echo "1. Push this branch to GitHub" |
| 92 | +echo "2. Create a PR to main with conventional commit messages" |
| 93 | +echo "3. The release-test workflow will run automatically" |
| 94 | +echo "4. Check the workflow logs for any issues" |
0 commit comments