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

First Iteration #1

Merged
merged 37 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1607464
media processor and store, api drafts
adwski Jan 6, 2024
6fe6e5e
add common api store and user store
adwski Jan 7, 2024
0df5482
add user request validation
adwski Jan 7, 2024
4093a6e
add service configuration, add userapi service
adwski Jan 8, 2024
4805cfb
add videoapi and session store
adwski Jan 9, 2024
4995424
fix err wrap
adwski Jan 9, 2024
98359ee
add videoapi client, uploader service, notificator, fasthttp server
adwski Jan 10, 2024
e4ec3db
add uploader and streamer apps, add ristretto cache to session store
adwski Jan 11, 2024
3088e60
add processor, add cli, refactor segmenter
adwski Jan 12, 2024
5129703
refactor compose, fix userapi
adwski Jan 13, 2024
8c5703d
fixes and refactoring
adwski Jan 13, 2024
f6eddc4
add token create cmd, add happy path, fix bugs
adwski Jan 15, 2024
b6a9b22
add dash player, update happy path and readme
adwski Jan 16, 2024
5aec29a
remove unused nginx mount
adwski Jan 16, 2024
09be886
add comments
adwski Jan 17, 2024
35556a0
expant video section to fill viewport
adwski Jan 17, 2024
e1f2e88
customize default echo middleware
adwski Jan 18, 2024
2c8ee68
rm manual password salting, minor fixes and refactor
adwski Jan 26, 2024
8b5504c
fix case in sql
adwski Jan 26, 2024
9970646
add generator tests
adwski Jan 26, 2024
c16d0ee
add logger tests
adwski Jan 26, 2024
3b4f3bc
add auth tests, server tests, user e2e tests
adwski Jan 29, 2024
970c070
add vide e2e tests and getall in video user-side api
adwski Jan 30, 2024
f905db6
rm unused funcs
adwski Jan 30, 2024
01f431b
add more tests and guthub tests workflow
adwski Jan 31, 2024
1528b94
add fs output to test step
adwski Jan 31, 2024
1f8910f
fix testfiles dir
adwski Jan 31, 2024
11673d2
add coverage badge, update readme
adwski Jan 31, 2024
dac453a
fix push branch
adwski Jan 31, 2024
a34add9
rm github-push-action
adwski Jan 31, 2024
18595c0
specify push branch
adwski Jan 31, 2024
cf7c86f
try checkout -t -b
adwski Jan 31, 2024
a98c893
add ref to checkout action
adwski Jan 31, 2024
9108468
chore: update coverage badge
adwski Jan 31, 2024
c8ad397
update verify-changed-files
adwski Jan 31, 2024
b39b138
fix viperEC tests and videostore getall error
adwski Feb 5, 2024
9489e1e
increase MaxRequestBodySize for media services
adwski Feb 6, 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
83 changes: 83 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: e2e tests

on:
pull_request:
push:
branches:
- main

jobs:

e2etests:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:16.1
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 5s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

redis:
image: redis:7
ports:
- 6379:6379

minio:
image: minio/minio:edge-cicd
options: --health-cmd "curl -s http://localhost:9000/minio/health/live"
env:
MINIO_ROOT_USER: admin
MINIO_ROOT_PASSWORD: password
ports:
- 9000:9000

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: setup db
env:
PGPASSWORD: postgres
run: |
psql -h localhost -p 5432 -U postgres -f ./docker/compose/initdb/0001_init.sql

- uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: install deps
run: go mod download

- name: run tests
run: |
go test -v -count=1 -cover -coverpkg=./... -coverprofile=profile.cov --tags e2e ./...
go tool cover -func=profile.cov
go tool cover -func=profile.cov -o=coverage.out

- name: coverage badge
uses: tj-actions/coverage-badge-go@v2
with:
filename: coverage.out

- name: verify changed files
uses: tj-actions/verify-changed-files@v17
id: verify-changed-files
with:
files: README.md

- name: push badge
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add README.md
git commit -m "chore: update coverage badge"
git push
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ vendor/

# Reports
report.xml
profile.cov
coverage.html

.DS_Store

Expand Down
11 changes: 11 additions & 0 deletions .mockery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
quiet: False
disable-version-string: True
with-expecter: True
mockname: "Mock{{.InterfaceName}}"
filename: "mock_{{.InterfaceName|lower}}_test.go"
outpkg: "{{.PackageName}}"
dir: "{{.InterfaceDir}}"
packages:
github.com/adwski/vidi/internal/api/video:
interfaces:
Store: {}
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
.PHONY: mock
mock:
find . -type f -name "mock_*" -exec rm -rf {} +
mockery

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

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

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

docker-dev-build:
cd docker/compose ;\
docker compose up -d --build
Expand Down Expand Up @@ -32,3 +47,19 @@ statictest:

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

.PHONY: unittests
unittests:
go test -v -count=1 ./...

.PHONY: cover
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
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Vidi

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

WIP

This is a final project for Yandex Practicum's Go Course.
Expand Down Expand Up @@ -30,6 +32,17 @@ make docker-dev
make docker-dev-clean
```

### Tests

```bash
# run unit tests
make unittests

# run unit and end2end tests
# docker compose project should be stopped (it will be ran by the command)
make test-all
```

### Happy Path

User interaction flow is described [here](./docs/happy_path.md).
2 changes: 1 addition & 1 deletion docker/compose/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
COMPOSE_PROJECT_NAME=vidi-dev
COMPOSE_FILE=docker-compose.infra.yml:docker-compose.api.yml:docker-compose.media.yml
COMPOSE_FILE=docker-compose.infra.yml:docker-compose.api.yml:docker-compose.media.yml:docker-compose.nginx.yml
1 change: 0 additions & 1 deletion docker/compose/docker-compose.api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ services:
environment:
VIDI_API_PREFIX: /api/users
VIDI_DATABASE_DSN: postgres://userapi:userapi@postgres:5432/userapi?sslmode=disable
VIDI_DATABASE_SALT: q1w2e3r4t5
VIDI_SERVER_ADDRESS: ":8080"
expose:
- 8080
Expand Down
14 changes: 1 addition & 13 deletions docker/compose/docker-compose.infra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@ x-logging: &logging
max-file: "5"

services:
nginx:
logging: *logging
restart: unless-stopped
image: nginx:1.25.3-bookworm
volumes:
- "./nginx.conf:/etc/nginx/nginx.conf:ro"
- "./player:/var/www/player:ro"
ports:
- "8080:80"
networks:
- vidi

minio:
logging: *logging
restart: unless-stopped
Expand Down Expand Up @@ -48,7 +36,7 @@ services:
- "vidi-db:/var/lib/postgresql/data"
- "./initdb:/docker-entrypoint-initdb.d:ro"
ports:
- "5400:5432"
- "5432:5432"
networks:
- vidi

Expand Down
26 changes: 26 additions & 0 deletions docker/compose/docker-compose.nginx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
version: "3.8"

x-logging: &logging
driver: "json-file"
options:
max-size: "100k"
max-file: "5"

services:
nginx:
logging: *logging
restart: unless-stopped
image: nginx:1.25.3-bookworm
volumes:
- "./nginx.conf:/etc/nginx/nginx.conf:ro"
- "./player:/var/www/player:ro"
ports:
- "8080:80"
networks:
- vidi

networks:
vidi:
name: vidi-net
driver: bridge
Loading
Loading