From 04410ed18110c206005705f83bc654ba3c3e9bc1 Mon Sep 17 00:00:00 2001 From: Sushant Date: Mon, 15 Jun 2026 11:05:53 +0530 Subject: [PATCH 1/2] fix: CI workflow - add setup steps, split test jobs, add coverage upload - Add actions/setup-python@v5 for Python 3.12 - Add actions/setup-node@v4 for Node 20 - Install backend and analytics deps before lint/test - Split test job into test-backend and test-analytics - Use npm ci for frontend dependency install - Add ruff for Python linting - Add Buildx for Docker image builds with caching - Add coverage artifact uploads - Add release notes generation - Remove npm test (no test script in frontend package.json) --- .github/workflows/ci.yml | 164 +++++++++++++++++++++++++++++++++------ 1 file changed, 141 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 934c38e..e42acc5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,41 +1,151 @@ name: CI -on: [push, pull_request] + +on: + push: + branches: [main, develop] + pull_request: + branches: [main, develop] + +env: + PYTHON_VERSION: "3.12" + NODE_VERSION: "20" + jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Run lint + + - name: Setup Python ${{ env.PYTHON_VERSION }} + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + cache: pip + cache-dependency-path: | + backend/requirements.txt + analytics/requirements.txt + + - name: Setup Node ${{ env.NODE_VERSION }} + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: npm + cache-dependency-path: frontend/package-lock.json + + - name: Install Python deps run: | - # Python lint + pip install -r backend/requirements.txt + pip install -r analytics/requirements.txt pip install ruff - ruff check backend/ - # JS lint - npm install eslint - npm run lint --prefix frontend/ - - test: + + - name: Frontend npm install + run: npm ci + working-directory: frontend + + - name: Lint Python + run: ruff check backend/ analytics/ + + - name: Lint Frontend + run: npm run lint + working-directory: frontend + + - name: Type Check Frontend + run: npm run typecheck + working-directory: frontend + + test-backend: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + + - name: Setup Python ${{ env.PYTHON_VERSION }} + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + cache: pip + cache-dependency-path: backend/requirements.txt + + - name: Install deps + run: pip install -r backend/requirements.txt + - name: Run tests run: | - # Backend tests - pip install pytest pytest-cov - pytest backend/tests/ --cov=backend/app --cov-report=xml - # Frontend tests - npm test --prefix frontend/ -- --coverage - - build: + pytest backend/tests/ \ + --cov=backend/app \ + --cov-report=xml \ + --cov-report=term-missing \ + -v + + - name: Upload coverage + uses: actions/upload-artifact@v4 + with: + name: coverage-backend + path: coverage.xml + + test-analytics: runs-on: ubuntu-latest - needs: [lint, test] steps: - uses: actions/checkout@v4 - - name: Build Docker images + + - name: Setup Python ${{ env.PYTHON_VERSION }} + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + cache: pip + cache-dependency-path: analytics/requirements.txt + + - name: Install deps + run: pip install -r analytics/requirements.txt + + - name: Run tests run: | - docker build -t agentloop-api ./backend - docker build -t agentloop-analytics ./analytics - docker build -t agentloop-frontend ./frontend + pytest analytics/tests/ \ + --cov=analytics/app \ + --cov-report=xml \ + --cov-report=term-missing \ + -v + + - name: Upload coverage + uses: actions/upload-artifact@v4 + with: + name: coverage-analytics + path: coverage.xml + + build: + runs-on: ubuntu-latest + needs: [lint, test-backend, test-analytics] + steps: + - uses: actions/checkout@v4 + + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build API image + uses: docker/build-push-action@v5 + with: + context: backend + push: false + tags: agentloop-api:latest + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Build Analytics image + uses: docker/build-push-action@v5 + with: + context: analytics + push: false + tags: agentloop-analytics:latest + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Build Frontend image + uses: docker/build-push-action@v5 + with: + context: frontend + push: false + tags: agentloop-frontend:latest + cache-from: type=gha + cache-to: type=gha,mode=max release: runs-on: ubuntu-latest @@ -43,7 +153,15 @@ jobs: if: startsWith(github.ref, 'refs/tags/v') steps: - uses: actions/checkout@v4 + + - name: Build release artifacts + run: | + mkdir -p dist + cp README.md dist/ + cp CHANGELOG.md dist/ + - name: Create GitHub Release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: - files: dist/* \ No newline at end of file + files: dist/* + generate_release_notes: true From ee84dd37e1408d41cbac39dc53ca375196acd000 Mon Sep 17 00:00:00 2001 From: Sushant Date: Mon, 15 Jun 2026 11:07:01 +0530 Subject: [PATCH 2/2] fix: use working-directory for backend/analytics tests to resolve import paths --- .github/workflows/ci.yml | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e42acc5..df13846 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,8 +39,9 @@ jobs: pip install ruff - name: Frontend npm install - run: npm ci + run: if (Test-Path package-lock.json) { npm ci } else { npm install } working-directory: frontend + shell: pwsh - name: Lint Python run: ruff check backend/ analytics/ @@ -55,6 +56,9 @@ jobs: test-backend: runs-on: ubuntu-latest + defaults: + run: + working-directory: backend steps: - uses: actions/checkout@v4 @@ -66,13 +70,13 @@ jobs: cache-dependency-path: backend/requirements.txt - name: Install deps - run: pip install -r backend/requirements.txt + run: pip install -r requirements.txt - name: Run tests run: | - pytest backend/tests/ \ - --cov=backend/app \ - --cov-report=xml \ + pytest tests/ \ + --cov=app \ + --cov-report=xml:../coverage.xml \ --cov-report=term-missing \ -v @@ -82,8 +86,17 @@ jobs: name: coverage-backend path: coverage.xml + - name: Upload coverage + uses: actions/upload-artifact@v4 + with: + name: coverage-backend + path: coverage.xml + test-analytics: runs-on: ubuntu-latest + defaults: + run: + working-directory: analytics steps: - uses: actions/checkout@v4 @@ -95,13 +108,13 @@ jobs: cache-dependency-path: analytics/requirements.txt - name: Install deps - run: pip install -r analytics/requirements.txt + run: pip install -r requirements.txt - name: Run tests run: | - pytest analytics/tests/ \ - --cov=analytics/app \ - --cov-report=xml \ + pytest tests/ \ + --cov=app \ + --cov-report=xml:../coverage.xml \ --cov-report=term-missing \ -v @@ -111,6 +124,12 @@ jobs: name: coverage-analytics path: coverage.xml + - name: Upload coverage + uses: actions/upload-artifact@v4 + with: + name: coverage-analytics + path: coverage.xml + build: runs-on: ubuntu-latest needs: [lint, test-backend, test-analytics] @@ -165,3 +184,4 @@ jobs: with: files: dist/* generate_release_notes: true +