Add GitHub Actions workflow for automated testing (#15) #21
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: Output SSH Public Key | |
run: | | |
echo "Please manually add the following public key as a Deploy Key:" | |
cat ~/.ssh/id_rsa.pub | |
- name: Validate SSH Connection | |
run: ssh -T [email protected] | |
- 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" |