Skip to content

Commit 6575bb9

Browse files
authored
Merge pull request #424 from reliforp/test-with-docker
Test mutiple target PHP versions via docker
2 parents d83f8a5 + e1500ef commit 6575bb9

File tree

23 files changed

+662
-236
lines changed

23 files changed

+662
-236
lines changed

.github/workflows/phpunit.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ jobs:
4949
- name: Run test suite
5050
run: |
5151
mkdir -p build/logs
52-
./vendor/bin/phpunit --coverage-clover build/logs/clover.xml
52+
composer test-for-ci
53+
54+
- name: Fix absolute paths in the coverage report
55+
run: sed -i "s|<file name=\"/app/|<file name=\"`pwd`/|g" build/logs/clover.xml
5356

5457
- name: Send to coveralls
5558
env:

Dockerfile-dev

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM php:8.1-cli
2+
3+
RUN apt-get update && apt-get install -y \
4+
libffi-dev \
5+
libzip-dev \
6+
&& docker-php-ext-install ffi \
7+
&& docker-php-ext-install pcntl \
8+
&& docker-php-ext-install zip \
9+
&& pecl install pcov \
10+
&& docker-php-ext-enable pcov \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
RUN apt-get update -y \
14+
&& apt-get install -y ca-certificates curl gnupg \
15+
&& install -m 0755 -d /etc/apt/keyrings \
16+
&& curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg \
17+
&& chmod a+r /etc/apt/keyrings/docker.gpg \
18+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(. /etc/os-release && echo $VERSION_CODENAME) stable" \
19+
| tee /etc/apt/sources.list.d/docker.list > /dev/null \
20+
&& apt-get update -y \
21+
&& apt-get install -y docker-ce-cli \
22+
&& rm -rf /var/lib/apt/lists/*
23+
24+
COPY --from=composer /usr/bin/composer /usr/bin/composer
25+
26+
WORKDIR /app
27+
COPY . .
28+
29+
RUN composer install
30+
31+
CMD ["php", "vendor/bin/phpunit", "--colors=always", "--testdox", "--coverage-text", "--coverage-clover=coverage.xml", "--coverage-html=coverage"]

composer.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,22 @@
4848
},
4949
"autoload-dev": {
5050
"psr-4": {
51-
"Reli\\": "tests"
51+
"Reli\\": "tests",
52+
"Reli\\Command\\": "tests/Command/CommandEnumeratorTestData"
5253
}
5354
},
5455
"bin": [
5556
"reli"
5657
],
5758
"scripts": {
5859
"test": [
59-
"phpunit"
60+
"docker-compose run reli-test"
61+
],
62+
"test-with-coverage": [
63+
"docker-compose run reli-test-with-coverage"
64+
],
65+
"test-for-ci": [
66+
"docker-compose run reli-test-for-ci"
6067
],
6168
"psalm": [
6269
"psalm.phar"

docker-compose.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
version: '3.9'
2+
services:
3+
reli-test:
4+
build:
5+
context: .
6+
dockerfile: Dockerfile-dev
7+
pid: "host"
8+
cap_add:
9+
- SYS_PTRACE
10+
security_opt:
11+
- seccomp:unconfined
12+
volumes:
13+
- .:/app
14+
- /var/run/docker.sock:/var/run/docker.sock
15+
- /tmp/reli-test:/tmp/reli-test
16+
container_name: reli-test
17+
command: ["vendor/bin/phpunit" , "--colors=always", "--testdox"]
18+
reli-test-with-coverage:
19+
build:
20+
context: .
21+
dockerfile: Dockerfile-dev
22+
pid: "host"
23+
cap_add:
24+
- SYS_PTRACE
25+
security_opt:
26+
- seccomp:unconfined
27+
volumes:
28+
- .:/app
29+
- /var/run/docker.sock:/var/run/docker.sock
30+
- /tmp/reli-test:/tmp/reli-test
31+
- ./build:/app/build
32+
container_name: reli-test
33+
command: ["vendor/bin/phpunit" , "--colors=always", "--testdox", "--coverage-clover", "build/logs/clover.xml"]
34+
reli-test-for-ci:
35+
build:
36+
context: .
37+
dockerfile: Dockerfile-dev
38+
pid: "host"
39+
cap_add:
40+
- SYS_PTRACE
41+
security_opt:
42+
- seccomp:unconfined
43+
volumes:
44+
- .:/app
45+
- /var/run/docker.sock:/var/run/docker.sock
46+
- /tmp/reli-test:/tmp/reli-test
47+
- ./build:/app/build
48+
container_name: reli-test
49+
command: ["vendor/bin/phpunit" , "--coverage-clover", "build/logs/clover.xml"]

src/Lib/PhpInternals/Headers/v70.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,17 @@ struct _zend_resource {
167167
void *ptr;
168168
};
169169

170+
// zend_compile.h
171+
typedef struct _zend_property_info {
172+
uint32_t offset; /* property offset for object properties or
173+
property index for static properties */
174+
uint32_t flags;
175+
zend_string *name;
176+
zend_string *doc_comment;
177+
zend_class_entry *ce;
178+
} zend_property_info;
179+
180+
// zend_types.h
170181
struct _zend_reference {
171182
zend_refcounted_h gc;
172183
zval val;

src/Lib/PhpInternals/Headers/v71.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,17 @@ struct _zend_resource {
169169
void *ptr;
170170
};
171171

172+
// zend_compile.h
173+
typedef struct _zend_property_info {
174+
uint32_t offset; /* property offset for object properties or
175+
property index for static properties */
176+
uint32_t flags;
177+
zend_string *name;
178+
zend_string *doc_comment;
179+
zend_class_entry *ce;
180+
} zend_property_info;
181+
182+
// zend_types.h
172183
struct _zend_reference {
173184
zend_refcounted_h gc;
174185
zval val;

src/Lib/PhpInternals/Headers/v72.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,17 @@ struct _zend_resource {
171171

172172
typedef uintptr_t zend_type;
173173

174+
// zend_compile.h
175+
typedef struct _zend_property_info {
176+
uint32_t offset; /* property offset for object properties or
177+
property index for static properties */
178+
uint32_t flags;
179+
zend_string *name;
180+
zend_string *doc_comment;
181+
zend_class_entry *ce;
182+
} zend_property_info;
183+
184+
// zend_types.h
174185
struct _zend_reference {
175186
zend_refcounted_h gc;
176187
zval val;

src/Lib/PhpInternals/Headers/v73.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,17 @@ struct _zend_resource {
168168

169169
typedef uintptr_t zend_type;
170170

171+
// zend_compile.h
172+
typedef struct _zend_property_info {
173+
uint32_t offset; /* property offset for object properties or
174+
property index for static properties */
175+
uint32_t flags;
176+
zend_string *name;
177+
zend_string *doc_comment;
178+
zend_class_entry *ce;
179+
} zend_property_info;
180+
181+
// zend_types.h
171182
struct _zend_reference {
172183
zend_refcounted_h gc;
173184
zval val;

src/Lib/PhpInternals/Types/Zend/V74/ZendArray.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,37 @@ public function __get(string $field_name): mixed
3333
};
3434
}
3535

36+
public function dumpFlags(): string
37+
{
38+
$flags = $this->flags;
39+
$flag_names = [];
40+
if ($flags & ((1 << 0) | (1 << 1))) {
41+
$flag_names[] = 'HASH_FLAG_CONSISTENCY';
42+
}
43+
if ($flags & (1 << 2)) {
44+
$flag_names[] = 'HASH_FLAG_PACKED';
45+
}
46+
if ($flags & (1 << 3)) {
47+
$flag_names[] = 'HASH_FLAG_UNINITIALIZED';
48+
}
49+
if ($flags & (1 << 4)) {
50+
$flag_names[] = 'HASH_FLAG_STATIC_KEYS';
51+
}
52+
if ($flags & (1 << 5)) {
53+
$flag_names[] = 'HASH_FLAG_HAS_EMPTY_IND';
54+
}
55+
if ($flags & (1 << 6)) {
56+
$flag_names[] = 'HASH_FLAG_ALLOW_COW_VIOLATION';
57+
}
58+
59+
return implode(' | ', $flag_names);
60+
}
61+
62+
public function isUninitialized(): bool
63+
{
64+
return (bool)($this->flags & (1 << 3));
65+
}
66+
3667
public function getDataSize(): int
3768
{
3869
return $this->nTableSize * self::BUCKET_SIZE_IN_BYTES;

src/Lib/PhpInternals/Types/Zend/ZendArray.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ public static function fromCastedCData(CastedCData $casted_cdata, Pointer $point
351351
return new static($casted_cdata, $pointer);
352352
}
353353

354+
/** @return Pointer<ZendArray> */
354355
public function getPointer(): Pointer
355356
{
356357
return $this->pointer;

0 commit comments

Comments
 (0)