Skip to content

Commit 65dae0a

Browse files
zsiecclaude
andcommitted
Implement Phase 1: Core foundation and project setup
- Created Go project structure with modular architecture - Implemented configuration management with Viper (YAML + env support) - Built structured logging system with rotation using logrus - Developed custom error handling framework with typed errors - Created health check system with Redis, disk, and memory monitors - Implemented HTTP/3 server using quic-go with QUIC protocol - Set up Docker environment with multi-stage builds and NVIDIA CUDA support - Created Makefile for build automation and common tasks - Generated self-signed TLS certificates for development - Implemented comprehensive test suite with 71% code coverage - Set up GitHub Actions CI/CD workflow - Added monitoring support with Prometheus metrics - Created test client for HTTP/3 endpoint verification All Phase 1 requirements completed and tested. The foundation is ready for Phase 2 stream ingestion implementation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 0699dcd commit 65dae0a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+16133
-8745
lines changed

.air.toml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
root = "."
2+
testdata_dir = "testdata"
3+
tmp_dir = "tmp"
4+
5+
[build]
6+
args_bin = ["-config", "configs/development.yaml"]
7+
bin = "./tmp/main"
8+
cmd = "go build -o ./tmp/main ./cmd/mirror"
9+
delay = 1000
10+
exclude_dir = ["assets", "tmp", "vendor", "testdata", "docker", "certs", "logs"]
11+
exclude_file = []
12+
exclude_regex = ["_test.go"]
13+
exclude_unchanged = false
14+
follow_symlink = false
15+
full_bin = ""
16+
include_dir = []
17+
include_ext = ["go", "tpl", "tmpl", "html"]
18+
include_file = []
19+
kill_delay = "0s"
20+
log = "build-errors.log"
21+
poll = false
22+
poll_interval = 0
23+
post_cmd = []
24+
pre_cmd = []
25+
rerun = false
26+
rerun_delay = 500
27+
send_interrupt = false
28+
stop_on_error = false
29+
30+
[color]
31+
app = ""
32+
build = "yellow"
33+
main = "magenta"
34+
runner = "green"
35+
watcher = "cyan"
36+
37+
[log]
38+
main_only = false
39+
time = false
40+
41+
[misc]
42+
clean_on_exit = false
43+
44+
[screen]
45+
clear_on_rebuild = false
46+
keep_scroll = true

.env.example

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Mirror Environment Variables Example
2+
# Copy this file to .env and update with your values
3+
4+
# Server Configuration
5+
MIRROR_SERVER_HTTP3_PORT=8443
6+
MIRROR_SERVER_TLS_CERT_FILE=./certs/cert.pem
7+
MIRROR_SERVER_TLS_KEY_FILE=./certs/key.pem
8+
9+
# Redis Configuration
10+
MIRROR_REDIS_ADDRESSES=localhost:6379
11+
MIRROR_REDIS_PASSWORD=
12+
MIRROR_REDIS_DB=0
13+
14+
# Logging Configuration
15+
MIRROR_LOGGING_LEVEL=info
16+
MIRROR_LOGGING_FORMAT=json
17+
MIRROR_LOGGING_OUTPUT=stdout
18+
19+
# Metrics Configuration
20+
MIRROR_METRICS_ENABLED=true
21+
MIRROR_METRICS_PORT=9090
22+
23+
# AWS Configuration (for future phases)
24+
# AWS_REGION=us-east-1
25+
# AWS_ACCESS_KEY_ID=
26+
# AWS_SECRET_ACCESS_KEY=
27+
28+
# S3 Configuration (for future phases)
29+
# S3_BUCKET_NAME=mirror-streams
30+
# S3_ENDPOINT=
31+
32+
# Stream Configuration (for future phases)
33+
# STREAM_MAX_BITRATE=50000000
34+
# STREAM_BUFFER_SIZE=4194304
35+
# STREAM_MAX_CONCURRENT=25

