Skip to content

Commit bbf4e29

Browse files
Merge pull request #17421 from MauricioFauth/mutation-tests-workflow
Improve mutation tests workflow
2 parents 8ecf99a + 38564b5 commit bbf4e29

3 files changed

Lines changed: 35 additions & 38 deletions

File tree

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
1+
# https://docs.github.com/en/actions
2+
13
name: Mutation tests
24

35
on:
46
push:
5-
branches: [master]
7+
branches:
8+
- master
9+
paths:
10+
- '*/classes/**.php'
611
pull_request:
7-
branches: [master]
12+
branches:
13+
- master
14+
paths:
15+
- '*/classes/**.php'
816

917
permissions:
1018
contents: read
1119

1220
jobs:
13-
tests:
14-
name: Mutation tests with PHP ${{ matrix.php-version }}
21+
infection:
22+
name: Infection
1523
runs-on: ${{ matrix.operating-system }}
1624
strategy:
1725
matrix:
18-
php-version: ["8.0"]
19-
operating-system: [ubuntu-latest]
26+
php-version:
27+
- "8.1"
28+
operating-system:
29+
- ubuntu-latest
2030
steps:
2131
- name: Checkout code
2232
uses: actions/checkout@v3
2333

24-
- name: Fetch github.base_ref (for diffing)
25-
if: ${{ github.base_ref != '' }}
26-
run: |
27-
git fetch --depth=1 origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
28-
2934
- name: Install Gettext
30-
run: |
31-
sudo apt-get install -y gettext
35+
run: sudo apt-get install -y gettext
3236

3337
- name: Generate mo files
3438
run: ./scripts/generate-mo --quiet
@@ -43,31 +47,26 @@ jobs:
4347

4448
- name: Install Infection
4549
# The GPG key can be found at https://infection.github.io/guide/installation.html
46-
run: |
47-
phive --no-progress install --target ./build/tools --trust-gpg-keys C5095986493B4AA0 infection
50+
run: phive --no-progress install --target ./build/tools --trust-gpg-keys C5095986493B4AA0 infection
4851

4952
- name: Install Composer dependencies
50-
uses: ramsey/composer-install@v1
53+
uses: ramsey/composer-install@v2
5154
with:
5255
dependency-versions: highest
5356

5457
- name: Collect coverage report
55-
run: |
56-
composer run phpunit -- --testsuite unit --stop-on-failure
58+
run: composer run phpunit -- --testsuite unit --stop-on-failure
5759

58-
- name: Infection
59-
if: ${{ github.base_ref != '' }}
60+
- name: Run Infection for changed files only
61+
if: github.event_name == 'pull_request'
6062
run: |
61-
CHANGED_FILES=$(git diff origin/$GITHUB_BASE_REF --diff-filter=AM --name-only | grep libraries/classes/ | paste -sd "," -);
62-
./build/tools/infection -j$(nproc) --skip-initial-tests --no-interaction --no-progress --coverage=build/logs \
63-
--ignore-msi-with-no-mutations \
64-
--filter=$CHANGED_FILES
65-
env:
66-
INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }}
63+
git fetch --depth=1 origin $GITHUB_BASE_REF
64+
./build/tools/infection -j$(nproc) --git-diff-lines --git-diff-base=origin/$GITHUB_BASE_REF \
65+
--logger-github --ignore-msi-with-no-mutations --only-covered \
66+
--skip-initial-tests --coverage=build/logs --no-interaction --no-progress
6767
68-
- name: Infection
69-
if: ${{ github.base_ref == '' }}
70-
run: |
71-
./build/tools/infection -j$(nproc) --skip-initial-tests --no-interaction --no-progress --coverage=build/logs
68+
- name: Run Infection
69+
if: github.event_name == 'push'
7270
env:
7371
INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }}
72+
run: ./build/tools/infection -j$(nproc) --skip-initial-tests --coverage=build/logs --no-interaction --no-progress

libraries/classes/Controllers/Table/RecentFavoriteController.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use PhpMyAdmin\Controllers\Sql\SqlController;
99
use PhpMyAdmin\RecentFavoriteTable;
1010

11+
use function is_string;
12+
1113
/**
1214
* Browse recent and favorite tables chosen from navigation.
1315
*/
@@ -17,9 +19,11 @@ public function __invoke(): void
1719
{
1820
$GLOBALS['containerBuilder'] = $GLOBALS['containerBuilder'] ?? null;
1921

20-
RecentFavoriteTable::getInstance('recent')->removeIfInvalid($_REQUEST['db'], $_REQUEST['table']);
22+
$db = isset($_REQUEST['db']) && is_string($_REQUEST['db']) ? $_REQUEST['db'] : '';
23+
$table = isset($_REQUEST['table']) && is_string($_REQUEST['table']) ? $_REQUEST['table'] : '';
2124

22-
RecentFavoriteTable::getInstance('favorite')->removeIfInvalid($_REQUEST['db'], $_REQUEST['table']);
25+
RecentFavoriteTable::getInstance('recent')->removeIfInvalid($db, $table);
26+
RecentFavoriteTable::getInstance('favorite')->removeIfInvalid($db, $table);
2327

2428
/** @var SqlController $controller */
2529
$controller = $GLOBALS['containerBuilder']->get(SqlController::class);

psalm-baseline.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3556,12 +3556,6 @@
35563556
</MixedArgument>
35573557
</file>
35583558
<file src="libraries/classes/Controllers/Table/RecentFavoriteController.php">
3559-
<MixedArgument occurrences="4">
3560-
<code>$_REQUEST['db']</code>
3561-
<code>$_REQUEST['db']</code>
3562-
<code>$_REQUEST['table']</code>
3563-
<code>$_REQUEST['table']</code>
3564-
</MixedArgument>
35653559
<PossiblyNullReference occurrences="1">
35663560
<code>get</code>
35673561
</PossiblyNullReference>

0 commit comments

Comments
 (0)