Skip to content

Commit f191801

Browse files
authored
Use PHP 8.4 for tests and fix phpstan issue (#176)
* Use PHP 8.4 for tests and fix phpstan issue Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de> * Update actions Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de> * Migrate phpunit configuration Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de> --------- Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
1 parent 3f8e4ff commit f191801

File tree

5 files changed

+33
-49
lines changed

5 files changed

+33
-49
lines changed

.github/workflows/blackbox.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ jobs:
1111
name: Run BlackBox Tests
1212
steps:
1313
- name: Checkout code
14-
uses: actions/checkout@v2
14+
uses: actions/checkout@v4
1515

1616
- name: Cache dependencies
17-
uses: actions/cache@v2
17+
uses: actions/cache@v4
1818
with:
1919
path: ~/.composer/cache/files
2020
key: dependencies-blackbox
2121

2222
- name: Setup PHP
2323
uses: shivammathur/setup-php@v2
2424
with:
25-
php-version: 8.3
25+
php-version: 8.4
2626
coverage: none
2727

2828
- name: Install dependencies

.github/workflows/checks.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ jobs:
99
name: Code Checks
1010
steps:
1111
- name: Checkout code
12-
uses: actions/checkout@v2
12+
uses: actions/checkout@v4
1313

1414
- name: Cache dependencies
15-
uses: actions/cache@v2
15+
uses: actions/cache@v4
1616
with:
1717
path: ~/.composer/cache/files
1818
key: dependencies-code-checks
1919

2020
- name: Setup PHP
2121
uses: shivammathur/setup-php@v2
2222
with:
23-
php-version: 8.3
23+
php-version: 8.4
2424
coverage: none
2525

2626
- name: Install dependencies
@@ -34,16 +34,14 @@ jobs:
3434
fail-fast: false
3535
matrix:
3636
php:
37-
- "8.1"
38-
- "8.2"
39-
- "8.3"
37+
- "8.4"
4038
name: PHPStan on PHP ${{ matrix.php }}
4139
steps:
4240
- name: Checkout code
43-
uses: actions/checkout@v2
41+
uses: actions/checkout@v4
4442

4543
- name: Cache dependencies
46-
uses: actions/cache@v2
44+
uses: actions/cache@v4
4745
with:
4846
path: ~/.composer/cache/files
4947
key: dependencies-code-checks

.github/workflows/tests.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ on: [ push, pull_request ]
44

55
jobs:
66
test:
7-
runs-on: ${{ matrix.os }}
7+
runs-on: ubuntu-latest
88
strategy:
99
fail-fast: true
1010
matrix:
11-
os: [ ubuntu-latest ]
12-
php: [ 8.1, 8.2, 8.3 ]
13-
dependency-version: [ prefer-lowest, prefer-stable ]
11+
php: [ 8.1, 8.2, 8.3, 8.4 ]
1412
redis-version: [ 5, 6, 7 ]
1513

16-
name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} - ${{ matrix.redis-version }}
14+
name: P${{ matrix.php }} - Redis ${{ matrix.redis-version }}
1715

1816
# Service container with PostgreSQL
1917
services:
@@ -43,10 +41,10 @@ jobs:
4341

4442
steps:
4543
- name: Checkout code
46-
uses: actions/checkout@v2
44+
uses: actions/checkout@v4
4745

4846
- name: Cache dependencies
49-
uses: actions/cache@v2
47+
uses: actions/cache@v4
5048
with:
5149
path: ~/.composer/cache/files
5250
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
@@ -60,7 +58,7 @@ jobs:
6058
coverage: none
6159

6260
- name: Install dependencies
63-
run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
61+
run: composer update --prefer-dist --no-interaction --no-suggest
6462

6563
- name: Start Redis
6664
uses: supercharge/redis-github-action@1.1.0
@@ -87,4 +85,4 @@ jobs:
8785
TEST_PDO_DSN: 'pgsql:host=localhost;dbname=test'
8886
TEST_PDO_USERNAME: 'root'
8987
TEST_PDO_PASSWORD: 'root'
90-
run: vendor/bin/phpunit tests/Test/Prometheus/PDO
88+
run: vendor/bin/phpunit tests/Test/Prometheus/PDO

phpunit.xml.dist

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
3-
backupStaticAttributes="false"
4-
bootstrap="tests/bootstrap.php"
5-
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnError="false"
11-
stopOnFailure="false">
12-
13-
<testsuites>
14-
<testsuite name="Unit">
15-
<directory>./tests/Test/Prometheus</directory>
16-
</testsuite>
17-
</testsuites>
18-
19-
<filter>
20-
<whitelist processUncoveredFilesFromWhitelist="true">
21-
<directory suffix=".php">./src/Prometheus</directory>
22-
</whitelist>
23-
</filter>
24-
25-
<groups>
26-
<exclude>
27-
<group>Performance</group>
28-
</exclude>
29-
</groups>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="tests/bootstrap.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnError="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage processUncoveredFiles="true">
4+
<include>
5+
<directory suffix=".php">./src/Prometheus</directory>
6+
</include>
7+
</coverage>
8+
<testsuites>
9+
<testsuite name="Unit">
10+
<directory>./tests/Test/Prometheus</directory>
11+
</testsuite>
12+
</testsuites>
13+
<groups>
14+
<exclude>
15+
<group>Performance</group>
16+
</exclude>
17+
</groups>
3018
</phpunit>

src/Prometheus/Storage/PDO.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ protected function collectHistograms(): array
138138
sort($labels);
139139
foreach ($labels as $label_values) {
140140
$acc = 0;
141-
$decoded_values = json_decode($label_values, true); /** @phpstan-ignore-line */
141+
$decoded_values = json_decode($label_values, true);
142142
foreach ($data['buckets'] as $bucket) {
143143
$bucket = (string)$bucket;
144144
if (!isset($histogram_buckets[$label_values][$bucket])) {

0 commit comments

Comments
 (0)