Skip to content

Merge pull request #21 from rwilliamspbg-ops/fix/devcontainer-gui-ful… #30

Merge pull request #21 from rwilliamspbg-ops/fix/devcontainer-gui-ful…

Merge pull request #21 from rwilliamspbg-ops/fix/devcontainer-gui-ful… #30

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
permissions:
contents: read
packages: write
env:
CARGO_TERM_COLOR: always
RUST_VERSION: 1.87
CARGO_BUILD_JOBS: 1
jobs:
# Build and test Rust server
build-server:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.RUST_VERSION }}
components: rustfmt, clippy
- name: Cache Cargo dependencies
uses: swatinem/rust-cache@v2
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake clang libssl-dev pkg-config
- name: Build server
working-directory: ./mohawk-server
run: cargo build --release --verbose
- name: Run tests
working-directory: ./mohawk-server
run: cargo test --verbose
- name: Check formatting
working-directory: ./mohawk-server
run: cargo fmt -- --check
- name: Run clippy lints
working-directory: ./mohawk-server
run: cargo clippy -- -D warnings
# Build and test GUI
build-gui:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
working-directory: ./gui
run: npm install
- name: Build GUI
working-directory: ./gui
run: npm run build
- name: Run type check
working-directory: ./gui
run: npx tsc --noEmit
# Build Docker images
build-docker:
runs-on: ubuntu-latest
needs: [build-server, build-gui]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Normalize image repository path
run: echo "IMAGE_REPO=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
- name: Build and push CPU image
uses: docker/build-push-action@v5
with:
context: ./mohawk-server
file: ./mohawk-server/Dockerfile
push: true
tags: |
${{ env.IMAGE_REPO }}/mohawk-server:latest
${{ env.IMAGE_REPO }}/mohawk-server:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push CUDA image
uses: docker/build-push-action@v5
with:
context: ./mohawk-server
file: ./mohawk-server/Dockerfile.cuda
push: true
tags: |
${{ env.IMAGE_REPO }}/mohawk-server-cuda:latest
${{ env.IMAGE_REPO }}/mohawk-server-cuda:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
# Integration tests
integration-tests:
runs-on: ubuntu-latest
needs: build-server
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.RUST_VERSION }}
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake clang libssl-dev pkg-config
- name: Build server
working-directory: ./mohawk-server
run: cargo build --release
- name: Start server
working-directory: ./mohawk-server
run: |
cargo run --release &
sleep 10
- name: Run integration tests
working-directory: ./mohawk-server
run: |
python test_server.py || echo "Tests completed"
# Deploy to staging
deploy-staging:
runs-on: ubuntu-latest
needs: [build-docker, integration-tests]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
environment: staging
steps:
- uses: actions/checkout@v4
- name: Deploy to staging
run: |
echo "Deploying to staging environment..."
# Add your deployment commands here (kubectl, docker-compose, etc.)