|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +env: |
| 10 | + DOCKER_REGISTRY: ghcr.io |
| 11 | + IMAGE_NAME: ghcr.io/codealive-ai/codealive-mcp |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + packages: write |
| 16 | + |
| 17 | +jobs: |
| 18 | + test: |
| 19 | + name: Test |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - uses: actions/setup-python@v5 |
| 25 | + with: |
| 26 | + python-version: '3.11' |
| 27 | + cache: 'pip' |
| 28 | + |
| 29 | + - name: Install dependencies |
| 30 | + run: | |
| 31 | + python -m pip install --upgrade pip |
| 32 | + pip install -e . |
| 33 | + pip install pytest pytest-asyncio pytest-mock pytest-cov jsonschema |
| 34 | +
|
| 35 | + - name: Run tests |
| 36 | + run: | |
| 37 | + python -m pytest src/tests/ -v --cov=src --cov-report=term-missing --cov-report=xml --junitxml=junit/test-results.xml |
| 38 | +
|
| 39 | + - name: Upload test results |
| 40 | + uses: actions/upload-artifact@v4 |
| 41 | + if: always() |
| 42 | + with: |
| 43 | + name: pytest-results |
| 44 | + path: | |
| 45 | + junit/test-results.xml |
| 46 | + coverage.xml |
| 47 | +
|
| 48 | + docker: |
| 49 | + name: Build & Push Docker |
| 50 | + needs: test |
| 51 | + runs-on: ubuntu-latest |
| 52 | + steps: |
| 53 | + - uses: actions/checkout@v4 |
| 54 | + |
| 55 | + - uses: docker/setup-buildx-action@v3 |
| 56 | + |
| 57 | + - name: Login to GitHub Container Registry |
| 58 | + if: github.event_name == 'push' |
| 59 | + uses: docker/login-action@v3 |
| 60 | + with: |
| 61 | + registry: ${{ env.DOCKER_REGISTRY }} |
| 62 | + username: ${{ github.actor }} |
| 63 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + |
| 65 | + # PR: build only (no push) to validate Dockerfile — single platform for speed |
| 66 | + - name: Build Docker image (PR validation) |
| 67 | + if: github.event_name == 'pull_request' |
| 68 | + uses: docker/build-push-action@v5 |
| 69 | + with: |
| 70 | + push: false |
| 71 | + load: true |
| 72 | + file: ./Dockerfile |
| 73 | + tags: ${{ env.IMAGE_NAME }}:pr-${{ github.event.number }} |
| 74 | + cache-from: type=gha |
| 75 | + |
| 76 | + # Push to main: build multi-platform and push with rolling tags |
| 77 | + - name: Build and push Docker image |
| 78 | + if: github.event_name == 'push' |
| 79 | + uses: docker/build-push-action@v5 |
| 80 | + with: |
| 81 | + push: true |
| 82 | + platforms: linux/amd64,linux/arm64 |
| 83 | + file: ./Dockerfile |
| 84 | + tags: | |
| 85 | + ${{ env.IMAGE_NAME }}:main |
| 86 | + ${{ env.IMAGE_NAME }}:latest |
| 87 | + labels: | |
| 88 | + io.modelcontextprotocol.server.name=io.github.CodeAlive-AI/codealive-mcp |
| 89 | + cache-from: type=gha |
| 90 | + cache-to: type=gha |
0 commit comments