Run tests against a local Zuplo development server before deploying anywhere.
Catch issues earlier and avoid deploying broken changes.
.github/workflows/local-test-then-deploy.yaml
name: Local Test Then Deployon: push: branches: - main pull_request:jobs: local-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 20 - name: Install dependencies run: npm install - name: Start local server and run tests run: | # Start the local dev server in the background npx zuplo dev & DEV_PID=$! # Wait for server to be ready echo "Waiting for local server to start..." sleep 10 # Run tests against local server npx zuplo test --endpoint http://localhost:9000 # Stop the dev server kill $DEV_PID deploy: needs: local-test runs-on: ubuntu-latest # Only deploy on push to main, not on PRs if: github.event_name == 'push' && github.ref == 'refs/heads/main' env: ZUPLO_API_KEY: ${{ secrets.ZUPLO_API_KEY }} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 20 - name: Install dependencies run: npm install - name: Deploy to Zuplo run: npx zuplo deploy --api-key "$ZUPLO_API_KEY"
This workflow:
Starts a local Zuplo server in the CI environment
Runs your test suite against localhost
Only proceeds to deployment if local tests pass
Deploys to Zuplo (only on pushes to main)
Why Test Locally First?
Faster feedback — Local tests run without waiting for deployment
Catch syntax errors — The local server validates your configuration
Test policies — Verify authentication, rate limiting, and other policies
work correctly
No wasted deployments — Don't deploy changes that will fail tests
Combining with Remote Tests
For maximum confidence, test both locally and against the deployed environment:
Code
jobs: local-test: # ... local testing job ... deploy-and-test: needs: local-test # ... deploy and run tests against live environment ...