mirror of
https://github.com/koel/koel
synced 2024-11-24 05:03:05 +00:00
feat(build): add CI unit tests with PostgreSQL (#1544)
This commit is contained in:
parent
d4046ff24f
commit
e527eccf03
4 changed files with 94 additions and 2 deletions
79
.github/workflows/unit-backend-pgsql.yml
vendored
Normal file
79
.github/workflows/unit-backend-pgsql.yml
vendored
Normal file
|
@ -0,0 +1,79 @@
|
|||
name: Backend Unit Tests - PostgreSQL
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
paths-ignore:
|
||||
- resources/assets/**
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths-ignore:
|
||||
- resources/assets/**
|
||||
workflow_dispatch:
|
||||
branches:
|
||||
- master
|
||||
paths-ignore:
|
||||
- resources/assets/**
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
php-version: [ 8.0, 8.1 ]
|
||||
fail-fast: false
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres
|
||||
env:
|
||||
POSTGRES_DB: koel
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
ports:
|
||||
- 5432:5432
|
||||
options: >-
|
||||
--health-cmd pg_isready
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
|
||||
env:
|
||||
DB_CONNECTION: pgsql-ci
|
||||
DB_HOST: localhost
|
||||
DB_PORT: 5432
|
||||
DB_DATABASE: koel
|
||||
DB_USERNAME: postgres
|
||||
DB_PASSWORD: postgres
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Set up PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-version }}
|
||||
tools: composer:v2
|
||||
coverage: xdebug
|
||||
extensions: pdo_sqlite, zip, gd
|
||||
- name: Install PHP dependencies
|
||||
uses: ramsey/composer-install@v2
|
||||
with:
|
||||
composer-options: --prefer-dist
|
||||
- name: Generate app key
|
||||
run: php artisan key:generate --quiet
|
||||
- name: Run code style checker
|
||||
run: composer cs
|
||||
- name: Run static analysis
|
||||
run: composer analyze -- --no-progress
|
||||
- name: Run tests
|
||||
run: composer coverage
|
||||
- name: Upload logs if broken
|
||||
uses: actions/upload-artifact@v1
|
||||
if: failure()
|
||||
with:
|
||||
name: logs
|
||||
path: storage/logs
|
||||
- name: Upload coverage
|
||||
uses: codecov/codecov-action@v1
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
|
@ -74,6 +74,18 @@ return [
|
|||
'schema' => 'public',
|
||||
],
|
||||
|
||||
'pgsql-ci' => [
|
||||
'driver' => 'pgsql',
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
'port' => env('DB_PORT', 5432),
|
||||
'database' => env('DB_DATABASE', 'koel'),
|
||||
'username' => env('DB_USERNAME', 'postgres'),
|
||||
'password' => env('DB_PASSWORD', 'postgres'),
|
||||
'charset' => 'utf8',
|
||||
'prefix' => '',
|
||||
'schema' => 'public',
|
||||
],
|
||||
|
||||
'sqlsrv' => [
|
||||
'driver' => 'sqlsrv',
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
|
|
|
@ -72,8 +72,9 @@ class DownloadTest extends TestCase
|
|||
->with(Mockery::on(static function (Collection $retrievedSongs) use ($songs): bool {
|
||||
$retrievedIds = $retrievedSongs->pluck('id')->toArray();
|
||||
$requestedIds = $songs->pluck('id')->toArray();
|
||||
self::assertEqualsCanonicalizing($requestedIds, $retrievedIds);
|
||||
|
||||
return $requestedIds[0] === $retrievedIds[0] && $requestedIds[1] === $retrievedIds[1];
|
||||
return true;
|
||||
}))
|
||||
->andReturn($this->mediaPath . '/blank.mp3'); // should be a zip file, but we're testing here…
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ class SongTest extends TestCase
|
|||
->assertOk();
|
||||
|
||||
/** @var array<array-key, Song>|Collection $songs */
|
||||
$songs = Song::query()->latest()->take(3)->get();
|
||||
$songs = Song::query()->whereIn('id', $originalSongs->pluck('id'))->get();
|
||||
|
||||
// Even though the album name doesn't change, a new artist should have been created
|
||||
// and thus, a new album with the same name was created as well.
|
||||
|
|
Loading…
Reference in a new issue