Add GitHub Actions workflow for automated testing (#26) #33
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test Bootstrapper Script Generator | |
on: | |
pull_request: | |
branches: | |
- master | |
pull_request_target: | |
branches: | |
- master | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Node.js 20 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: latest | |
- name: Install dependencies | |
run: pnpm install | |
- name: Build project | |
run: pnpm build | |
- name: Create test directories | |
run: | | |
mkdir test-dir | |
mkdir -p test-source test-output scripts | |
cat > test-source/package.json << 'EOL' | |
{ | |
"name": "test-app", | |
"version": "1.0.0", | |
"description": "Test app for bootstrapper", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
} | |
} | |
EOL | |
mkdir test-source/src | |
echo 'console.log("Hello World");' > test-source/src/index.js | |
echo 'body { margin: 0; }' > test-source/src/styles.css | |
- name: Pack and install globally | |
run: | | |
npm pack | |
sudo npm install -g $(ls bootstrapper-script-generator-*.tgz) | |
- name: Generate and run bootstrap script | |
run: | | |
# Generate bootstrap script in scripts directory | |
npx make-bootstrapper-script scripts/bootstrap.sh test-source | |
chmod +x scripts/bootstrap.sh | |
# Execute bootstrap script in test-output directory | |
cd test-output | |
../scripts/bootstrap.sh | |
cd .. | |
- name: Compare directories | |
run: | | |
echo "=== Current working directory ===" | |
pwd | |
ls -la | |
echo -e "\n=== Test Source (test-source) directory ===" | |
echo "test-source directory structure:" | |
ls -la test-source/ | |
echo -e "\n=== Test Output (test-output) directory ===" | |
echo "test-output directory structure:" | |
ls -la test-output/ | |
echo -e "\n=== test-source/package.json hex dump ===" | |
xxd test-source/package.json | |
echo -e "\n=== test-output/package.json hex dump ===" | |
xxd test-output/package.json | |
echo -e "\n=== Directory Comparison ===" | |
echo "Comparing directories..." | |
diff_output=$(diff -rB --strip-trailing-cr test-source test-output 2>&1) | |
if [ $? -ne 0 ]; then | |
echo "Directory comparison failed. Differences found:" | |
echo "$diff_output" | |
exit 1 | |
else | |
echo "Directories are identical!" | |
fi |