Add GitHub Actions workflow for automated testing (#15) #20
Workflow file for this run
This file contains 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 fastify-swc-server CLI | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Generate SSH Key | |
run: | | |
mkdir -p ~/.ssh | |
ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa -N "" -C "[email protected]" | |
chmod 600 ~/.ssh/id_rsa | |
eval "$(ssh-agent -s)" | |
ssh-add ~/.ssh/id_rsa | |
ssh-keyscan github.com >> ~/.ssh/known_hosts | |
echo "Public Key:" | |
cat ~/.ssh/id_rsa.pub | |
id: ssh-key | |
- name: Add SSH Public Key to Repository | |
uses: peter-evans/create-or-update-comment@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
repository: ${{ github.repository }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
Please add this SSH public key as a Deploy Key to your repository: | |
``` | |
${{ steps.ssh-key.outputs.public_key }} | |
``` | |
- name: Debug SSH Connection | |
run: ssh -T [email protected] || echo "SSH connection failed" | |
- name: Set up pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: "8.6.0" | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "lts/*" | |
cache: pnpm | |
- name: Install dependencies (skip prepare script) | |
run: pnpm install --ignore-scripts | |
- name: Pack and install CLI globally | |
run: | | |
npm pack | |
sudo npm install -g $(ls fastify-swc-typescript-server-bootstrap-cli-*.tgz) | |
# Verify CLI is available | |
fastify-swc-server || echo "CLI installation verified" | |
- name: Test CLI Functionality | |
run: | | |
# Create a new project using the CLI | |
fastify-swc-server test-fastify-project | |
# Verify project structure | |
ls -la test-fastify-project | |
# Change into the new project directory | |
cd test-fastify-project | |
# Install dependencies using pnpm | |
pnpm install | |
# Test if the project builds successfully | |
pnpm run build | |
# Run the project in development mode | |
pnpm dev & | |
# Wait briefly for the dev server to start | |
sleep 5 | |
# Verify the server is running (check localhost:3000 by default or configured port) | |
curl -I http://localhost:3000 || echo "Server verification skipped" | |
# Kill the dev server to clean up | |
pkill -f "node" |