refac(api): overhaul upload pipeline and fix race conditions #338
Workflow file for this run
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: Test The Application | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| branches: | |
| - main | |
| - dev | |
| jobs: | |
| test-api: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: pnpm/action-setup@v6 | |
| with: | |
| run_install: false | |
| - name: Use Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '22.22.0' | |
| cache: 'pnpm' | |
| - name: install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build workspace packages | |
| run: pnpm -r run build | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.10' | |
| - name: Generate test data | |
| run: | | |
| pip install rosbags | |
| python3 cli/tests/generate_test_data.py | |
| - name: build_stack | |
| run: docker compose -f docker-compose.testing.yml build | |
| env: | |
| BACKEND_URL: 'http://localhost:3000' | |
| GIT_BRANCH: ${{ github.head_ref || github.ref_name }} | |
| GIT_COMMIT: ${{ github.sha }} | |
| - name: clear previous volumes | |
| run: docker compose -f docker-compose.testing.yml down -v | |
| - name: Pre-generate endpoints | |
| working-directory: ./backend | |
| run: | | |
| mkdir -p .endpoints | |
| npm run gen:docs -- .endpoints | |
| - name: launch_stack | |
| working-directory: ./backend | |
| run: | | |
| docker compose -f ../docker-compose.testing.yml up -d | |
| SECONDS=0 | |
| TIMEOUT=180 | |
| while ! curl -s -f http://localhost:3000/auth/available-providers > /dev/null; do | |
| if [ $SECONDS -ge $TIMEOUT ]; then | |
| echo "Timeout reached: API not reachable" | |
| docker logs kleinkram-api-server-test | |
| docker compose -f ../docker-compose.testing.yml down | |
| exit 1 | |
| fi | |
| sleep 1 | |
| echo "waiting for API to be reachable..." | |
| done | |
| echo "API is up. Waiting for Loki to be ready..." | |
| while ! curl -s -f http://localhost:3100/ready > /dev/null; do | |
| if [ $SECONDS -ge $TIMEOUT ]; then | |
| echo "Timeout reached: Loki not ready" | |
| docker compose -f ../docker-compose.testing.yml logs loki | |
| docker compose -f ../docker-compose.testing.yml down | |
| exit 1 | |
| fi | |
| sleep 2 | |
| echo "Waiting for Loki... ($SECONDS seconds elapsed)" | |
| done | |
| echo "All services are up. Running tests..." | |
| # This will now cause the step to fail immediately if tests fail. | |
| pnpm test --ci | |
| echo "Tests passed successfully." | |
| - name: Clean up | |
| if: always() | |
| run: echo "Cleanup done" | |
| - name: Stop Docker stack | |
| if: always() | |
| run: docker compose -f docker-compose.testing.yml down | |
| - name: Delete Docker volumes | |
| if: always() | |
| run: docker volume prune -f |