Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
209 changes: 209 additions & 0 deletions .github/workflows/mcp-server-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
name: MCP Server CI/CD

on:
push:
branches:
- main
- master
- develop
paths:
- 'packages/mcp-server/**'
- '.github/workflows/mcp-server-ci.yml'
pull_request:
paths:
- 'packages/mcp-server/**'
- '.github/workflows/mcp-server-ci.yml'
release:
types: [published]

env:
REGISTRY: docker.io
IMAGE_NAME: coorchat/mcp-server
NODE_VERSION: '18'

jobs:
lint-and-test:
name: Lint & Test
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/mcp-server

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: packages/mcp-server/package-lock.json

- name: Install dependencies
run: npm ci

- name: Run linter
run: npm run lint

- name: Run type check
run: npx tsc --noEmit

- name: Run unit tests
run: npm test -- --coverage

- name: Upload coverage reports
uses: codecov/codecov-action@v4
with:
files: ./packages/mcp-server/coverage/lcov.info
flags: mcp-server
name: mcp-server-coverage
fail_ci_if_error: false

build:
name: Build TypeScript
runs-on: ubuntu-latest
needs: lint-and-test
defaults:
run:
working-directory: packages/mcp-server

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: packages/mcp-server/package-lock.json

- name: Install dependencies
run: npm ci

- name: Build project
run: npm run build

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: mcp-server-dist
path: packages/mcp-server/dist
retention-days: 7

integration-test:
name: Integration Tests
runs-on: ubuntu-latest
needs: build
defaults:
run:
working-directory: packages/mcp-server

services:
redis:
image: redis:7-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: packages/mcp-server/package-lock.json

- name: Install dependencies
run: npm ci

- name: Run integration tests
run: npm run test:integration
env:
REDIS_URL: redis://localhost:6379
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docker-build:
name: Build Docker Image
runs-on: ubuntu-latest
needs: [lint-and-test, build]
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./packages/mcp-server
file: ./packages/mcp-server/Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

publish-npm:
name: Publish to npm
runs-on: ubuntu-latest
needs: [integration-test, docker-build]
if: github.event_name == 'release'
defaults:
run:
working-directory: packages/mcp-server

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm ci

- name: Build project
run: npm run build

- name: Publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
186 changes: 186 additions & 0 deletions .github/workflows/relay-server-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
name: Relay Server CI/CD

on:
push:
branches:
- main
- master
- develop
paths:
- 'packages/relay-server/**'
- '.github/workflows/relay-server-ci.yml'
pull_request:
paths:
- 'packages/relay-server/**'
- '.github/workflows/relay-server-ci.yml'
release:
types: [published]

env:
REGISTRY: docker.io
IMAGE_NAME: coorchat/relay-server
DOTNET_VERSION: '8.0'

jobs:
build-and-test:
name: Build & Test
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/relay-server

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Restore dependencies
run: dotnet restore

- name: Build solution
run: dotnet build --no-restore --configuration Release

- name: Run unit tests
run: dotnet test tests/CoorChat.RelayServer.Tests.Unit/CoorChat.RelayServer.Tests.Unit.csproj --no-build --configuration Release --logger trx --collect:"XPlat Code Coverage"

- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: packages/relay-server/**/*.trx
retention-days: 7

- name: Upload coverage reports
uses: codecov/codecov-action@v4
with:
files: ./packages/relay-server/**/coverage.cobertura.xml
flags: relay-server
name: relay-server-coverage
fail_ci_if_error: false

integration-test:
name: Integration Tests
runs-on: ubuntu-latest
needs: build-and-test
defaults:
run:
working-directory: packages/relay-server

services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: coorchat
POSTGRES_PASSWORD: test_password
POSTGRES_DB: coorchat_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Restore dependencies
run: dotnet restore

- name: Build solution
run: dotnet build --no-restore --configuration Release

- name: Run integration tests
run: dotnet test tests/CoorChat.RelayServer.Tests.Integration/CoorChat.RelayServer.Tests.Integration.csproj --no-build --configuration Release --logger trx
env:
ConnectionStrings__DefaultConnection: "Host=localhost;Port=5432;Database=coorchat_test;Username=coorchat;Password=test_password"

docker-build:
name: Build Docker Image
runs-on: ubuntu-latest
needs: [build-and-test, integration-test]
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./packages/relay-server
file: ./packages/relay-server/Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

publish-nuget:
name: Publish to NuGet
runs-on: ubuntu-latest
needs: [integration-test, docker-build]
if: github.event_name == 'release'
defaults:
run:
working-directory: packages/relay-server

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Restore dependencies
run: dotnet restore

- name: Build solution
run: dotnet build --no-restore --configuration Release

- name: Pack NuGet packages
run: |
dotnet pack src/CoorChat.RelayServer.Core/CoorChat.RelayServer.Core.csproj --no-build --configuration Release --output ./nupkgs
dotnet pack src/CoorChat.RelayServer.Data/CoorChat.RelayServer.Data.csproj --no-build --configuration Release --output ./nupkgs

- name: Publish to NuGet
run: dotnet nuget push "./nupkgs/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
Loading
Loading