Update README.md #48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| # CI pipeline for Mirror video streaming platform | |
| # Includes SRT library dependency handling for CGO builds | |
| # Current limitation: Only builds for linux/amd64 due to CGO cross-compilation complexity | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main ] | |
| env: | |
| GO_VERSION: '1.23' | |
| SRT_VERSION: 'v1.5.4' | |
| FFMPEG_VERSION: '7.1' | |
| jobs: | |
| # lint: | |
| # name: Lint | |
| # 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 }} | |
| # - name: Cache Go modules | |
| # uses: actions/cache@v3 | |
| # with: | |
| # path: ~/go/pkg/mod | |
| # key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
| # restore-keys: | | |
| # ${{ runner.os }}-go- | |
| # - name: Install golangci-lint | |
| # run: | | |
| # curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2 | |
| # - name: Run golangci-lint | |
| # run: golangci-lint run ./... | |
| # - name: Run go fmt | |
| # run: | | |
| # if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then | |
| # echo "Code is not formatted. Run 'make fmt'" | |
| # gofmt -s -d . | |
| # exit 1 | |
| # fi | |
| # - name: Run go vet | |
| # run: go vet ./... | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| services: | |
| redis: | |
| image: redis:7-alpine | |
| ports: | |
| - 6379:6379 | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| - name: Cache Go modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go- | |
| - name: Install SRT and FFmpeg dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| build-essential \ | |
| cmake \ | |
| pkg-config \ | |
| libssl-dev \ | |
| libtclap-dev \ | |
| ffmpeg \ | |
| libavcodec-dev \ | |
| libavformat-dev \ | |
| libavutil-dev \ | |
| libswscale-dev \ | |
| libavfilter-dev \ | |
| libavdevice-dev \ | |
| libswresample-dev | |
| # Build and install SRT from source (latest stable) | |
| git clone https://github.com/Haivision/srt.git /tmp/srt | |
| cd /tmp/srt | |
| git checkout ${{ env.SRT_VERSION }} | |
| mkdir build && cd build | |
| cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release | |
| make -j$(nproc) | |
| sudo make install | |
| sudo ldconfig | |
| - name: Verify SRT and FFmpeg installation | |
| run: | | |
| # Ensure library paths are configured | |
| sudo ldconfig | |
| pkg-config --modversion srt || echo "SRT version check failed, but continuing..." | |
| echo "FFmpeg version:" | |
| ffmpeg -version | head -3 | |
| echo "FFmpeg libraries:" | |
| pkg-config --modversion libavcodec libavformat libavutil libswscale | |
| - name: Generate test certificates | |
| run: make generate-certs | |
| - name: Set SRT environment variables | |
| run: | | |
| echo "CGO_CFLAGS=$(pkg-config --cflags srt)" >> $GITHUB_ENV | |
| echo "CGO_LDFLAGS=$(pkg-config --libs srt)" >> $GITHUB_ENV | |
| - name: Run tests | |
| env: | |
| MIRROR_REDIS_ADDRESSES: localhost:6379 | |
| CGO_ENABLED: 1 | |
| PKG_CONFIG_PATH: /usr/local/lib/pkgconfig | |
| run: go test -v -race -short -coverprofile=coverage.out ./... | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| needs: [test] | |
| strategy: | |
| matrix: | |
| # CGO cross-compilation is complex, focusing on linux/amd64 for now | |
| # TODO: Add proper cross-compilation support for CGO dependencies | |
| os: [linux] | |
| arch: [amd64] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| - name: Cache Go modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go- | |
| - name: Install SRT and FFmpeg dependencies for build | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| build-essential \ | |
| cmake \ | |
| pkg-config \ | |
| libssl-dev \ | |
| libtclap-dev \ | |
| ffmpeg \ | |
| libavcodec-dev \ | |
| libavformat-dev \ | |
| libavutil-dev \ | |
| libswscale-dev \ | |
| libavfilter-dev \ | |
| libavdevice-dev \ | |
| libswresample-dev | |
| # Build and install SRT from source (latest stable) | |
| git clone https://github.com/Haivision/srt.git /tmp/srt | |
| cd /tmp/srt | |
| git checkout ${{ env.SRT_VERSION }} | |
| mkdir build && cd build | |
| cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release | |
| make -j$(nproc) | |
| sudo make install | |
| sudo ldconfig | |
| - name: Verify SRT and FFmpeg installation (build) | |
| run: | | |
| # Ensure library paths are configured | |
| sudo ldconfig | |
| pkg-config --modversion srt || echo "SRT version check failed, but continuing..." | |
| echo "FFmpeg version:" | |
| ffmpeg -version | head -3 | |
| echo "FFmpeg libraries:" | |
| pkg-config --modversion libavcodec libavformat libavutil libswscale | |
| - name: Set SRT environment variables (build) | |
| run: | | |
| echo "CGO_CFLAGS=$(pkg-config --cflags srt)" >> $GITHUB_ENV | |
| echo "CGO_LDFLAGS=$(pkg-config --libs srt)" >> $GITHUB_ENV | |
| - name: Build binary | |
| env: | |
| GOOS: ${{ matrix.os }} | |
| GOARCH: ${{ matrix.arch }} | |
| CGO_ENABLED: 1 | |
| PKG_CONFIG_PATH: /usr/local/lib/pkgconfig | |
| run: | | |
| output_name="mirror-${{ matrix.os }}-${{ matrix.arch }}" | |
| go build -ldflags "-X github.com/zsiec/mirror/pkg/version.Version=${GITHUB_SHA::7}" -o "bin/${output_name}" ./cmd/mirror | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: mirror-${{ matrix.os }}-${{ matrix.arch }} | |
| path: bin/mirror-* | |
| # security: | |
| # name: Security Scan | |
| # runs-on: ubuntu-latest | |
| # needs: [build] | |
| # steps: | |
| # - name: Checkout code | |
| # uses: actions/checkout@v4 | |
| # - name: Run Trivy vulnerability scanner | |
| # uses: aquasecurity/trivy-action@master | |
| # with: | |
| # scan-type: 'fs' | |
| # scan-ref: '.' | |
| # format: 'sarif' | |
| # output: 'trivy-results.sarif' | |
| # - name: Upload Trivy scan results to GitHub Security tab | |
| # uses: github/codeql-action/upload-sarif@v3 | |
| # with: | |
| # sarif_file: 'trivy-results.sarif' |