Skip to content

Commit 18267dd

Browse files
authored
Support basic auth and presigns (#5)
* feat: wip - support for multipart * feat: support for s3 + minio presigned url and tests. writeup for future enhancements * feat: gha for tests * feat: add livvips support to gha
1 parent adc2e16 commit 18267dd

File tree

24 files changed

+2716
-16
lines changed

24 files changed

+2716
-16
lines changed

.github/workflows/test.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
test:
11+
name: Run Tests
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
go-version: [1.21, 1.22]
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Install libvips
23+
run: |
24+
sudo apt-get update
25+
sudo apt-get install -y libvips-dev
26+
27+
- name: Set up Go
28+
uses: actions/setup-go@v4
29+
with:
30+
go-version: ${{ matrix.go-version }}
31+
32+
- name: Cache Go modules
33+
uses: actions/cache@v4
34+
with:
35+
path: |
36+
~/go/pkg/mod
37+
~/.cache/go-build
38+
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
39+
restore-keys: |
40+
${{ runner.os }}-go-${{ matrix.go-version }}-
41+
42+
- name: Download dependencies
43+
run: go mod download
44+
45+
- name: Verify dependencies
46+
run: go mod verify
47+
48+
- name: Run tests
49+
run: make test
50+
51+
- name: Run tests with coverage
52+
run: make test-coverage
53+
54+
- name: Upload coverage reports to Codecov
55+
uses: codecov/codecov-action@v4
56+
with:
57+
file: ./coverage.out
58+
flags: unittests
59+
name: codecov-umbrella
60+
fail_ci_if_error: false
61+
62+
lint:
63+
name: Lint
64+
runs-on: ubuntu-latest
65+
66+
steps:
67+
- name: Checkout code
68+
uses: actions/checkout@v4
69+
70+
- name: Install libvips
71+
run: |
72+
sudo apt-get update
73+
sudo apt-get install -y libvips-dev
74+
75+
- name: Set up Go
76+
uses: actions/setup-go@v4
77+
with:
78+
go-version: 1.22
79+
80+
- name: golangci-lint
81+
uses: golangci/golangci-lint-action@v3
82+
with:
83+
version: latest
84+
args: --timeout=5m
85+
86+
build:
87+
name: Build
88+
runs-on: ubuntu-latest
89+
needs: [test, lint]
90+
91+
steps:
92+
- name: Checkout code
93+
uses: actions/checkout@v4
94+
95+
- name: Install libvips
96+
run: |
97+
sudo apt-get update
98+
sudo apt-get install -y libvips-dev
99+
100+
- name: Set up Go
101+
uses: actions/setup-go@v4
102+
with:
103+
go-version: 1.22
104+
105+
- name: Build application
106+
run: make build
107+
108+
- name: Upload build artifact
109+
uses: actions/upload-artifact@v4
110+
with:
111+
name: mediaflow-binary
112+
path: mediaflow
113+
retention-days: 7

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ go.work.sum
3232
# .vscode/
3333

3434
tmp/*
35-
mediaflow
35+
mediaflow.env.local

Makefile

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,24 @@ run-image:
5959
@echo "Running image 🚀"
6060
@set -a && . ./.env && docker run -p 8080:8080 --replace -n mediaflow-server --rm $(IMAGE_FULL_NAME)
6161

62+
test:
63+
@echo "Running tests 🧪"
64+
@go test -v ./internal/...
65+
66+
test-coverage:
67+
@echo "Running tests with coverage 📊"
68+
@go test -v -coverprofile=coverage.out ./internal/...
69+
@go tool cover -html=coverage.out -o coverage.html
70+
@echo "Coverage report generated: coverage.html"
71+
72+
test-upload:
73+
@echo "Running upload module tests 🔄"
74+
@go test -v ./internal/upload
75+
76+
test-auth:
77+
@echo "Running auth module tests 🔐"
78+
@go test -v ./internal/auth
79+
6280
clean:
6381
@echo "Cleaning up 🧹"
64-
@rm -f mediaflow
82+
@rm -f mediaflow coverage.out coverage.html

examples/storage-config.yaml

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,63 @@ storage_options:
2929
sizes: ["256", "512"]
3030
default_size: "256"
3131
quality: 90
32-
convert_to: "webp"
32+
convert_to: "webp"
33+
34+
35+
upload_options:
36+
avatar:
37+
kind: "image"
38+
allowed_mimes: ["image/jpeg", "image/png", "image/webp"]
39+
size_max_bytes: 5242880 # 5MB
40+
multipart_threshold_mb: 15
41+
part_size_mb: 8
42+
token_ttl_seconds: 900 # 15 minutes
43+
path_template: "raw/{shard?}/{key_base}.{ext}"
44+
enable_sharding: true
45+
46+
photo:
47+
kind: "image"
48+
allowed_mimes: ["image/jpeg", "image/png", "image/webp"]
49+
size_max_bytes: 20971520 # 20MB
50+
multipart_threshold_mb: 15
51+
part_size_mb: 8
52+
token_ttl_seconds: 900
53+
path_template: "raw/{shard?}/{key_base}.{ext}"
54+
enable_sharding: true
55+
56+
video:
57+
kind: "video"
58+
allowed_mimes: ["video/mp4", "video/quicktime", "video/webm"]
59+
size_max_bytes: 104857600 # 100MB
60+
multipart_threshold_mb: 15
61+
part_size_mb: 8
62+
token_ttl_seconds: 1800 # 30 minutes
63+
path_template: "raw/{shard?}/{key_base}.{ext}"
64+
enable_sharding: true
65+
66+
default:
67+
kind: "image"
68+
allowed_mimes: ["image/jpeg", "image/png"]
69+
size_max_bytes: 10485760 # 10MB
70+
multipart_threshold_mb: 15
71+
part_size_mb: 8
72+
token_ttl_seconds: 900
73+
path_template: "raw/{shard?}/{key_base}.{ext}"
74+
enable_sharding: true
75+
76+
videos:
77+
product:
78+
origin_folder: "originals/videos/products"
79+
constraints:
80+
max_fps: 30
81+
max_size_mb: 500
82+
proxy:
83+
enabled: true
84+
folder: "proxies/videos/products"
85+
height: 240
86+
preview_seconds: 4
87+
posters:
88+
folder: "posters/videos"
89+
time_percent: 10
90+
format: "jpg"
91+
quality: 90

0 commit comments

Comments
 (0)