.github/workflows/ci.yml

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
GO_VERSION: '1.23'
11+
12+
jobs:
13+
lint:
14+
name: Lint
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version: ${{ env.GO_VERSION }}
24+
25+
- name: Cache Go modules
26+
uses: actions/cache@v3
27+
with:
28+
path: ~/go/pkg/mod
29+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
30+
restore-keys: |
31+
${{ runner.os }}-go-
32+
33+
- name: Install golangci-lint
34+
run: |
35+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2
36+
37+
- name: Run golangci-lint
38+
run: golangci-lint run ./...
39+
40+
- name: Run go fmt
41+
run: |
42+
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
43+
echo "Code is not formatted. Run 'make fmt'"
44+
gofmt -s -d .
45+
exit 1
46+
fi
47+
48+
- name: Run go vet
49+
run: go vet ./...
50+
51+
test:
52+
name: Test
53+
runs-on: ubuntu-latest
54+
services:
55+
redis:
56+
image: redis:7-alpine
57+
ports:
58+
- 6379:6379
59+
options: >-
60+
--health-cmd "redis-cli ping"
61+
--health-interval 10s
62+
--health-timeout 5s
63+
--health-retries 5
64+
65+
steps:
66+
- name: Checkout code
67+
uses: actions/checkout@v4
68+
69+
- name: Set up Go
70+
uses: actions/setup-go@v5
71+
with:
72+
go-version: ${{ env.GO_VERSION }}
73+
74+
- name: Cache Go modules
75+
uses: actions/cache@v3
76+
with:
77+
path: ~/go/pkg/mod
78+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
79+
restore-keys: |
80+
${{ runner.os }}-go-
81+
82+
- name: Generate test certificates
83+
run: make generate-certs
84+
85+
- name: Run tests
86+
env:
87+
MIRROR_REDIS_ADDRESSES: localhost:6379
88+
run: go test -v -race -coverprofile=coverage.out ./...
89+
90+
- name: Upload coverage to Codecov
91+
uses: codecov/codecov-action@v3
92+
with:
93+
file: ./coverage.out
94+
flags: unittests
95+
name: codecov-umbrella
96+
97+
build:
98+
name: Build
99+
runs-on: ubuntu-latest
100+
needs: [lint, test]
101+
strategy:
102+
matrix:
103+
os: [linux, darwin, windows]
104+
arch: [amd64, arm64]
105+
exclude:
106+
- os: windows
107+
arch: arm64
108+
109+
steps:
110+
- name: Checkout code
111+
uses: actions/checkout@v4
112+
113+
- name: Set up Go
114+
uses: actions/setup-go@v5
115+
with:
116+
go-version: ${{ env.GO_VERSION }}
117+
118+
- name: Cache Go modules
119+
uses: actions/cache@v3
120+
with:
121+
path: ~/go/pkg/mod
122+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
123+
restore-keys: |
124+
${{ runner.os }}-go-
125+
126+
- name: Build binary
127+
env:
128+
GOOS: ${{ matrix.os }}
129+
GOARCH: ${{ matrix.arch }}
130+
run: |
131+
output_name="mirror-${{ matrix.os }}-${{ matrix.arch }}"
132+
if [ "${{ matrix.os }}" = "windows" ]; then
133+
output_name="${output_name}.exe"
134+
fi
135+
go build -ldflags "-X github.com/zsiec/mirror/pkg/version.Version=${GITHUB_SHA::7}" -o "bin/${output_name}" ./cmd/mirror
136+
137+
- name: Upload artifacts
138+
uses: actions/upload-artifact@v3
139+
with:
140+
name: mirror-${{ matrix.os }}-${{ matrix.arch }}
141+
path: bin/mirror-*
142+
143+
docker:
144+
name: Docker Build
145+
runs-on: ubuntu-latest
146+
needs: [lint, test]
147+
if: github.event_name == 'push'
148+
149+
steps:
150+
- name: Checkout code
151+
uses: actions/checkout@v4
152+
153+
- name: Set up Docker Buildx
154+
uses: docker/setup-buildx-action@v3
155+
156+
- name: Login to GitHub Container Registry
157+
uses: docker/login-action@v3
158+
with:
159+
registry: ghcr.io
160+
username: ${{ github.actor }}
161+
password: ${{ secrets.GITHUB_TOKEN }}
162+
163+
- name: Build and push Docker image
164+
uses: docker/build-push-action@v5
165+
with:
166+
context: .
167+
file: ./docker/Dockerfile
168+
platforms: linux/amd64,linux/arm64
169+
push: true
170+
tags: |
171+
ghcr.io/${{ github.repository }}:latest
172+
ghcr.io/${{ github.repository }}:${{ github.sha }}
173+
cache-from: type=gha
174+
cache-to: type=gha,mode=max
175+
176+
security:
177+
name: Security Scan
178+
runs-on: ubuntu-latest
179+
needs: [build]
180+
181+
steps:
182+
- name: Checkout code
183+
uses: actions/checkout@v4
184+
185+
- name: Run Trivy vulnerability scanner
186+
uses: aquasecurity/trivy-action@master
187+
with:
188+
scan-type: 'fs'
189+
scan-ref: '.'
190+
format: 'sarif'
191+
output: 'trivy-results.sarif'
192+
193+
- name: Upload Trivy scan results to GitHub Security tab
194+
uses: github/codeql-action/upload-sarif@v2
195+
with:
196+
sarif_file: 'trivy-results.sarif'

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ generated/
100100
*.pprof
101101

102102
# Binary outputs
103-
mirror
104103
mirror-ingestion
105104
mirror-transcoder
106105
mirror-packager

0 commit comments

Comments
 (0)