113 lines
2.7 KiB
YAML
113 lines
2.7 KiB
YAML
name: Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
pull_request:
|
|
branches: [master]
|
|
|
|
jobs:
|
|
test-api:
|
|
name: Test API
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
database: ['sqlite', 'mysql', 'postgres']
|
|
|
|
services:
|
|
mariadb:
|
|
image: mariadb:10.5
|
|
env:
|
|
MYSQL_DATABASE: photoview_test
|
|
MYSQL_USER: photoview
|
|
MYSQL_PASSWORD: photosecret
|
|
MYSQL_RANDOM_ROOT_PASSWORD: yes
|
|
options: >-
|
|
--health-cmd="mysqladmin ping"
|
|
--health-interval=10s
|
|
--health-timeout=5s
|
|
--health-retries=5
|
|
ports:
|
|
- 3306:3306
|
|
|
|
postgres:
|
|
image: postgres:13.2
|
|
env:
|
|
POSTGRES_USER: photoview
|
|
POSTGRES_PASSWORD: photosecret
|
|
POSTGRES_DB: photoview_test
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
|
|
steps:
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Build test image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
pull: true
|
|
push: false
|
|
load: true
|
|
target: api
|
|
tags: photoview/api
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
- name: Test
|
|
run: |
|
|
docker run --name test --network host \
|
|
-e PHOTOVIEW_DATABASE_DRIVER=${{ matrix.database }} \
|
|
-e PHOTOVIEW_MYSQL_URL='photoview:photosecret@tcp(localhost:3306)/photoview_test' \
|
|
-e PHOTOVIEW_POSTGRES_URL='postgres://photoview:photosecret@localhost:5432/photoview_test' \
|
|
-e PHOTOVIEW_SQLITE_PATH=/tmp/photoview.db \
|
|
photoview/api \
|
|
go test ./... -v -database -filesystem -p 1 -coverprofile=coverage.txt -covermode=atomic
|
|
docker cp test:/app/api/coverage.txt ./api/
|
|
|
|
- name: Upload coverage
|
|
uses: codecov/codecov-action@v4
|
|
with:
|
|
flags: api-${{ matrix.database }}
|
|
|
|
test-ui:
|
|
name: Test UI
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Build test image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
pull: true
|
|
push: false
|
|
load: true
|
|
target: ui
|
|
tags: photoview/ui
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
- name: Test
|
|
run: |
|
|
docker run --name test photoview/ui npm run test:ci
|
|
docker cp test:/app/ui/coverage ./ui/
|
|
|
|
- name: Upload coverage
|
|
uses: codecov/codecov-action@v4
|
|
with:
|
|
flags: ui
|