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

tec: Improve tests performance #693

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
63 changes: 63 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Linters

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
NO_DOCKER: true

jobs:
build:
runs-on: ${{ matrix.operating-system }}

strategy:
matrix:
operating-system: [ubuntu-22.04]
php-versions: ['8.2', '8.3']

name: PHP ${{ matrix.php-versions }} CI on ${{ matrix.operating-system }}

steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: xdebug
extensions: intl, gettext, pcntl, gd, pdo, pdo_pgsql
ini-values: browscap=${{ github.workspace }}/docker/lite_php_browscap.ini

- name: Setup locales
run: |
sudo apt-get install locales
sudo locale-gen fr_FR.UTF-8 en_GB.UTF-8

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Cache node dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-

- name: Install dependencies
run: make install

- name: Run the linters
run: make lint
16 changes: 2 additions & 14 deletions .github/workflows/ci.yml → .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Continuous Integration
name: Tests

on:
push:
Expand All @@ -14,8 +14,6 @@ env:
DB_PASSWORD: postgres
COVERAGE: --coverage-text
MOCK_HOST: "http://127.0.0.1:8001"
APP_SUBSCRIPTIONS_HOST: ${{ secrets.APP_SUBSCRIPTIONS_HOST }}
APP_SUBSCRIPTIONS_PRIVATE_KEY: ${{ secrets.APP_SUBSCRIPTIONS_PRIVATE_KEY }}

jobs:
build:
Expand Down Expand Up @@ -67,24 +65,14 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Cache node dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-

- name: Install dependencies
run: make install
run: composer install

- name: Setup the application
run: make setup
env:
DB_PORT: ${{ job.services.postgres.ports[5432] }}

- name: Run the linters
run: make lint

- name: Run mock_server (background)
run: php -t ${{ github.workspace }} -S 127.0.0.1:8001 ${{ github.workspace }}/tests/mock_server/index.php &

Expand Down
2 changes: 1 addition & 1 deletion lib/Minz
4 changes: 2 additions & 2 deletions tests/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

