Skip to content

Commit 240d4ed

Browse files
Add GitHub Actions workflow for automated testing
1 parent 3bffcb9 commit 240d4ed

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

.github/workflows/test.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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 'scripts' \
45+
--exclude 'dist' \
46+
--cvs-exclude \
47+
. test-source/
48+
49+
- name: Pack and install globally
50+
run: |
51+
npm pack
52+
sudo npm install -g $(ls bootstrapper-script-generator-*.tgz)
53+
54+
- name: Generate and run bootstrap script
55+
run: |
56+
# Generate bootstrap script in scripts directory
57+
npx make-bootstrapper-script scripts/bootstrap.sh test-source
58+
chmod +x scripts/bootstrap.sh
59+
60+
# Execute bootstrap script in test-output directory
61+
cd test-output
62+
../scripts/bootstrap.sh
63+
cd ..
64+
65+
- name: Install dos2unix
66+
run: sudo apt-get update && sudo apt-get install -y dos2unix
67+
68+
- name: Remove trailing blank lines
69+
run: |
70+
find test-source test-output -type f -exec sed -i ':a;/^\n*$/{$d;N;};/\n$/ba' {} +
71+
72+
- name: Compare directories
73+
run: |
74+
echo -e "\n=== Directory Comparison ==="
75+
diff_output=$(diff -r --ignore-all-space --strip-trailing-cr test-source test-output || true)
76+
if [ -n "$diff_output" ]; then
77+
echo "Directory comparison failed. Differences found:"
78+
echo "$diff_output"
79+
exit 1
80+
else
81+
echo "Directories are identical!"
82+
fi
83+
84+
- name: Debug differences
85+
run: |
86+
diff -rq test-source test-output | awk '{print $2}' | while read file; do
87+
echo "=== Debugging $file ==="
88+
echo "Hex dump of test-source/$file:"
89+
xxd "test-source/${file#test-source/}" || echo "File not found in test-source: $file"
90+
echo "Hex dump of test-output/$file:"
91+
xxd "test-output/${file#test-output/}" || echo "File not found in test-output: $file"
92+
done

0 commit comments

Comments
 (0)