Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Tests

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
test:
name: Run Tests
runs-on: ubuntu-latest

strategy:
matrix:
go-version: [1.21, 1.22]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install libvips
run: |
sudo apt-get update
sudo apt-get install -y libvips-dev

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go-version }}-

- name: Download dependencies
run: go mod download

- name: Verify dependencies
run: go mod verify

- name: Run tests
run: make test

- name: Run tests with coverage
run: make test-coverage

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.out
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false

lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install libvips
run: |
sudo apt-get update
sudo apt-get install -y libvips-dev

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.22

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout=5m

build:
name: Build
runs-on: ubuntu-latest
needs: [test, lint]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install libvips
run: |
sudo apt-get update
sudo apt-get install -y libvips-dev

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.22

- name: Build application
run: make build

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: mediaflow-binary
path: mediaflow
retention-days: 7
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ go.work.sum
# .vscode/

tmp/*
mediaflow
mediaflow.env.local
20 changes: 19 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ run-image:
@echo "Running image 🚀"
@set -a && . ./.env && docker run -p 8080:8080 --replace -n mediaflow-server --rm $(IMAGE_FULL_NAME)

test:
@echo "Running tests 🧪"
@go test -v ./internal/...

test-coverage:
@echo "Running tests with coverage 📊"
@go test -v -coverprofile=coverage.out ./internal/...
@go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"

test-upload:
@echo "Running upload module tests 🔄"
@go test -v ./internal/upload

test-auth:
@echo "Running auth module tests 🔐"
@go test -v ./internal/auth

clean:
@echo "Cleaning up 🧹"
@rm -f mediaflow
@rm -f mediaflow coverage.out coverage.html
61 changes: 60 additions & 1 deletion examples/storage-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,63 @@ storage_options:
sizes: ["256", "512"]
default_size: "256"
quality: 90
convert_to: "webp"
convert_to: "webp"


upload_options:
avatar:
kind: "image"
allowed_mimes: ["image/jpeg", "image/png", "image/webp"]
size_max_bytes: 5242880 # 5MB
multipart_threshold_mb: 15
part_size_mb: 8
token_ttl_seconds: 900 # 15 minutes
path_template: "raw/{shard?}/{key_base}.{ext}"
enable_sharding: true

photo:
kind: "image"
allowed_mimes: ["image/jpeg", "image/png", "image/webp"]
size_max_bytes: 20971520 # 20MB
multipart_threshold_mb: 15
part_size_mb: 8
token_ttl_seconds: 900
path_template: "raw/{shard?}/{key_base}.{ext}"
enable_sharding: true

video:
kind: "video"
allowed_mimes: ["video/mp4", "video/quicktime", "video/webm"]
size_max_bytes: 104857600 # 100MB
multipart_threshold_mb: 15
part_size_mb: 8
token_ttl_seconds: 1800 # 30 minutes
path_template: "raw/{shard?}/{key_base}.{ext}"
enable_sharding: true

default:
kind: "image"
allowed_mimes: ["image/jpeg", "image/png"]
size_max_bytes: 10485760 # 10MB
multipart_threshold_mb: 15
part_size_mb: 8
token_ttl_seconds: 900
path_template: "raw/{shard?}/{key_base}.{ext}"
enable_sharding: true

videos:
product:
origin_folder: "originals/videos/products"
constraints:
max_fps: 30
max_size_mb: 500
proxy:
enabled: true
folder: "proxies/videos/products"
height: 240
preview_seconds: 4
posters:
folder: "posters/videos"
time_percent: 10
format: "jpg"
quality: 90
Loading
Loading