feat: add integration test infrastructure with E2E SMS tests #17
This file contains hidden or 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: integration-test | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| jobs: | |
| integration-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout 🛎 | |
| uses: actions/checkout@v4 | |
| - name: Checkout httpsms-go SDK | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: NdoleStudio/httpsms-go | |
| ref: feature/add-phone-webhook-services | |
| path: httpsms-go | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.23" | |
| - name: Fix SDK replace path for CI | |
| working-directory: ./tests | |
| run: | | |
| sed -i 's|replace github.com/NdoleStudio/httpsms-go => ../../httpsms-go|replace github.com/NdoleStudio/httpsms-go => ../httpsms-go|' go.mod | |
| - name: Generate Firebase credentials | |
| run: | | |
| bash tests/generate-firebase-credentials.sh tests/firebase-credentials.json | |
| echo "FIREBASE_CREDENTIALS=$(jq -c . tests/firebase-credentials.json)" >> $GITHUB_ENV | |
| - name: Start services 🐳 | |
| working-directory: ./tests | |
| run: docker compose up -d --build | |
| - name: Wait for services to be healthy | |
| working-directory: ./tests | |
| run: | | |
| echo "Waiting for API to be healthy..." | |
| for i in $(seq 1 40); do | |
| if docker compose exec api curl -sf http://localhost:8000/health >/dev/null 2>&1; then | |
| echo "API is healthy!" | |
| break | |
| fi | |
| if [ $i -eq 40 ]; then | |
| echo "API failed to become healthy" | |
| docker compose logs api | |
| exit 1 | |
| fi | |
| echo "Attempt $i/40 - waiting 5s..." | |
| sleep 5 | |
| done | |
| - name: Wait for seed to complete | |
| working-directory: ./tests | |
| run: | | |
| echo "Waiting for seed container to finish..." | |
| docker compose wait seed || true | |
| sleep 2 | |
| - name: Run integration tests 🧪 | |
| working-directory: ./tests | |
| run: go test -v -timeout 300s ./... | |
| - name: Collect logs on failure 📋 | |
| if: failure() | |
| working-directory: ./tests | |
| run: | | |
| docker compose logs --tail 200 | |
| - name: Stop services 🛑 | |
| if: always() | |
| working-directory: ./tests | |
| run: docker compose down -v |