2020-08-09 21:13:25 +02:00
|
|
|
name: Tests
|
2020-08-09 20:32:02 +02:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [master]
|
|
|
|
pull_request:
|
|
|
|
branches: [master]
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
test-api:
|
|
|
|
name: Test API
|
2024-08-03 23:17:54 +02:00
|
|
|
runs-on: ubuntu-latest
|
2021-04-23 20:52:55 +02:00
|
|
|
strategy:
|
2021-09-27 20:59:41 +02:00
|
|
|
fail-fast: false
|
2021-04-23 20:52:55 +02:00
|
|
|
matrix:
|
2024-08-03 23:17:54 +02:00
|
|
|
database: ['sqlite', 'mysql', 'postgres']
|
2021-04-23 20:52:55 +02:00
|
|
|
|
|
|
|
services:
|
|
|
|
mariadb:
|
2024-08-29 15:25:25 +02:00
|
|
|
image: mariadb:lts
|
2021-04-23 20:52:55 +02:00
|
|
|
env:
|
|
|
|
MYSQL_DATABASE: photoview_test
|
|
|
|
MYSQL_USER: photoview
|
|
|
|
MYSQL_PASSWORD: photosecret
|
2021-04-23 21:00:11 +02:00
|
|
|
MYSQL_RANDOM_ROOT_PASSWORD: yes
|
2024-08-29 15:25:25 +02:00
|
|
|
# https://github.com/MariaDB/mariadb-docker/issues/497
|
2021-04-23 20:52:55 +02:00
|
|
|
options: >-
|
2024-08-29 15:25:25 +02:00
|
|
|
--health-cmd="mariadb-admin ping"
|
2021-04-23 20:52:55 +02:00
|
|
|
--health-interval=10s
|
|
|
|
--health-timeout=5s
|
|
|
|
--health-retries=5
|
2021-04-23 21:14:11 +02:00
|
|
|
ports:
|
|
|
|
- 3306:3306
|
2021-04-23 20:52:55 +02:00
|
|
|
|
|
|
|
postgres:
|
2024-08-29 15:25:25 +02:00
|
|
|
image: postgres:16-alpine
|
2021-04-23 20:52:55 +02:00
|
|
|
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
|
2021-04-23 21:14:11 +02:00
|
|
|
ports:
|
|
|
|
- 5432:5432
|
2021-04-23 20:52:55 +02:00
|
|
|
|
2020-08-09 20:32:02 +02:00
|
|
|
steps:
|
2024-08-03 23:17:54 +02:00
|
|
|
- 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
|
2024-08-29 15:25:25 +02:00
|
|
|
id: test
|
2024-08-03 23:17:54 +02:00
|
|
|
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
|
2024-08-29 15:25:25 +02:00
|
|
|
if: ${{ steps.test.conclusion == 'success' || steps.test.conclusion == 'failure' }}
|
2024-08-03 23:17:54 +02:00
|
|
|
with:
|
|
|
|
flags: api-${{ matrix.database }}
|
2021-02-15 20:47:01 +01:00
|
|
|
|
2020-09-27 23:04:05 +02:00
|
|
|
test-ui:
|
|
|
|
name: Test UI
|
|
|
|
runs-on: ubuntu-latest
|
2021-02-15 20:47:01 +01:00
|
|
|
|
2020-09-27 23:04:05 +02:00
|
|
|
steps:
|
2024-08-03 23:17:54 +02:00
|
|
|
- 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
|
2024-08-29 15:25:25 +02:00
|
|
|
id: test
|
2024-08-03 23:17:54 +02:00
|
|
|
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
|
2024-08-29 15:25:25 +02:00
|
|
|
if: ${{ steps.test.conclusion == 'success' || steps.test.conclusion == 'failure' }}
|
2024-08-03 23:17:54 +02:00
|
|
|
with:
|
|
|
|
flags: ui
|
2024-08-29 15:25:25 +02:00
|
|
|
|
|
|
|
- name: Run ESLint
|
|
|
|
working-directory: ui
|
|
|
|
run: |
|
|
|
|
npm run lint:ci || true
|
|
|
|
echo "--------------------------"
|
|
|
|
echo "ESLint execution results :"
|
|
|
|
echo "--------------------------"
|
|
|
|
cat ./eslint-report.txt || echo "ESLint report file not found."
|
|
|
|
|
|
|
|
- name: ESLint artifact
|
|
|
|
id: eslint-artifact
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
with:
|
|
|
|
name: ESLint-report
|
|
|
|
path: ./ui/eslint-report.txt
|
|
|
|
if-no-files-found: warn
|
|
|
|
compression-level: 9
|
|
|
|
overwrite: true
|