Merge pull request #253 from amosproj/docs/193-build #590
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
| # SPDX-FileCopyrightText: 2025 robot-visual-perception | |
| # | |
| # SPDX-License-Identifier: CC0-1.0 | |
| name: CI Pipeline | |
| on: | |
| push: | |
| branches: [main] # pushes to main | |
| pull_request: | |
| branches: [main] # # PRs to main | |
| jobs: | |
| # Lint and format stage | |
| lint-licensing: | |
| name: Lint licensing (REUSE) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: REUSE Compliance Check | |
| uses: fsfe/reuse-action@v4 | |
| lint-frontend: | |
| name: Lint frontend | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: 'src/frontend/package-lock.json' | |
| - name: Install dependencies | |
| working-directory: src/frontend | |
| run: npm ci | |
| - name: Lint | |
| run: make lint-frontend | |
| - name: Check formatting | |
| run: make format-check-frontend | |
| lint-backend: | |
| name: Lint backend | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v3 | |
| - name: Set up Python | |
| run: uv python install 3.11 | |
| - name: Install dependencies | |
| run: make install-backend | |
| - name: Lint | |
| run: make lint-backend | |
| - name: Check formatting | |
| run: make format-check-backend | |
| # Build stage | |
| build-frontend: | |
| name: Build frontend | |
| runs-on: ubuntu-latest | |
| needs: [lint-frontend] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: 'src/frontend/package-lock.json' | |
| - name: Install dependencies | |
| working-directory: src/frontend | |
| run: npm ci | |
| - name: Build | |
| working-directory: src/frontend | |
| run: npm run build | |
| build-backend: | |
| name: Build backend | |
| runs-on: ubuntu-latest | |
| needs: [lint-backend] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v3 | |
| - name: Set up Python | |
| run: uv python install 3.11 | |
| - name: Install dependencies | |
| run: make install-backend | |
| - name: Build (import check) | |
| working-directory: src/backend | |
| run: | | |
| uv run python -c "import streamer.main" | |
| uv run python -c "import analyzer.main" | |
| # Test stage | |
| test-frontend: | |
| name: Test frontend | |
| runs-on: ubuntu-latest | |
| needs: [build-frontend] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: 'src/frontend/package-lock.json' | |
| - name: Install dependencies | |
| working-directory: src/frontend | |
| run: npm ci | |
| - name: Test | |
| run: make test-frontend | |
| test-backend: | |
| name: Test backend | |
| runs-on: ubuntu-latest | |
| needs: [build-backend] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v3 | |
| - name: Set up Python | |
| run: uv python install 3.11 | |
| - name: Install dependencies | |
| run: make install-backend | |
| - name: Test | |
| run: make test-backend | |
| # Package stage | |
| package-frontend: | |
| name: Package frontend | |
| runs-on: ubuntu-latest | |
| needs: [test-frontend] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image | |
| run: make docker-build-frontend | |
| package-backend: | |
| name: Package backend | |
| runs-on: ubuntu-latest | |
| needs: [test-backend] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image | |
| run: make docker-build-backend | |
| test-docker-compose: | |
| name: Test docker-compose | |
| runs-on: ubuntu-latest | |
| needs: [package-backend, package-frontend] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build images | |
| run: make docker-build | |
| - name: Remove camera device for CI | |
| # GH actions don't have /dev/video0, remove it to allow containers to start | |
| run: sed -i '/devices:/,+1d' docker-compose.yml | |
| - name: Start services | |
| run: docker compose up -d && sleep 30 | |
| - name: Test health endpoints | |
| run: | | |
| curl -f http://localhost:8000/health | |
| curl -f http://localhost:8001/health | |
| curl -f http://localhost:8080 | |
| - name: Test service connectivity | |
| # Use Python instead of curl since analyzer container doesn't have curl installed | |
| run: docker compose exec -T analyzer python -c "import urllib.request; urllib.request.urlopen('http://streamer:8000/health')" | |
| - name: Show logs on failure | |
| if: failure() | |
| run: docker compose logs | |
| - name: Cleanup | |
| if: always() | |
| run: docker compose down |