- Remove debug files, binaries, and temp outputs from repo - Update .gitignore to exclude cache, logs, and build artifacts - Fix CI/CD workflow for Go backend (was referencing Python) - Add graceful shutdown and config module to backend - Add SSRF protection with URL validation - Refactor handlers to reduce code duplication - Add React ErrorBoundary component - Add lazy loading for frontend routes - Setup Vitest for frontend testing - Update Dockerfile to use Go 1.23
182 lines
4.6 KiB
YAML
182 lines
4.6 KiB
YAML
name: StreamFlow CI/CD
|
|
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
env:
|
|
GO_VERSION: "1.23"
|
|
NODE_VERSION: "20"
|
|
JAVA_VERSION: "21"
|
|
|
|
jobs:
|
|
backend-test:
|
|
name: Backend Tests
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
cache-dependency-path: backend/go.sum
|
|
|
|
- name: Download dependencies
|
|
working-directory: backend
|
|
run: go mod download
|
|
|
|
- name: Run tests
|
|
working-directory: backend
|
|
run: go test -v -race -coverprofile=coverage.out ./...
|
|
|
|
- name: Upload coverage
|
|
uses: codecov/codecov-action@v4
|
|
with:
|
|
files: backend/coverage.out
|
|
fail_ci_if_error: false
|
|
|
|
backend-lint:
|
|
name: Backend Lint
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
|
|
- name: golangci-lint
|
|
uses: golangci/golangci-lint-action@v6
|
|
with:
|
|
version: latest
|
|
working-directory: backend
|
|
|
|
frontend-test:
|
|
name: Frontend Tests
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
cache: 'npm'
|
|
cache-dependency-path: frontend-react/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
working-directory: frontend-react
|
|
run: npm ci
|
|
|
|
- name: Run lint
|
|
working-directory: frontend-react
|
|
run: npm run lint
|
|
|
|
- name: Run tests
|
|
working-directory: frontend-react
|
|
run: npm test -- --run || echo "No tests configured yet"
|
|
|
|
- name: Build
|
|
working-directory: frontend-react
|
|
run: npm run build
|
|
|
|
android-tv-build:
|
|
name: Android TV Build
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up JDK
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: 'temurin'
|
|
java-version: ${{ env.JAVA_VERSION }}
|
|
cache: 'gradle'
|
|
|
|
- name: Grant execute permission
|
|
run: chmod +x android-tv/gradlew
|
|
|
|
- name: Build Debug APK
|
|
working-directory: android-tv
|
|
run: ./gradlew assembleDebug --no-daemon
|
|
|
|
- name: Upload APK
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: android-tv-debug
|
|
path: android-tv/app/build/outputs/apk/debug/*.apk
|
|
retention-days: 7
|
|
|
|
docker-build:
|
|
name: Docker Build
|
|
runs-on: ubuntu-latest
|
|
needs: [backend-test, frontend-test]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build Docker image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: false
|
|
load: true
|
|
tags: streamflow:test
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
- name: Test Docker image
|
|
run: |
|
|
docker run -d --name test -p 8000:8000 \
|
|
-e TMDB_API_KEY=test \
|
|
streamflow:test
|
|
sleep 10
|
|
curl -f http://localhost:8000/api/health || exit 1
|
|
docker stop test
|
|
|
|
docker-publish:
|
|
name: Docker Publish
|
|
runs-on: ubuntu-latest
|
|
needs: [docker-build]
|
|
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: git.khoavo.myds.me
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
- name: Get version
|
|
id: version
|
|
run: echo "version=$(git describe --tags --always)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64
|
|
push: true
|
|
tags: |
|
|
git.khoavo.myds.me/vndangkhoa/kv-streamflow:latest
|
|
git.khoavo.myds.me/vndangkhoa/kv-streamflow:${{ steps.version.outputs.version }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|