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
|
2021-02-16 10:44:38 +01:00
|
|
|
runs-on: ubuntu-20.04
|
2020-08-09 20:32:02 +02:00
|
|
|
|
2021-04-23 20:52:55 +02:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
database: ['mysql', 'postgres', 'sqlite']
|
|
|
|
|
|
|
|
services:
|
|
|
|
mariadb:
|
|
|
|
image: mariadb:10.5
|
|
|
|
env:
|
|
|
|
MYSQL_DATABASE: photoview_test
|
|
|
|
MYSQL_USER: photoview
|
|
|
|
MYSQL_PASSWORD: photosecret
|
2021-04-23 21:00:11 +02:00
|
|
|
MYSQL_RANDOM_ROOT_PASSWORD: yes
|
2021-04-23 20:52:55 +02:00
|
|
|
options: >-
|
|
|
|
--health-cmd="mysqladmin ping"
|
|
|
|
--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:
|
2021-04-23 20:54:01 +02:00
|
|
|
image: postgres:13.2
|
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
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: api
|
|
|
|
|
|
|
|
steps:
|
2021-04-23 20:52:55 +02:00
|
|
|
- name: Set up Go
|
2020-08-09 20:32:02 +02:00
|
|
|
uses: actions/setup-go@v2
|
|
|
|
with:
|
2021-04-23 20:52:55 +02:00
|
|
|
go-version: ^1.16
|
2020-08-09 20:32:02 +02:00
|
|
|
id: go
|
|
|
|
|
|
|
|
- name: Check out code into the Go module directory
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
2021-04-23 21:07:32 +02:00
|
|
|
- name: Cache Go dependencies
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: ~/go/pkg/mod
|
|
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-go-
|
|
|
|
|
2021-02-15 20:47:01 +01:00
|
|
|
- name: Get C dependencies
|
2021-02-15 23:40:02 +01:00
|
|
|
run: |
|
2021-03-27 23:15:14 +01:00
|
|
|
sudo add-apt-repository ppa:strukturag/libheif
|
|
|
|
sudo add-apt-repository ppa:strukturag/libde265
|
2021-02-15 23:40:02 +01:00
|
|
|
sudo apt-get update
|
2021-06-04 22:45:33 +02:00
|
|
|
sudo apt-get install -y libdlib-dev libblas-dev libatlas-base-dev liblapack-dev libjpeg-turbo8-dev libheif-dev
|
2021-02-15 20:47:01 +01:00
|
|
|
|
|
|
|
- name: Get GO dependencies
|
2020-08-09 20:32:02 +02:00
|
|
|
run: |
|
|
|
|
go get -v -t -d ./...
|
|
|
|
if [ -f Gopkg.toml ]; then
|
|
|
|
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
|
|
|
dep ensure
|
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Build
|
|
|
|
run: go build -v .
|
|
|
|
|
2021-04-23 20:52:55 +02:00
|
|
|
- name: Configure MySQL
|
|
|
|
if: ${{ matrix.database == 'mysql' }}
|
|
|
|
run: |
|
|
|
|
cp ../.github/mysql.testing.env testing.env
|
|
|
|
|
|
|
|
- name: Configure Postgres
|
|
|
|
if: ${{ matrix.database == 'postgres' }}
|
|
|
|
run: |
|
|
|
|
cp ../.github/postgres.testing.env testing.env
|
|
|
|
|
|
|
|
- name: Configure Sqlite
|
|
|
|
if: ${{ matrix.database == 'sqlite' }}
|
|
|
|
run: |
|
|
|
|
touch photoview_test.db
|
|
|
|
cp ../.github/sqlite.testing.env testing.env
|
|
|
|
|
2020-08-09 20:32:02 +02:00
|
|
|
- name: Test
|
2021-04-23 21:46:01 +02:00
|
|
|
run: go test ./... -v -database -filesystem -p 1 -coverprofile=coverage.txt -covermode=atomic
|
|
|
|
|
|
|
|
- name: Upload coverage
|
2021-04-23 22:01:52 +02:00
|
|
|
uses: codecov/codecov-action@v1
|
|
|
|
with:
|
|
|
|
flags: api
|
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
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: ui
|
2021-02-15 20:47:01 +01:00
|
|
|
|
2020-09-27 23:04:05 +02:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2021-04-05 23:18:38 +02:00
|
|
|
node-version: [15.x]
|
2020-09-27 23:04:05 +02:00
|
|
|
|
|
|
|
steps:
|
2021-04-23 22:01:52 +02:00
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Cache NPM dependencies
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: ~/.npm
|
|
|
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-node-
|
|
|
|
|
|
|
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
|
|
uses: actions/setup-node@v1
|
|
|
|
with:
|
|
|
|
node-version: ${{ matrix.node-version }}
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: npm clean-install
|
|
|
|
|
|
|
|
- name: Test
|
|
|
|
run: npm run test:ci
|
|
|
|
|
|
|
|
- name: Upload coverage
|
|
|
|
uses: codecov/codecov-action@v1
|
|
|
|
with:
|
|
|
|
flags: ui
|