Skip to content

Commit 8871406

Browse files
authored
Merge pull request #1 from DEVizzent/add_workflow
Add gitlab workflow to test library in different environments
2 parents 0e1fc5d + fa957ad commit 8871406

File tree

9 files changed

+115
-12
lines changed

9 files changed

+115
-12
lines changed

.github/workflows/ci.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Tests
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
7+
tests:
8+
name: Tests
9+
runs-on: ubuntu-latest
10+
env:
11+
MOCKSERVER_URL: 'http://localhost:1080'
12+
services:
13+
mockserver:
14+
image: mockserver/mockserver
15+
ports:
16+
- "1080:1080"
17+
env:
18+
MOCKSERVER_INITIALIZATION_JSON_PATH: /docker/mockserver/expectations/**.json
19+
MOCKSERVER_LOG_LEVEL: WARN
20+
continue-on-error: ${{ matrix.experimental }}
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
dependencies:
25+
- "lowest"
26+
- "highest"
27+
php:
28+
- '7.4'
29+
- '8.0'
30+
experimental:
31+
- false
32+
include:
33+
- php: "8.1"
34+
composer-options: "--ignore-platform-reqs"
35+
experimental: true
36+
dependencies: "highest"
37+
- php: "8.2"
38+
composer-options: "--ignore-platform-reqs"
39+
experimental: true
40+
dependencies: "highest"
41+
steps:
42+
- name: Set up PHP
43+
uses: shivammathur/setup-php@2.24.0
44+
with:
45+
php-version: ${{ matrix.php }}
46+
extensions: intl, mbstring
47+
tools: "composer:v2"
48+
49+
- name: Checkout code
50+
uses: actions/checkout@v2
51+
52+
- name: "Install lowest dependencies"
53+
if: ${{ matrix.dependencies == 'lowest' }}
54+
run: composer update --prefer-lowest --no-interaction --no-progress --no-suggest ${{ matrix.composer-options }}
55+
56+
- name: "Install highest dependencies"
57+
if: ${{ matrix.dependencies == 'highest' }}
58+
run: composer update --no-interaction --no-progress --no-suggest ${{ matrix.composer-options }}
59+
60+
- name: "Run unit tests"
61+
run: ./vendor/bin/phpunit -c phpunit.xml
62+
63+
cs:
64+
name: Codestyle check on PHP 7.4
65+
runs-on: ubuntu-latest
66+
steps:
67+
- name: Set up PHP
68+
uses: shivammathur/setup-php@2.24.0
69+
with:
70+
php-version: 7.4
71+
72+
- name: Checkout code
73+
uses: actions/checkout@v2
74+
75+
- name: Download dependencies
76+
run: composer update --no-interaction --prefer-dist --optimize-autoloader --prefer-stable
77+
78+
- name: Run tests
79+
run: ./vendor/bin/phpcs
80+
81+
static-analysis:
82+
name: Static analysis
83+
runs-on: ubuntu-latest
84+
strategy:
85+
matrix:
86+
php:
87+
- '7.4'
88+
steps:
89+
- name: Set up PHP
90+
uses: shivammathur/setup-php@2.24.0
91+
with:
92+
php-version: ${{ matrix.php }}
93+
94+
- name: Checkout code
95+
uses: actions/checkout@v2
96+
97+
- name: Download dependencies
98+
run: composer update --no-interaction --prefer-dist --optimize-autoloader --prefer-stable
99+
100+
- name: Run PHPStan
101+
run: ./vendor/bin/phpstan analyse --memory-limit 512M

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"php": "7.4.*||8.*",
2626
"guzzlehttp/guzzle": "^7.0",
2727
"codeception/codeception": "4.*||5.*",
28-
"phpunit/phpunit": "8.* || 9.*"
28+
"phpunit/phpunit": "^8.5 || 9.*"
2929
},
3030
"require-dev": {
3131
"phpmd/phpmd": "2.*",

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ services:
55
build:
66
dockerfile: docker/php/Dockerfile
77
context: .
8+
environment:
9+
MOCKSERVER_URL: 'http://mockserver:1080'
810
volumes:
911
- .:/app
1012
tty: true

phpstan-baseline.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
parameters:
22
ignoreErrors:
33
-
4-
message: "#^Method DEVizzent\\\\CodeceptionMockServerHelper\\\\MockServerHelper\\:\\:\\_beforeSuite\\(\\) has parameter \\$settings with no type specified\\.$#"
4+
message: "#^Method .*_beforeSuite\\(\\) has parameter \\$settings.*\\.$#"
55
count: 1
66
path: src/MockServerHelper.php

src/Config/ExpectationsPath.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ExpectationsPath
1414

1515
public function __construct(string $path = '')
1616
{
17-
if ('' === $path) {
17+
if ('' !== $path) {
1818
$this->set($path);
1919
}
2020
}
@@ -34,7 +34,7 @@ private function set(string $path): void
3434
*/
3535
public function getExpectationsFiles(): iterable
3636
{
37-
if ('' !== $this->path) {
37+
if ('' === $this->path) {
3838
return [];
3939
}
4040
if (!is_dir($this->path)) {

tests/Integration/NotMatchedRequestTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ private function initialize(string $notMatchedRequestConfig): void
2121
$this->sot = new MockServerHelper(
2222
$moduleContainer,
2323
[
24-
'url' => 'http://mockserver:1080',
24+
'url' => getenv('MOCKSERVER_URL'),
2525
'notMatchedRequest' => $notMatchedRequestConfig,
2626
'expectationsPath' => __DIR__ . '/../../docker/mockserver/expectations',
2727
]
2828
);
2929
$this->sot->_initialize();
3030
$this->sot->_beforeSuite();
31-
$this->client = new Client(['proxy' => 'http://mockserver:1080', 'verify' => false]);
31+
$this->client = new Client(['proxy' => getenv('MOCKSERVER_URL'), 'verify' => false]);
3232
$this->sot->clearMockServerLogs();
3333
}
3434

tests/Integration/SeeAllRequestWereMatchedTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ protected function initialize(string $notMatchedRequest): void
1818
{
1919
$moduleContainer = $this->createMock(ModuleContainer::class);
2020
$config = [
21-
'url' => 'http://mockserver:1080',
21+
'url' => getenv('MOCKSERVER_URL'),
2222
'notMatchedRequest' => $notMatchedRequest,
2323
'expectationsPath' => __DIR__ . '/../../docker/mockserver/expectations',
2424
];
2525
$this->sot = new MockServerHelper($moduleContainer, $config);
2626
$this->sot->_initialize();
2727
$this->sot->_beforeSuite();
28-
$this->client = new Client(['proxy' => 'http://mockserver:1080', 'verify' => false]);
28+
$this->client = new Client(['proxy' => getenv('MOCKSERVER_URL'), 'verify' => false]);
2929
$this->sot->clearMockServerLogs();
3030
}
3131

tests/Integration/SeeMockRequestWasCalledTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ protected function setUp(): void
1818
parent::setUp();
1919
$moduleContainer = $this->createMock(ModuleContainer::class);
2020
$config = [
21-
'url' => 'http://mockserver:1080',
21+
'url' => getenv('MOCKSERVER_URL'),
2222
'expectationsPath' => __DIR__ . '/../../docker/mockserver/expectations',
2323
];
2424
$this->sot = new MockServerHelper($moduleContainer, $config);
2525
$this->sot->_initialize();
2626
$this->sot->_beforeSuite();
27-
$this->client = new Client(['proxy' => 'http://mockserver:1080', 'verify' => false]);
27+
$this->client = new Client(['proxy' => getenv('MOCKSERVER_URL'), 'verify' => false]);
2828
$this->sot->clearMockServerLogs();
2929
}
3030

tests/Integration/SeeMockRequestWasNotCalledTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ protected function setUp(): void
1717
{
1818
parent::setUp();
1919
$config = [
20-
'url' => 'http://mockserver:1080',
20+
'url' => getenv('MOCKSERVER_URL'),
2121
'expectationsPath' => __DIR__ . '/../../docker/mockserver/expectations',
2222
];
2323
$moduleContainer = $this->createMock(ModuleContainer::class);
2424
$this->sot = new MockServerHelper($moduleContainer, $config);
2525
$this->sot->_initialize();
2626
$this->sot->_beforeSuite();
27-
$this->client = new Client(['proxy' => 'http://mockserver:1080', 'verify' => false]);
27+
$this->client = new Client(['proxy' => getenv('MOCKSERVER_URL'), 'verify' => false]);
2828
$this->sot->clearMockServerLogs();
2929
}
3030

0 commit comments

Comments
 (0)