mirror of
https://github.com/hhftechnology/vps-monitor.git
synced 2026-04-28 03:29:55 +00:00
131 lines
3.1 KiB
YAML
131 lines
3.1 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main, dev]
|
|
pull_request:
|
|
branches: [main, dev]
|
|
|
|
jobs:
|
|
backend:
|
|
name: Backend (Go)
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: ./home
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: "home/go.mod"
|
|
|
|
- name: Create placeholder static files
|
|
run: |
|
|
mkdir -p internal/static/dist
|
|
touch internal/static/dist/index.html
|
|
|
|
- name: Lint
|
|
uses: golangci/golangci-lint-action@v6
|
|
with:
|
|
version: latest
|
|
working-directory: home
|
|
|
|
- name: Test
|
|
run: go test -v ./...
|
|
|
|
- name: Build
|
|
run: go build -v ./...
|
|
|
|
integration:
|
|
name: Integration Test
|
|
runs-on: ubuntu-latest
|
|
needs: [backend]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Create .env file
|
|
run: |
|
|
cp env.example .env
|
|
# Clear auth variables to disable authentication
|
|
sed -i 's/^JWT_SECRET=.*//' .env
|
|
sed -i 's/^ADMIN_USERNAME=.*//' .env
|
|
sed -i 's/^ADMIN_PASSWORD=.*//' .env
|
|
|
|
- name: Start Test Container
|
|
run: docker run -d --name test-vps-monitor-container alpine sleep 300
|
|
|
|
- name: Build and Start VPS-Monitor
|
|
run: docker compose up -d --build
|
|
|
|
- name: Wait for Server
|
|
run: |
|
|
for i in {1..60}; do
|
|
if curl -s http://localhost:8123/api/v1/containers > /dev/null; then
|
|
echo "Server is up!"
|
|
exit 0
|
|
fi
|
|
echo "Waiting for server..."
|
|
sleep 1
|
|
done
|
|
echo "Server failed to start"
|
|
docker compose logs
|
|
exit 1
|
|
|
|
- name: Test API
|
|
run: |
|
|
RESPONSE=$(curl -s http://localhost:8123/api/v1/containers)
|
|
echo "Response: $RESPONSE"
|
|
if echo "$RESPONSE" | grep -q "test-vps-monitor-container"; then
|
|
echo "Found test container in response!"
|
|
else
|
|
echo "Test container not found in response"
|
|
docker compose logs
|
|
exit 1
|
|
fi
|
|
|
|
- name: Cleanup
|
|
if: always()
|
|
run: |
|
|
docker compose down
|
|
docker rm -f test-vps-monitor-container || true
|
|
|
|
frontend:
|
|
name: Frontend (React)
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: ./frontend
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: oven-sh/setup-bun@v1
|
|
|
|
- name: Install dependencies
|
|
run: bun install --frozen-lockfile
|
|
|
|
- name: Lint (Biome)
|
|
run: bun x biome lint .
|
|
|
|
- name: Type Check
|
|
run: bun x tsc --noEmit
|
|
|
|
- name: Build
|
|
run: bun run build
|
|
|
|
docs:
|
|
name: Docs (Next.js)
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: ./docs
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: oven-sh/setup-bun@v1
|
|
|
|
- name: Install dependencies
|
|
run: bun install --frozen-lockfile
|
|
|
|
- name: Lint (Biome)
|
|
run: bun run lint
|
|
|
|
- name: Build
|
|
run: bun run build
|