Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add videoapi grpc server and vidit tool #2

Merged
merged 56 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
6a7ca20
add videoapi grpc server and vidit tool
adwski Apr 29, 2024
4ac0e80
add main menu screen and videos screen
adwski May 1, 2024
d5595d9
add upload parts handling
adwski May 6, 2024
f5aad52
add upload and quota screens
adwski May 7, 2024
96c03c2
add multipart video upload
adwski May 8, 2024
5a11f13
add media reader
adwski May 9, 2024
d3ac939
add playback meta to video object
adwski May 10, 2024
461c23e
fix case when sync sample time diff > segment duration
adwski May 10, 2024
d4b8306
fix media reader seek with whence 1
adwski May 10, 2024
137986a
add upload resume, video delete, keyMap help messages
adwski May 10, 2024
9ec4846
rm static css and js
adwski May 10, 2024
373be02
bring watch url back, add it to videos screen, also add more help key…
adwski May 10, 2024
8558d22
disable tests temporary
adwski May 10, 2024
a751f36
fix segmentation by determining max diff between sync points
adwski May 11, 2024
f5bedcf
use audio/mp4 ct for init segments
adwski May 11, 2024
185e9fa
rename readerTS
adwski May 11, 2024
94796a5
update gitignore
adwski May 11, 2024
f502ef1
fix lint errs
adwski May 11, 2024
4435baa
update golangci-lint job
adwski May 11, 2024
d8def34
update statictest job
adwski May 11, 2024
da5d9f4
fix some err handlings
adwski May 11, 2024
9e34ad1
update go in dockerfiles, fix upload name in state, go mod tidy
adwski May 11, 2024
7a69360
fix tests
adwski May 11, 2024
5a50d0d
add video service unit tests, add unittest wf job
adwski May 12, 2024
ae1c608
add goreleaser
adwski May 13, 2024
7db87e8
configure goreleaser for local build
adwski May 13, 2024
5253739
turn e2e tests job back on, fix userapi test
adwski May 13, 2024
c56a7a5
chore: update coverage badge
adwski May 13, 2024
cf32615
update video e2e tests
adwski May 14, 2024
102ebda
chore: update coverage badge
adwski May 14, 2024
a7eb3f1
rm test s3 pkg
adwski May 14, 2024
13a1478
chore: update coverage badge
adwski May 14, 2024
273f2af
add vidit state and init tests
adwski May 14, 2024
58e8335
chore: update coverage badge
adwski May 14, 2024
1775d18
add tea unittests for startup cases
adwski May 15, 2024
94fe54b
chore: update coverage badge
adwski May 15, 2024
c5dd359
add vidit e2e main flow test
adwski May 15, 2024
92cb369
try to fix missing tty error
adwski May 15, 2024
6a479ff
chore: update coverage badge
adwski May 15, 2024
17982de
rm unused video api http serviceside client
adwski May 15, 2024
7f1b8c3
chore: update coverage badge
adwski May 15, 2024
86027d3
add requestid unittests
adwski May 15, 2024
47d6521
chore: update coverage badge
adwski May 15, 2024
733951f
fix lint errs
adwski May 15, 2024
8a33952
add more auth unittests
adwski May 16, 2024
41c8d85
add vidit login and re-login e2e tests
adwski May 16, 2024
dd6476b
chore: update coverage badge
adwski May 16, 2024
9ba8aa1
add cli tests and upload resume tests
adwski May 16, 2024
e0e2b37
chore: update coverage badge
adwski May 16, 2024
f2ec549
add session store unittests
adwski May 16, 2024
e39f4e7
chore: update coverage badge
adwski May 16, 2024
9564338
add comments
adwski May 16, 2024
960cbc3
add default-file-picker-dir cmdline arg to vidit
adwski May 17, 2024
9e58a2d
rm generated ca from config.json
adwski May 17, 2024
5a887f1
update README, rm old doc
adwski May 17, 2024
4995e3b
chore: update coverage badge
adwski May 17, 2024
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
7 changes: 3 additions & 4 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
cache: false
go-version-file: go.mod
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.55.2
version: v1.58.1
4 changes: 2 additions & 2 deletions .github/workflows/statictest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ on:
jobs:
statictest:
runs-on: ubuntu-latest
container: golang:1.21
container: golang:1.22
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Download statictest binary
uses: robinraju/[email protected]
Expand Down
15 changes: 14 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ report.xml
profile.cov
coverage.html

# macos stuff
.DS_Store

output
# test paths
output/
cmd/vidictl/test.go
docker/compose/config/test.xml

