Skip to content

Commit 4064237

Browse files
authored
ci: pullrequest action definitions with test-harness support (#16)
Signed-off-by: Tom Carrio <[email protected]>
1 parent 7d7f1d2 commit 4064237

File tree

6 files changed

+104
-12
lines changed

6 files changed

+104
-12
lines changed

.github/workflows/pullrequest.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
6+
name: PR
7+
8+
on:
9+
pull_request:
10+
branches: [ main ]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
operating-system: [ubuntu-latest]
21+
php-version: ['7.4', '8.0', '8.1']
22+
23+
steps:
24+
- uses: actions/checkout@v3
25+
with:
26+
submodules: true
27+
fetch-depth: 0
28+
29+
- name: Setup PHP
30+
uses: shivammathur/setup-php@v2
31+
with:
32+
php-version: ${{ matrix.php-version }}
33+
coverage: xdebug
34+
extensions: ast
35+
36+
- name: Validate composer.json and composer.lock
37+
run: composer validate
38+
39+
- name: Cache Composer packages
40+
id: root-composer-cache
41+
uses: actions/cache@v3
42+
with:
43+
path: vendor
44+
key: ${{ runner.os }}-${{ matrix.php-version }}-php-${{ hashFiles('composer.json') }}
45+
restore-keys: |
46+
${{ runner.os }}-${{ matrix.php-version }}-php-
47+
48+
- name: Install dependencies
49+
if: steps.root-composer-cache.outputs.cache-hit != 'true'
50+
run: composer install --prefer-dist --no-progress --no-suggest
51+
52+
- name: Check Style
53+
run: vendor/bin/phpcs
54+
55+
- name: Run Psalm
56+
run: vendor/bin/psalm --output-format=github --php-version=${{ matrix.php-version }}
57+
58+
- name: Run Phpstan
59+
run: vendor/bin/phpstan analyse --error-format=github
60+
61+
- name: Run PHPUnit (unit tests)
62+
run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover --testsuite unit
63+
64+
- name: Validate composer.json and composer.lock
65+
working-directory: integration
66+
run: composer validate
67+
68+
- name: Prepare test-harness
69+
working-directory: integration
70+
run: |
71+
git submodule update --init --recursive
72+
cp ./test-harness/features/*.feature ./features/
73+
74+
- name: Cache Composer packages
75+
id: behat-composer-cache
76+
uses: actions/cache@v3
77+
with:
78+
path: integration/vendor
79+
key: ${{ runner.os }}-${{ matrix.php-version }}-php-${{ hashFiles('integration/composer.json') }}
80+
restore-keys: |
81+
${{ runner.os }}-${{ matrix.php-version }}-php-
82+
83+
- name: Install dependencies
84+
working-directory: integration
85+
if: steps.behat-composer-cache.outputs.cache-hit != 'true'
86+
run: composer install --prefer-dist --no-progress --no-suggest
87+
88+
- name: Start test-harness container
89+
run: docker run --rm -d -p 8013:8013 ghcr.io/open-feature/flagd-testbed:latest
90+
91+
- name: Run Behat (integration tests)
92+
working-directory: integration
93+
run: vendor/bin/behat

.tool-versions

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
php 7.4.30
1+
# php 7.4.30
2+
# php 8.0.24
3+
php 8.1.11

integration/composer.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,6 @@
2626
"phpunit/phpunit": "^9.5"
2727
},
2828
"repositories": [
29-
{
30-
"type": "path",
31-
"url": "../../openfeature-php-sdk-contrib/src/Flagd",
32-
"options": {
33-
"versions": {
34-
"open-feature/flagd-provider": "0.0.2"
35-
}
36-
}
37-
},
3829
{
3930
"type": "path",
4031
"url": "../",

phpcs.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
<!-- Ignore this for PHP 7.4 -->
2525
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint"/>
26+
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint"/>
2627
</rule>
2728

2829
</ruleset>

src/implementation/hooks/HookHints.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use OpenFeature\interfaces\hooks\HookHints as HookHintsInterface;
99

1010
use function array_keys;
11+
use function key_exists;
1112

1213
class HookHints implements HookHintsInterface
1314
{
@@ -19,7 +20,11 @@ class HookHints implements HookHintsInterface
1920
*/
2021
public function get(string $key)
2122
{
22-
return $this->hints[$key];
23+
if (key_exists($key, $this->hints)) {
24+
return $this->hints[$key];
25+
}
26+
27+
return null;
2328
}
2429

2530
/**

tests/unit/OpenFeatureAPITest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function testApiCanHaveProviderSet(): void
8080
$actualProvider = $api->getProvider();
8181

8282
$this->assertInstanceOf(Provider::class, $actualProvider);
83-
$this->assertInstanceOf(get_class($provider), $actualProvider);
83+
$this->assertInstanceOf(get_class($provider), $actualProvider); // phpcs:ignore
8484
}
8585

8686
/**

0 commit comments

Comments
 (0)