|
| 1 | +name: Test Bootstrapper Script Generator |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request_target: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + |
| 11 | +jobs: |
| 12 | + test: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v3 |
| 17 | + |
| 18 | + - name: Set up Node.js 20 |
| 19 | + uses: actions/setup-node@v3 |
| 20 | + with: |
| 21 | + node-version: 20 |
| 22 | + |
| 23 | + - name: Install pnpm |
| 24 | + uses: pnpm/action-setup@v2 |
| 25 | + with: |
| 26 | + version: latest |
| 27 | + |
| 28 | + - name: Install dependencies |
| 29 | + run: pnpm install |
| 30 | + |
| 31 | + - name: Build project |
| 32 | + run: pnpm build |
| 33 | + |
| 34 | + - name: Create test directories |
| 35 | + run: | |
| 36 | + mkdir test-dir |
| 37 | + mkdir -p test-source test-output scripts |
| 38 | + # Copy project files with text mode and line ending normalization |
| 39 | + rsync -av --no-times \ |
| 40 | + --exclude 'node_modules' \ |
| 41 | + --exclude '.git' \ |
| 42 | + --exclude '.github' \ |
| 43 | + --exclude 'test-dir' \ |
| 44 | + --exclude 'test-output' \ |
| 45 | + --exclude 'test-source' \ |
| 46 | + --exclude 'scripts' \ |
| 47 | + --exclude 'dist' \ |
| 48 | + --cvs-exclude \ |
| 49 | + . test-source/ |
| 50 | +
|
| 51 | + - name: Pack and install globally |
| 52 | + run: | |
| 53 | + npm pack |
| 54 | + sudo npm install -g $(ls bootstrapper-script-generator-*.tgz) |
| 55 | +
|
| 56 | + - name: Generate and run bootstrap script |
| 57 | + run: | |
| 58 | + # Generate bootstrap script in scripts directory |
| 59 | + npx make-bootstrapper-script scripts/bootstrap.sh test-source |
| 60 | + chmod +x scripts/bootstrap.sh |
| 61 | +
|
| 62 | + # Execute bootstrap script in test-output directory |
| 63 | + cd test-output |
| 64 | + ../scripts/bootstrap.sh |
| 65 | + cd .. |
| 66 | +
|
| 67 | + - name: Install dos2unix |
| 68 | + run: sudo apt-get update && sudo apt-get install -y dos2unix |
| 69 | + |
| 70 | + - name: Remove trailing blank lines |
| 71 | + run: | |
| 72 | + find test-source test-output -type f -exec sed -i ':a;/^\n*$/{$d;N;};/\n$/ba' {} + |
| 73 | +
|
| 74 | + - name: Compare directories |
| 75 | + run: | |
| 76 | + echo -e "\n=== Directory Comparison ===" |
| 77 | + diff_output=$(diff -r --ignore-all-space --strip-trailing-cr test-source test-output || true) |
| 78 | + if [ -n "$diff_output" ]; then |
| 79 | + echo "Directory comparison failed. Differences found:" |
| 80 | + echo "$diff_output" |
| 81 | + exit 1 |
| 82 | + else |
| 83 | + echo "Directories are identical!" |
| 84 | + fi |
| 85 | +
|
| 86 | + - name: Debug differences |
| 87 | + run: | |
| 88 | + diff -rq test-source test-output | awk '{print $2}' | while read file; do |
| 89 | + echo "=== Debugging $file ===" |
| 90 | + echo "Hex dump of test-source/$file:" |
| 91 | + xxd "test-source/${file#test-source/}" || echo "File not found in test-source: $file" |
| 92 | + echo "Hex dump of test-output/$file:" |
| 93 | + xxd "test-output/${file#test-output/}" || echo "File not found in test-output: $file" |
| 94 | + done |
0 commit comments