# certs
docker/compose/tls/*
!docker/compose/tls/placeholder

e2e/cert.pem
e2e/key.pem

dist/
61 changes: 13 additions & 48 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
# Options for analysis running.
run:
go: "1.21"
go: "1.22"
# Settable parameters #
timeout: 5m
tests: true
build-tags: []
# Which dirs to skip: issues from them won't be reported.
skip-dirs:
- "bin"
- "scripts"
- ".ci"
- ".gradle"
# Which files to skip: they will be analyzed, but issues from them won't be reported.
skip-files: []

# Invariable parameters #

# Exit code when at least one issue was found.
issues-exit-code: 1
# Enables skipping of directories:
# - vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: false
# If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
Expand All @@ -43,7 +32,8 @@ run:

# Output configuration options
output:
format: colored-line-number
formats:
- format: colored-line-number
# Print lines of code with issue.
print-issued-lines: true
# Print linter name in the end of issue text.
Expand Down Expand Up @@ -100,43 +90,11 @@ linters-settings:

gocritic:
enabled-checks:
- appendAssign
- appendCombine
- argOrder
- assignOp
- badCall
- badCond
- captLocal
- caseOrder
- commentFormatting
- defaultCaseOrder
- deprecatedComment
- dupArg
- dupBranchBody
- dupCase
- dupSubExpr
- elseif
- exitAfterDefer
- flagDeref
- flagName
- ifElseChain
- indexAlloc
- mapKey
- newDeref
- offBy1
- rangeExprCopy
- rangeValCopy
- regexpMust
- singleCaseSwitch
- sloppyLen
- stringXbytes
- switchTrue
- typeSwitchVar
- underef
- unlambda
- unslice
- valSwap
- wrapperFunc

godot:
capital: true
Expand All @@ -150,7 +108,7 @@ linters-settings:
goimports:
local-prefixes: github.com/org/project

gomnd:
mnd:
checks:
- argument
- case
Expand Down Expand Up @@ -372,15 +330,14 @@ linters:
- errcheck
- errname
- errorlint
- execinquery
- exhaustive
- gocheckcompilerdirectives
- goconst
- gocritic
- godot
- gofmt
- goimports
- gomnd
- mnd
- goprintffuncname
- gosec
- gosimple
Expand Down Expand Up @@ -418,8 +375,16 @@ linters:

# Issues configuration
issues:
exclude-dirs:
- "bin"
- "scripts"
- ".ci"
- ".gradle"
exclude: []
exclude-case-sensitive: false
# Enables skipping of directories:
# - vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
exclude-dirs-use-default: false
exclude-rules:
- path: "_test\\.go"
text: "fieldalignment: struct with \\d+ pointer bytes could be \\d+"
Expand Down
34 changes: 34 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: 1

before:
hooks:
- go mod tidy

builds:
- env:
- CGO_ENABLED=0
main: ./cmd/vidit
binary: vidit
tags:
- netgo
goos:
- darwin
- linux
- windows
goarch:
- "386"
- amd64
- arm64

archives:
- format: tar.gz
name_template: >-
{{- .ProjectName -}}
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
format_overrides:
- goos: windows
format: zip
1 change: 1 addition & 0 deletions .mockery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ packages:
github.com/adwski/vidi/internal/api/video:
interfaces:
Store: {}
SessionStore: {}
45 changes: 38 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SHELL := /bin/bash

.PHONY: mock
mock:
find . -type f -name "mock_*" -exec rm -rf {} +
Expand All @@ -9,21 +11,30 @@ docker-dev:
docker compose up -d
docker ps

.PHONY: docker-infra
docker-infra:
cd docker/compose ;\
docker compose -f docker-compose.infra.yml up -d
docker compose -f docker-compose.infra.yml -f docker-compose.nginx.yml up -d
docker ps

.PHONY: docker-infra-clean
docker-infra-clean:
cd docker/compose ;\
docker compose -f docker-compose.infra.yml down -v
docker compose -f docker-compose.infra.yml -f docker-compose.nginx.yml down -v
docker ps

.PHONY: docker-dev-build
docker-dev-build:
cd docker/compose ;\
docker compose up -d --build
docker ps

.PHONY: docker-dev-build-svc
docker-dev-build-svc:
cd docker/compose ;\
docker compose up -d --no-deps --build $$SVC
docker ps

.PHONY: docker-dev-clean
docker-dev-clean:
cd docker/compose ;\
Expand All @@ -37,16 +48,19 @@ goimports:
lint:
golangci-lint run ./...

.PHONY: build
build:
go build -gcflags "-m" -race -o ./cmd/userapi/userapi ./cmd/userapi/*.go
build-tui:
goreleaser build --debug --clean

.PHONY: statictest
statictest:
go vet -vettool=$$(which statictest) ./...

.PHONY: test-nginx
test-nginx:
docker run --rm -it --entrypoint nginx -v ./docker/compose/nginx.conf:/etc/nginx/nginx.conf nginx:1.25.3-bookworm -t
docker run --rm -it --entrypoint nginx \
-v ./docker/compose/tls:/etc/nginx/tls \
-v ./docker/compose/nginx.conf:/etc/nginx/nginx.conf \
nginx:1.25.3-bookworm -t

.PHONY: unittests
unittests:
Expand All @@ -56,10 +70,27 @@ unittests:
cover:
go tool cover -html profile.cov -o coverage.html


.PHONY: test-all
test-all: docker-infra
go test -v -count=1 -cover -coverpkg=./... -coverprofile=profile.cov --tags e2e ./...
go tool cover -func profile.cov
$(MAKE) cover
$(MAKE) docker-infra-clean

.PHONY: grpc
grpc:
protoc --go_out=. --go-grpc_out=. internal/api/video/grpc/protobuf/user.proto
protoc --go_out=. --go-grpc_out=. internal/api/video/grpc/protobuf/service.proto

.PHONY: tls
tls:
openssl req -x509 -nodes -days 365 -newkey rsa:4096 \
-keyout ./docker/compose/tls/key.pem -out ./docker/compose/tls/cert.pem \
-subj "/C=RU/O=ViDi/OU=vidi/CN=vidi" \
-addext "subjectAltName = DNS:localhost, IP:127.0.0.1, IP:::1"

VIDI_CA=$$(base64 -i ./docker/compose/tls/cert.pem) && \
tmp=$$(mktemp) && \
cfg="./docker/compose/config/config.json" && \
jq --arg a "$$VIDI_CA" '.vidi_ca = $$a' $$cfg > $$tmp && \
mv $$tmp $$cfg
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Vidi

![Coverage](https://img.shields.io/badge/Coverage-80.4%25-brightgreen)
![Coverage](https://img.shields.io/badge/Coverage-70.9%25-brightgreen)

WIP

Expand Down
11 changes: 0 additions & 11 deletions cmd/vidi/vidi.go

This file was deleted.

11 changes: 11 additions & 0 deletions cmd/vidictl/vidi.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

import (
"os"

"github.com/adwski/vidi/internal/cli"
)

func main() {
os.Exit(cli.Execute())
}
16 changes: 16 additions & 0 deletions cmd/vidit/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package main

import (
"log"
"os"

"github.com/adwski/vidi/internal/tool"
)

func main() {
t, err := tool.New()
if err != nil {
log.Fatal(err)
}
os.Exit(t.Run())
}
5 changes: 5 additions & 0 deletions docker/compose/config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"user_api_url": "http://localhost/api/users",
"video_api_url": "localhost:443",
"vidi_ca": "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUZoRENDQTJ5Z0F3SUJBZ0lVWTNSZmo0V1I3VkNwUEREZ2liR1Q0V1RySzlBd0RRWUpLb1pJaHZjTkFRRUwKQlFBd09qRUxNQWtHQTFVRUJoTUNVbFV4RFRBTEJnTlZCQW9NQkZacFJHa3hEVEFMQmdOVkJBc01CSFpwWk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V5c2wyeWpVSGtiUWhpY1hqZVlsei9sNk9jRVFDN2pGaHVwcmZaWmR2Yzd1QWFJczBINER2CjdYOXdvRlh5OXNzUUwwZk1nemdIQ2M5VmQ4TDlabWNWazBhV3RncWxiRERYM2wreVFHUjBnNW5pcnhDUGZZNC8KWEF2R2p4ZFllcnBxNGFmNkNIeHRCZkdMaGszZnYwbmM4REtDRnZUZUhHTC9SbmkzZnB3SURHN2dTcUZaOFBtVQpTQStKN0Y0UUlNaVNrLy9JYUxlWThBdnRDUG1RY3VsZgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg=="
}
16 changes: 9 additions & 7 deletions docker/compose/docker-compose.api.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---
version: "3.8"

x-logging: &logging
driver: "json-file"
options:
Expand All @@ -18,7 +16,7 @@ services:
environment:
VIDI_API_PREFIX: /api/users
VIDI_DATABASE_DSN: postgres://userapi:userapi@postgres:5432/userapi?sslmode=disable
VIDI_SERVER_ADDRESS: ":8080"
VIDI_SERVER_HTTP_ADDRESS: ":8080"
expose:
- 8080
networks:
Expand All @@ -34,14 +32,18 @@ services:
dockerfile: docker/videoapi.Dockerfile
target: dev
environment:
VIDI_API_PREFIX: /api/video
VIDI_API_PREFIX: /api
VIDI_DATABASE_DSN: postgres://videoapi:videoapi@postgres:5432/videoapi?sslmode=disable
VIDI_REDIS_DSN: redis://redis:6379/0
VIDI_MEDIA_URL_WATCH: http://localhost:8080/watch
VIDI_MEDIA_URL_UPLOAD: http://localhost:8080/upload
VIDI_SERVER_ADDRESS: ":8080"
VIDI_MEDIA_URL_WATCH: http://localhost:80/watch
VIDI_MEDIA_URL_UPLOAD: http://localhost:80/upload
VIDI_SERVER_HTTP_ADDRESS: ":8080"
VIDI_SERVER_GRPC_ADDRESS: ":8181"
VIDI_SERVER_GRPC_SVC_ADDRESS: ":8282"
expose:
- 8080
ports:
- "8282:8282"
networks:
- vidi
depends_on:
Expand Down
Loading
Loading