Skip to content

Add GitHub Actions workflow for automated testing (#15) #22

Add GitHub Actions workflow for automated testing (#15)

Add GitHub Actions workflow for automated testing (#15) #22

Workflow file for this run

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
with:
ssh-key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
- name: Generate Temporary SSH Key
run: |
mkdir -p ~/.ssh
ssh-keygen -t rsa -b 4096 -C "[email protected]" -N "" -f ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
- name: Authorize SSH Key for the Workflow
run: |
curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-X POST \
-d '{"title":"Temporary key","key":"'"$(cat ~/.ssh/id_rsa.pub)"'"}' \
https://api.github.com/repos/${{ github.repository }}/keys
- name: Validate SSH Connection
run: ssh -T [email protected] || (echo "SSH connection failed" && exit 1)
- 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)
fastify-swc-server || echo "CLI installation verified"
- name: Test CLI Functionality
run: |
fastify-swc-server test-fastify-project
ls -la test-fastify-project
cd test-fastify-project
pnpm install
pnpm run build
pnpm dev &
sleep 5
curl -I http://localhost:3000 || echo "Server verification skipped"
pkill -f "node"