|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Test script to verify GitHub repository setup |
| 4 | +# This script should be run after pushing to GitHub |
| 5 | + |
| 6 | +set -e |
| 7 | + |
| 8 | +echo "🔍 Testing GitHub repository setup..." |
| 9 | + |
| 10 | +# Check if we're in a git repository |
| 11 | +if ! git rev-parse --git-dir > /dev/null 2>&1; then |
| 12 | + echo "❌ Not in a git repository" |
| 13 | + exit 1 |
| 14 | +fi |
| 15 | + |
| 16 | +# Check if we have a remote origin |
| 17 | +if ! git remote get-url origin > /dev/null 2>&1; then |
| 18 | + echo "❌ No remote origin configured" |
| 19 | + exit 1 |
| 20 | +fi |
| 21 | + |
| 22 | +ORIGIN_URL=$(git remote get-url origin) |
| 23 | +echo "✅ Remote origin: $ORIGIN_URL" |
| 24 | + |
| 25 | +# Check if we're on main branch |
| 26 | +CURRENT_BRANCH=$(git branch --show-current) |
| 27 | +if [ "$CURRENT_BRANCH" != "main" ]; then |
| 28 | + echo "⚠️ Currently on branch: $CURRENT_BRANCH (should be 'main')" |
| 29 | +else |
| 30 | + echo "✅ On main branch" |
| 31 | +fi |
| 32 | + |
| 33 | +# Check if we have the required files |
| 34 | +echo "" |
| 35 | +echo "📋 Checking required files..." |
| 36 | + |
| 37 | +required_files=( |
| 38 | + ".github/workflows/ci-cd.yml" |
| 39 | + ".github/workflows/pr-test.yml" |
| 40 | + "package.json" |
| 41 | + "package-lock.json" |
| 42 | + ".releaserc.json" |
| 43 | + "CONTRIBUTING.md" |
| 44 | + "README.md" |
| 45 | + "LICENSE" |
| 46 | +) |
| 47 | + |
| 48 | +for file in "${required_files[@]}"; do |
| 49 | + if [ -f "$file" ]; then |
| 50 | + echo "✅ $file" |
| 51 | + else |
| 52 | + echo "❌ $file (missing)" |
| 53 | + exit 1 |
| 54 | + fi |
| 55 | +done |
| 56 | + |
| 57 | +echo "" |
| 58 | +echo "🐳 Checking Docker setup..." |
| 59 | + |
| 60 | +# Check if Docker is available |
| 61 | +if ! command -v docker &> /dev/null; then |
| 62 | + echo "⚠️ Docker not found (install for local testing)" |
| 63 | +else |
| 64 | + echo "✅ Docker available" |
| 65 | + |
| 66 | + # Try to build the image |
| 67 | + if docker build -t md-to-bbcode:test . > /dev/null 2>&1; then |
| 68 | + echo "✅ Docker image builds successfully" |
| 69 | + |
| 70 | + # Test the image |
| 71 | + if echo "# Test" | docker run --rm -i md-to-bbcode:test > /dev/null 2>&1; then |
| 72 | + echo "✅ Docker image works correctly" |
| 73 | + else |
| 74 | + echo "❌ Docker image failed to run" |
| 75 | + exit 1 |
| 76 | + fi |
| 77 | + else |
| 78 | + echo "❌ Docker image build failed" |
| 79 | + exit 1 |
| 80 | + fi |
| 81 | +fi |
| 82 | + |
| 83 | +echo "" |
| 84 | +echo "🧪 Running tests..." |
| 85 | + |
| 86 | +# Run Python tests |
| 87 | +if python test_converter.py > /dev/null 2>&1; then |
| 88 | + echo "✅ Python tests pass" |
| 89 | +else |
| 90 | + echo "❌ Python tests failed" |
| 91 | + exit 1 |
| 92 | +fi |
| 93 | + |
| 94 | +echo "" |
| 95 | +echo "📦 Checking Node.js setup..." |
| 96 | + |
| 97 | +# Check if Node.js is available |
| 98 | +if ! command -v npm &> /dev/null; then |
| 99 | + echo "⚠️ npm not found (needed for semantic-release)" |
| 100 | +else |
| 101 | + echo "✅ npm available" |
| 102 | + |
| 103 | + # Check if dependencies are installed |
| 104 | + if [ -d "node_modules" ]; then |
| 105 | + echo "✅ Node.js dependencies installed" |
| 106 | + else |
| 107 | + echo "🔄 Installing Node.js dependencies..." |
| 108 | + npm ci |
| 109 | + echo "✅ Node.js dependencies installed" |
| 110 | + fi |
| 111 | +fi |
| 112 | + |
| 113 | +echo "" |
| 114 | +echo "🎯 Next steps:" |
| 115 | +echo "1. Push to GitHub: git push origin main" |
| 116 | +echo "2. Check GitHub Actions: https://github.com/YOUR_USERNAME/md_to_bbcode/actions" |
| 117 | +echo "3. Configure repository secrets:" |
| 118 | +echo " - DOCKER_USERNAME: Your Docker Hub username" |
| 119 | +echo " - DOCKER_PASSWORD: Your Docker Hub password/token" |
| 120 | +echo "4. Make a commit with 'feat: initial release' to trigger first release" |
| 121 | + |
| 122 | +echo "" |
| 123 | +echo "🎉 Setup verification complete!" |
0 commit comments