class ApplicationTest extends \PHPUnit\Framework\TestCase
{
use \Minz\Tests\InitializerHelper;
use \Minz\Tests\ResponseAsserts;
use \tests\FakerHelper;
use \tests\InitializerHelper;
use \tests\LoginHelper;
use \Minz\Tests\ResponseAsserts;

public function testRunSetsTheDefaultLocale(): void
{
Expand Down
49 changes: 0 additions & 49 deletions tests/InitializerHelper.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/auth/CurrentUserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

class CurrentUserTest extends \PHPUnit\Framework\TestCase
{
use \Minz\Tests\InitializerHelper;
use \tests\FakerHelper;
use \tests\InitializerHelper;

#[\PHPUnit\Framework\Attributes\Before]
public function resetCurrentUser(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class ApplicationTest extends \PHPUnit\Framework\TestCase
{
use \tests\InitializerHelper;
use \Minz\Tests\InitializerHelper;
use \Minz\Tests\ResponseAsserts;

public function testRunDoesntFail(): void
Expand Down
4 changes: 2 additions & 2 deletions tests/cli/FeatureFlagsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

class FeatureFlagsTest extends \PHPUnit\Framework\TestCase
{
use \tests\FakerHelper;
use \tests\InitializerHelper;
use \Minz\Tests\ApplicationHelper;
use \Minz\Tests\InitializerHelper;
use \Minz\Tests\ResponseAsserts;
use \tests\FakerHelper;

#[\PHPUnit\Framework\Attributes\BeforeClass]
public static function loadApplication(): void
Expand Down
6 changes: 3 additions & 3 deletions tests/cli/FeedsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

class FeedsTest extends \PHPUnit\Framework\TestCase
{
use \tests\FakerHelper;
use \tests\InitializerHelper;
use \tests\MockHttpHelper;
use \Minz\Tests\ApplicationHelper;
use \Minz\Tests\InitializerHelper;
use \Minz\Tests\ResponseAsserts;
use \tests\FakerHelper;
use \tests\MockHttpHelper;

#[\PHPUnit\Framework\Attributes\BeforeClass]
public static function loadApplication(): void
Expand Down
4 changes: 2 additions & 2 deletions tests/cli/MediaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

class MediaTest extends \PHPUnit\Framework\TestCase
{
use \tests\InitializerHelper;
use \tests\MockHttpHelper;
use \Minz\Tests\ApplicationHelper;
use \Minz\Tests\InitializerHelper;
use \Minz\Tests\ResponseAsserts;
use \tests\MockHttpHelper;

#[\PHPUnit\Framework\Attributes\BeforeClass]
public static function loadApplication(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/SystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

class SystemTest extends \PHPUnit\Framework\TestCase
{
use \tests\InitializerHelper;
use \Minz\Tests\ApplicationHelper;
use \Minz\Tests\InitializerHelper;
use \Minz\Tests\ResponseAsserts;

#[\PHPUnit\Framework\Attributes\BeforeClass]
Expand Down
4 changes: 2 additions & 2 deletions tests/cli/TopicsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

class TopicsTest extends \PHPUnit\Framework\TestCase
{
use \tests\FakerHelper;
use \tests\InitializerHelper;
use \Minz\Tests\ApplicationHelper;
use \Minz\Tests\InitializerHelper;
use \Minz\Tests\ResponseAsserts;
use \tests\FakerHelper;

#[\PHPUnit\Framework\Attributes\BeforeClass]
public static function loadApplication(): void
Expand Down
4 changes: 2 additions & 2 deletions tests/cli/UrlsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

class UrlsTest extends \PHPUnit\Framework\TestCase
{
use \tests\FakerHelper;
use \tests\MockHttpHelper;
use \Minz\Tests\ApplicationHelper;
use \Minz\Tests\ResponseAsserts;
use \tests\FakerHelper;
use \tests\MockHttpHelper;

#[\PHPUnit\Framework\Attributes\BeforeClass]
public static function loadApplication(): void
Expand Down
6 changes: 3 additions & 3 deletions tests/cli/UsersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

class UsersTest extends \PHPUnit\Framework\TestCase
{
use \tests\FakerHelper;
use \tests\InitializerHelper;
use \tests\MockHttpHelper;
use \Minz\Tests\ApplicationHelper;
use \Minz\Tests\InitializerHelper;
use \Minz\Tests\ResponseAsserts;
use \Minz\Tests\TimeHelper;
use \tests\FakerHelper;
use \tests\MockHttpHelper;

#[\PHPUnit\Framework\Attributes\BeforeClass]
public static function loadApplication(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/controllers/AssetsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

class AssetsTest extends \PHPUnit\Framework\TestCase
{
use \tests\InitializerHelper;
use \Minz\Tests\ApplicationHelper;
use \Minz\Tests\InitializerHelper;
use \Minz\Tests\ResponseAsserts;

public function testShowReturnsTheAsset(): void
Expand Down
6 changes: 3 additions & 3 deletions tests/controllers/BookmarksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

class BookmarksTest extends \PHPUnit\Framework\TestCase
{
use \tests\LoginHelper;
use \tests\FakerHelper;
use \tests\InitializerHelper;
use \Minz\Tests\ApplicationHelper;
use \Minz\Tests\InitializerHelper;
use \Minz\Tests\ResponseAsserts;
use \tests\FakerHelper;
use \tests\LoginHelper;

public function testIndexRendersCorrectly(): void
{
Expand Down
6 changes: 3 additions & 3 deletions tests/controllers/CollectionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

class CollectionsTest extends \PHPUnit\Framework\TestCase
{
use \tests\FakerHelper;
use \tests\InitializerHelper;
use \tests\LoginHelper;
use \Minz\Tests\ApplicationHelper;
use \Minz\Tests\InitializerHelper;
use \Minz\Tests\ResponseAsserts;
use \tests\FakerHelper;
use \tests\LoginHelper;

public function testIndexRedirectsToLinks(): void
{
Expand Down
4 changes: 2 additions & 2 deletions tests/controllers/DiscoveryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

class DiscoveryTest extends \PHPUnit\Framework\TestCase
{
use \tests\FakerHelper;
use \tests\InitializerHelper;
use \Minz\Tests\ApplicationHelper;
use \Minz\Tests\InitializerHelper;
use \Minz\Tests\ResponseAsserts;
use \tests\FakerHelper;

public function testShowRendersCorrectly(): void
{
Expand Down
6 changes: 3 additions & 3 deletions tests/controllers/ExportationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

class ExportationsTest extends \PHPUnit\Framework\TestCase
{
use \tests\LoginHelper;
use \tests\FakerHelper;
use \tests\InitializerHelper;
use \Minz\Tests\ApplicationHelper;
use \Minz\Tests\InitializerHelper;
use \Minz\Tests\ResponseAsserts;
use \tests\FakerHelper;
use \tests\LoginHelper;

#[\PHPUnit\Framework\Attributes\BeforeClass]
public static function setJobAdapterToDatabase(): void
Expand Down
6 changes: 3 additions & 3 deletions tests/controllers/FeedsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

class FeedsTest extends \PHPUnit\Framework\TestCase
{
use \Minz\Tests\ApplicationHelper;
use \Minz\Tests\InitializerHelper;
use \Minz\Tests\ResponseAsserts;
use \tests\FakerHelper;
use \tests\InitializerHelper;
use \tests\LoginHelper;
use \tests\MockHttpHelper;
use \Minz\Tests\ApplicationHelper;
use \Minz\Tests\ResponseAsserts;

#[\PHPUnit\Framework\Attributes\Before]
public function emptyCachePath(): void
Expand Down
6 changes: 3 additions & 3 deletions tests/controllers/GroupsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

class GroupsTest extends \PHPUnit\Framework\TestCase
{
use \tests\LoginHelper;
use \tests\FakerHelper;
use \tests\InitializerHelper;
use \Minz\Tests\ApplicationHelper;
use \Minz\Tests\InitializerHelper;
use \Minz\Tests\ResponseAsserts;
use \tests\FakerHelper;
use \tests\LoginHelper;

public function testEditRendersCorrectly(): void
{
Expand Down
6 changes: 3 additions & 3 deletions tests/controllers/ImportationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

class ImportationsTest extends \PHPUnit\Framework\TestCase
{
use \tests\FakerHelper;
use \tests\InitializerHelper;
use \tests\LoginHelper;
use \Minz\Tests\ApplicationHelper;
use \Minz\Tests\InitializerHelper;
use \Minz\Tests\ResponseAsserts;
use \tests\FakerHelper;
use \tests\LoginHelper;

public function testDeleteDeletesImportationAndRedirects(): void
{
Expand Down
Loading
Loading