Analytics backend #18
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: Tinybird CI | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| branches: | |
| - main | |
| - master | |
| paths: | |
| - 'tinybird/**' | |
| types: [opened, reopened, labeled, unlabeled, synchronize] | |
| concurrency: ${{ github.workflow }}-${{ github.event.pull_request.number }} | |
| permissions: | |
| contents: read | |
| env: | |
| TINYBIRD_HOST: ${{ secrets.TINYBIRD_HOST }} | |
| TINYBIRD_TOKEN: ${{ secrets.TINYBIRD_TOKEN }} | |
| jobs: | |
| ci: | |
| name: Validate | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: 'tinybird' | |
| services: | |
| tinybird: | |
| image: tinybirdco/tinybird-local:latest | |
| ports: | |
| - 7181:7181 | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Install Tinybird CLI | |
| run: curl https://tinybird.co | sh | |
| - name: Build project | |
| run: tb build | |
| - name: Wait for Tinybird Local | |
| run: | | |
| set -euo pipefail | |
| endpoints=("http://localhost:7181/_health" "http://localhost:7181/health") | |
| max_attempts=20 | |
| base_delay=3 | |
| for ((attempt = 1; attempt <= max_attempts; attempt++)); do | |
| for endpoint in "${endpoints[@]}"; do | |
| status=$(curl -fsS -o /dev/null -w "%{http_code}" "$endpoint" || true) | |
| if [[ "$status" == "200" ]]; then | |
| echo "Tinybird local is healthy via $endpoint" | |
| exit 0 | |
| fi | |
| done | |
| sleep_seconds=$((base_delay * attempt)) | |
| echo "Tinybird local not ready (attempt ${attempt}/${max_attempts}). Retrying in ${sleep_seconds}s..." | |
| sleep "$sleep_seconds" | |
| done | |
| echo "Tinybird local failed to become healthy after waiting ~$((base_delay * max_attempts * (max_attempts + 1) / 2))s" >&2 | |
| exit 1 | |
| - name: Test project | |
| run: tb test run | |
| - name: Deployment check | |
| run: tb --cloud --host ${{ env.TINYBIRD_HOST }} --token ${{ env.TINYBIRD_TOKEN }} deploy --check |