Skip to content

Commit c41752f

Browse files
authored
test(github): Make PHPunit faster by using SQLite in memory and siabling Xdebug (#1138)
1 parent 1c11ec4 commit c41752f

1 file changed

Lines changed: 35 additions & 15 deletions

File tree

.github/workflows/testing.yml

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,9 @@ on:
77
jobs:
88
drupal:
99
name: Drupal ${{ matrix.drupal-core }} (PHP ${{ matrix.php-versions }})
10-
runs-on: ubuntu-latest
11-
services:
12-
mysql:
13-
image: mysql:5.7
14-
env:
15-
MYSQL_ALLOW_EMPTY_PASSWORD: false
16-
MYSQL_ROOT_PASSWORD: graphql
17-
MYSQL_DATABASE: graphql
18-
ports:
19-
- 3306/tcp
20-
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
10+
runs-on: ubuntu-20.04
11+
env:
12+
extensions: mbstring, xml, pdo_sqlite, gd, opcache
2113
strategy:
2214
fail-fast: false
2315
matrix:
@@ -33,20 +25,42 @@ jobs:
3325
with:
3426
repository: drupal/drupal
3527
ref: ${{ matrix.drupal-core }}
28+
3629
- name: Checkout graphql module
3730
uses: actions/checkout@v2
3831
with:
3932
path: modules/graphql
33+
34+
- name: Setup PHP extension cache
35+
id: extcache
36+
uses: shivammathur/cache-extensions@v1
37+
with:
38+
php-version: ${{ matrix.php-versions }}
39+
extensions: ${{ env.extensions }}
40+
# Ideally this would be based on env.extensions, how can we make a
41+
# hash out of that?
42+
key: cache-v1
43+
44+
- name: Cache PHP extensions
45+
uses: actions/cache@v2
46+
with:
47+
path: ${{ steps.extcache.outputs.dir }}
48+
key: ${{ steps.extcache.outputs.key }}
49+
restore-keys: ${{ steps.extcache.outputs.key }}
50+
4051
- name: Setup PHP, with composer and extensions
4152
uses: shivammathur/setup-php@v2
4253
with:
4354
php-version: ${{ matrix.php-versions }}
44-
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql
45-
- name: Start mysql service
46-
run: sudo /etc/init.d/mysql start
55+
# Disable Xdebug for better performance.
56+
coverage: none
57+
extensions: ${{ env.extensions }}
58+
ini-values: opcache.enable_cli=1
59+
4760
- name: Get composer cache directory
4861
id: composercache
4962
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
63+
5064
- name: Cache composer dependencies
5165
uses: actions/cache@v2
5266
with:
@@ -55,10 +69,12 @@ jobs:
5569
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
5670
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
5771
restore-keys: ${{ runner.os }}-composer-
72+
5873
- name: Install Drupal core dependencies
5974
run: |
6075
composer install --no-progress --prefer-dist --optimize-autoloader
6176
composer --no-interaction run-script drupal-phpunit-upgrade
77+
6278
- name: Install GraphQL dependencies
6379
run: composer --no-interaction --no-progress require \
6480
webonyx/graphql-php:^14.3 \
@@ -69,22 +85,26 @@ jobs:
6985
phpstan/phpstan-deprecation-rules:^0.12.2 \
7086
jangregor/phpstan-prophecy:^0.8 \
7187
phpstan/phpstan-phpunit:^0.12
88+
7289
# We install Coder separately because updating did not work in the local
7390
# Drupal vendor dir.
7491
- name: Install Coder
7592
run: |
7693
mkdir coder
7794
cd coder
7895
composer require drupal/coder:8.3.12 --no-interaction --no-progress
96+
7997
- name: Run PHPUnit
8098
run: |
8199
cp modules/graphql/phpunit.xml.dist core/phpunit.xml
82100
./vendor/bin/phpunit --configuration core/phpunit.xml modules/graphql
83101
env:
84-
SIMPLETEST_DB: mysql://root:graphql@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/graphql
102+
SIMPLETEST_DB: "sqlite://localhost/:memory:"
103+
85104
- name: Run PHPStan
86105
run: |
87106
cd modules/graphql && ../../vendor/bin/phpstan analyse
107+
88108
- name: Run PHPCS
89109
run: |
90110
./coder/vendor/bin/phpcs --config-set installed_paths ../../drupal/coder/coder_sniffer

0 commit comments

Comments
 (0)