Skip to content

Commit da00c95

Browse files
authored
Feature/testing (#26)
* [Feature] [testing] Add user facade and start page tests, add github test ci * [Feature] [testing] Move tools to global composer file * [Feature] [testing] Optimize CI, add PHPStan dev dependency * [Feature] [testing] Cache composer and npm
1 parent f9bee7b commit da00c95

File tree

17 files changed

+405
-115
lines changed

17 files changed

+405
-115
lines changed

.env.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# define your env variables for the test env here
22
KERNEL_CLASS='App\Kernel'
33
APP_SECRET='$ecretf0rt3st'
4-
SYMFONY_DEPRECATIONS_HELPER=999999
4+
SYMFONY_DEPRECATIONS_HELPER=disabled
55
PANTHER_APP_ENV=panther
66
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
7+
DATABASE_URL="mysql://modular-symfony-template:modular-symfony-template@mysql_test:3306/modular-symfony-template?serverVersion=5.7"

.github/workflows/ci.yml

Lines changed: 85 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,103 @@ on:
99
workflow_dispatch:
1010

1111
jobs:
12-
ci:
12+
build:
1313
runs-on: ubuntu-latest
1414
steps:
1515

1616
- uses: actions/checkout@v2
1717

18-
- name: Setup PHP
19-
uses: shivammathur/setup-php@v2
18+
- name: Start docker compose stack
19+
run: docker-compose up -d
20+
21+
- name: Cache composer dependencies
22+
uses: actions/cache@v3
23+
id: composer-dependencies
2024
with:
21-
php-version: '8.0'
22-
tools: composer, phpstan, phpcs
23-
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite
25+
path: ./vendor
26+
key: ${{ runner.os }}-${{ hashFiles('composer.lock') }}
2427

25-
- name: Get composer cache directory
26-
id: composer-cache
27-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
28+
- name: Install composer dependencies
29+
run: docker-compose exec -T php-fpm composer install --no-progress --prefer-dist --optimize-autoloader
2830

29-
- name: Cache composer dependencies
30-
uses: actions/cache@v2
31+
- name: Cache npm packages
32+
uses: actions/cache@v3
33+
id: npm-packages
34+
with:
35+
path: ./node_modules
36+
key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}
37+
38+
- name: Install npm packages
39+
run: docker-compose run npm npm install
40+
41+
- name: Build frontends
42+
run: docker-compose run npm npm run build
43+
44+
- uses: actions/upload-artifact@v3
45+
with:
46+
name: frontend-build
47+
path: ./public/build/*
48+
49+
- name: Stop docker compose stack
50+
run: docker-compose down
51+
52+
quality:
53+
runs-on: ubuntu-latest
54+
needs: [build]
55+
steps:
56+
57+
- uses: actions/checkout@v2
58+
59+
- uses: actions/cache@v3
60+
id: composer-dependencies
3161
with:
32-
path: ${{ steps.composer-cache.outputs.dir }}
33-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
34-
restore-keys: ${{ runner.os }}-composer-
62+
path: ./vendor
63+
key: ${{ runner.os }}-${{ hashFiles('composer.lock') }}
64+
65+
- name: Start docker compose stack
66+
run: docker-compose up -d
67+
68+
- name: Run PHPCS
69+
run: docker-compose exec -T php-fpm vendor/bin/phpcs src
70+
71+
- name: Run PHPStan
72+
run: docker-compose exec -T php-fpm vendor/bin/phpstan analyse --level 5 src tests
73+
74+
- name: Stop docker compose stack
75+
run: docker-compose down
76+
77+
test:
78+
runs-on: ubuntu-latest
79+
needs: [build]
80+
steps:
3581

36-
- name: Install Composer dependencies
37-
run: composer install --no-progress --prefer-dist --optimize-autoloader
82+
- uses: actions/checkout@v2
3883

39-
- name: PHPCS
40-
run: phpcs src/
84+
- uses: actions/cache@v3
85+
id: composer-dependencies
86+
with:
87+
path: ./vendor
88+
key: ${{ runner.os }}-${{ hashFiles('composer.lock') }}
4189

42-
- name: PHPStan
43-
run: phpstan analyse --level 5 --no-progress src/
90+
- uses: actions/cache@v3
91+
id: npm-packages
92+
with:
93+
path: ./node_modules
94+
key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}
4495

45-
- name: Codesniffer
46-
uses: pipeline-components/php-codesniffer@v0.12.3
96+
- uses: actions/download-artifact@v3
4797
with:
48-
directory: src/
98+
name: frontend-build
99+
path: ./public/build
100+
101+
- name: Start docker compose stack
102+
run: docker-compose up -d
103+
104+
- name: Migrate test database
105+
run: sleep 10 && docker-compose exec -T php-fpm php bin/console --env=test d:m:m --no-interaction
106+
107+
- name: Run tests
108+
run: docker-compose exec -T php-fpm php bin/phpunit
49109

50-
#- name: Deptrac
51-
# uses: docker://smoench/deptrac-action:latest
52-
# with:
53-
# args: analyse depfile.yaml
110+
- name: Stop docker compose stack
111+
run: docker-compose down

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,8 @@
4343
npm-debug.log
4444
yarn-error.log
4545
###< symfony/webpack-encore-bundle ###
46+
47+
###> squizlabs/php_codesniffer ###
48+
/.phpcs-cache
49+
/phpcs.xml
50+
###< squizlabs/php_codesniffer ###

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@
5050
"twig/twig": "^2.12|^3.0"
5151
},
5252
"require-dev": {
53+
"dama/doctrine-test-bundle": "^7.1",
54+
"phpstan/phpstan": "^1.7",
5355
"phpunit/phpunit": "^9.5",
56+
"squizlabs/php_codesniffer": "^3.6",
5457
"symfony/browser-kit": "6.0.*",
5558
"symfony/css-selector": "6.0.*",
5659
"symfony/debug-bundle": "6.0.*",

composer.lock

Lines changed: 183 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/bundles.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@
1515
EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true],
1616
Symfony\UX\Chartjs\ChartjsBundle::class => ['all' => true],
1717
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
18+
DAMA\DoctrineTestBundle\DAMADoctrineTestBundle::class => ['test' => true],
1819
];
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dama_doctrine_test:
2+
enable_static_connection: true
3+
enable_static_meta_data_cache: true
4+
enable_static_query_cache: true

0 commit comments

Comments
 (0)