|
| 1 | +name: Test fastify-swc-server CLI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master] |
| 6 | + pull_request: |
| 7 | + branches: [master] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout code |
| 15 | + uses: actions/checkout@v4 |
| 16 | + with: |
| 17 | + ssh-key: ${{ secrets.ACTIONS_DEPLOY_KEY }} |
| 18 | + |
| 19 | + - name: Generate Temporary SSH Key |
| 20 | + run: | |
| 21 | + mkdir -p ~/.ssh |
| 22 | + ssh-keygen -t rsa -b 4096 -C "[email protected]" -N "" -f ~/.ssh/id_rsa |
| 23 | + chmod 600 ~/.ssh/id_rsa |
| 24 | + eval "$(ssh-agent -s)" |
| 25 | + ssh-add ~/.ssh/id_rsa |
| 26 | + ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts |
| 27 | +
|
| 28 | + - name: Authorize SSH Key for the Workflow |
| 29 | + run: | |
| 30 | + curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ |
| 31 | + -X POST \ |
| 32 | + -d '{"title":"Temporary key","key":"'"$(cat ~/.ssh/id_rsa.pub)"'"}' \ |
| 33 | + https://api.github.com/repos/${{ github.repository }}/keys |
| 34 | +
|
| 35 | + - name: Validate SSH Connection |
| 36 | + run: ssh -T [email protected] || (echo "SSH connection failed" && exit 1) |
| 37 | + |
| 38 | + - name: Set up pnpm |
| 39 | + uses: pnpm/action-setup@v4 |
| 40 | + with: |
| 41 | + version: "8.6.0" |
| 42 | + |
| 43 | + - name: Set up Node.js |
| 44 | + uses: actions/setup-node@v4 |
| 45 | + with: |
| 46 | + node-version: "lts/*" |
| 47 | + cache: pnpm |
| 48 | + |
| 49 | + - name: Install dependencies (skip prepare script) |
| 50 | + run: pnpm install --ignore-scripts |
| 51 | + |
| 52 | + - name: Pack and install CLI globally |
| 53 | + run: | |
| 54 | + npm pack |
| 55 | + sudo npm install -g $(ls fastify-swc-typescript-server-bootstrap-cli-*.tgz) |
| 56 | + fastify-swc-server || echo "CLI installation verified" |
| 57 | +
|
| 58 | + - name: Test CLI Functionality |
| 59 | + run: | |
| 60 | + fastify-swc-server test-fastify-project |
| 61 | + ls -la test-fastify-project |
| 62 | + cd test-fastify-project |
| 63 | + pnpm install |
| 64 | + pnpm run build |
| 65 | + pnpm dev & |
| 66 | + sleep 5 |
| 67 | + curl -I http://localhost:3000 || echo "Server verification skipped" |
| 68 | + pkill -f "node" |
0 commit comments