-
Notifications
You must be signed in to change notification settings - Fork 0
172 lines (137 loc) · 4.23 KB
/
Copy pathci-cd.yml
File metadata and controls
172 lines (137 loc) · 4.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
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.)