2026-03-28 11:29:42 +01:00
|
|
|
name: CI
|
|
|
|
|
|
|
|
|
|
on:
|
|
|
|
|
push:
|
|
|
|
|
branches: [main]
|
|
|
|
|
pull_request:
|
|
|
|
|
branches: [main]
|
|
|
|
|
|
|
|
|
|
permissions:
|
|
|
|
|
contents: read
|
|
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
test:
|
|
|
|
|
name: Test
|
2026-05-27 15:44:48 +02:00
|
|
|
runs-on: docker
|
|
|
|
|
container:
|
|
|
|
|
image: docker.io/library/golang:1.25
|
2026-03-28 11:29:42 +01:00
|
|
|
steps:
|
2026-05-27 15:44:48 +02:00
|
|
|
- uses: actions/checkout@v4
|
2026-03-28 11:29:42 +01:00
|
|
|
|
|
|
|
|
- name: Run tests
|
|
|
|
|
run: go test -v -race -count=1 ./...
|
|
|
|
|
|
|
|
|
|
build:
|
|
|
|
|
name: Build
|
2026-05-27 15:44:48 +02:00
|
|
|
runs-on: docker
|
|
|
|
|
container:
|
|
|
|
|
image: docker.io/library/golang:1.25
|
2026-03-28 11:29:42 +01:00
|
|
|
strategy:
|
|
|
|
|
matrix:
|
|
|
|
|
goos: [linux, darwin, windows]
|
|
|
|
|
goarch: [amd64, arm64]
|
|
|
|
|
steps:
|
2026-05-27 15:44:48 +02:00
|
|
|
- uses: actions/checkout@v4
|
2026-03-28 11:29:42 +01:00
|
|
|
|
|
|
|
|
- name: Build
|
|
|
|
|
env:
|
|
|
|
|
GOOS: ${{ matrix.goos }}
|
|
|
|
|
GOARCH: ${{ matrix.goarch }}
|
|
|
|
|
run: go build -o unarr ./cmd/unarr/
|
|
|
|
|
|
|
|
|
|
lint:
|
|
|
|
|
name: Lint
|
2026-05-27 15:44:48 +02:00
|
|
|
runs-on: docker
|
|
|
|
|
container:
|
|
|
|
|
image: docker.io/library/golang:1.25
|
2026-03-28 11:29:42 +01:00
|
|
|
steps:
|
2026-05-27 15:44:48 +02:00
|
|
|
- uses: actions/checkout@v4
|
2026-03-28 11:29:42 +01:00
|
|
|
|
2026-05-27 15:44:48 +02:00
|
|
|
- name: Install golangci-lint
|
|
|
|
|
run: |
|
|
|
|
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/v2.11.4/install.sh \
|
|
|
|
|
| sh -s -- -b /usr/local/bin v2.11.4
|
2026-03-28 11:29:42 +01:00
|
|
|
|
|
|
|
|
- name: Run golangci-lint
|
2026-05-27 15:44:48 +02:00
|
|
|
run: golangci-lint run ./...
|
2026-03-28 11:29:42 +01:00
|
|
|
|
|
|
|
|
coverage:
|
|
|
|
|
name: Coverage
|
2026-05-27 15:44:48 +02:00
|
|
|
runs-on: docker
|
|
|
|
|
container:
|
|
|
|
|
image: docker.io/library/golang:1.25
|
2026-03-28 11:29:42 +01:00
|
|
|
steps:
|
2026-05-27 15:44:48 +02:00
|
|
|
- uses: actions/checkout@v4
|
2026-03-28 11:29:42 +01:00
|
|
|
|
2026-05-27 15:44:48 +02:00
|
|
|
- name: Install python3
|
|
|
|
|
run: apt-get update && apt-get install -y --no-install-recommends python3
|
2026-03-28 11:29:42 +01:00
|
|
|
|
test: add comprehensive test suite for engine, agent and cmd packages
- Refactor download.go and stream.go with downloadDeps/streamDeps structs
for dependency injection, enabling unit testing without real I/O
- download_test.go: 15 tests — input validation, mock downloaders, method
selection, cobra Args, deadlock detection
- stream_test.go: input validation, noOpen flag, engine error handling
- client_test.go: context cancellation, timeout, full Sync roundtrip,
watch-progress and HTTP error unwrapping
- sync_test.go: TriggerSync on watching transition, adjustInterval
- torrent_test.go: TorrentDownloader lifecycle without network
- stream_server_test.go: HTTP server lifecycle, SetFile/ClearFile,
concurrent requests, Shutdown releases port, content-type
- manager_integration_test.go: full pipeline — success, torrent→debrid
fallback, all-fail, multi-concurrent, ForceStart, OnTaskDone,
recent-finished drain, cancel mid-download, organize
- usenet_test.go: Cancel/Pause race regression test (run with -race)
- daemon_test.go: isAllowedStreamPath table tests
- CI: split coverage gate to engine+agent only (50% threshold); cmd
coverage still reported but not gated (interactive UI commands)
- lefthook: add pre-push hook with go test -race -count=1 -timeout=120s
2026-04-08 23:36:00 +02:00
|
|
|
- name: Run tests with coverage (all packages)
|
|
|
|
|
run: |
|
|
|
|
|
go test -race -coverprofile=coverage.out -covermode=atomic \
|
|
|
|
|
./internal/engine/... \
|
|
|
|
|
./internal/agent/... \
|
|
|
|
|
./internal/cmd/...
|
|
|
|
|
|
|
|
|
|
- name: Check coverage threshold (engine + agent)
|
|
|
|
|
run: |
|
|
|
|
|
# Threshold applies only to engine and agent — cmd contains interactive UI
|
|
|
|
|
# commands (config menus, daemon, auth browser) that are not unit-testable.
|
|
|
|
|
go test -race -coverprofile=coverage-core.out -covermode=atomic \
|
|
|
|
|
./internal/engine/... \
|
|
|
|
|
./internal/agent/...
|
2026-05-26 18:04:35 +02:00
|
|
|
COVERAGE=$(go tool cover -func=coverage-core.out | grep ^total | awk '{print $3}' | tr -d '%')
|
|
|
|
|
echo "Coverage on engine+agent: ${COVERAGE}%"
|
test: add comprehensive test suite for engine, agent and cmd packages
- Refactor download.go and stream.go with downloadDeps/streamDeps structs
for dependency injection, enabling unit testing without real I/O
- download_test.go: 15 tests — input validation, mock downloaders, method
selection, cobra Args, deadlock detection
- stream_test.go: input validation, noOpen flag, engine error handling
- client_test.go: context cancellation, timeout, full Sync roundtrip,
watch-progress and HTTP error unwrapping
- sync_test.go: TriggerSync on watching transition, adjustInterval
- torrent_test.go: TorrentDownloader lifecycle without network
- stream_server_test.go: HTTP server lifecycle, SetFile/ClearFile,
concurrent requests, Shutdown releases port, content-type
- manager_integration_test.go: full pipeline — success, torrent→debrid
fallback, all-fail, multi-concurrent, ForceStart, OnTaskDone,
recent-finished drain, cancel mid-download, organize
- usenet_test.go: Cancel/Pause race regression test (run with -race)
- daemon_test.go: isAllowedStreamPath table tests
- CI: split coverage gate to engine+agent only (50% threshold); cmd
coverage still reported but not gated (interactive UI commands)
- lefthook: add pre-push hook with go test -race -count=1 -timeout=120s
2026-04-08 23:36:00 +02:00
|
|
|
python3 -c "
|
|
|
|
|
coverage = float('${COVERAGE}')
|
|
|
|
|
threshold = 50.0
|
|
|
|
|
print(f'Coverage: {coverage:.1f}% (threshold: {threshold}%)')
|
|
|
|
|
if coverage < threshold:
|
|
|
|
|
print(f'ERROR: Coverage {coverage:.1f}% is below minimum {threshold}%')
|
|
|
|
|
exit(1)
|
|
|
|
|
else:
|
|
|
|
|
print('OK: Coverage meets minimum threshold')
|
|
|
|
|
"
|
2026-03-28 11:29:42 +01:00
|
|
|
|
|
|
|
|
vet:
|
|
|
|
|
name: Vet
|
2026-05-27 15:44:48 +02:00
|
|
|
runs-on: docker
|
|
|
|
|
container:
|
|
|
|
|
image: docker.io/library/golang:1.25
|
2026-03-28 11:29:42 +01:00
|
|
|
steps:
|
2026-05-27 15:44:48 +02:00
|
|
|
- uses: actions/checkout@v4
|
2026-03-28 11:29:42 +01:00
|
|
|
|
|
|
|
|
- name: Run go vet
|
|
|
|
|
run: go vet ./...
|