Skip to content

Commit 6da7a04

Browse files
author
Greg Bowler
authored
Improvements to CI (#145)
* build: add http-client to keywork for packagist * test: get current tests passing * test: upgrade to latest phpunit * build: introduce propfunc * test: pass phpcs tests * test: pass phpmd tests * test: pass phpstan tests * ci: upgrade ci to use build matrix * ci: remove scrutinizer * build: update curl * ci: use composer version of phpstan * ci: phpstan level 6 * ci: use phpstan v3
1 parent b659a1a commit 6da7a04

26 files changed

+1594
-805
lines changed

.github/workflows/ci.yml

Lines changed: 111 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on: [push]
55
jobs:
66
composer:
77
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
php: [ 8.1, 8.2 ]
811

912
steps:
1013
- uses: actions/checkout@v3
@@ -15,7 +18,10 @@ jobs:
1518
path: /tmp/composer-cache
1619
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
1720

18-
- uses: php-actions/composer@v6
21+
- name: Composer install
22+
uses: php-actions/composer@v6
23+
with:
24+
php_version: ${{ matrix.php }}
1925

2026
- name: Archive build
2127
run: mkdir /tmp/github-actions/ && tar -cvf /tmp/github-actions/build.tar ./
@@ -28,7 +34,13 @@ jobs:
2834

2935
phpunit:
3036
runs-on: ubuntu-latest
31-
needs: [composer]
37+
needs: [ composer ]
38+
strategy:
39+
matrix:
40+
php: [ 8.1, 8.2 ]
41+
42+
outputs:
43+
coverage: ${{ steps.store-coverage.outputs.coverage_text }}
3244

3345
steps:
3446
- uses: actions/download-artifact@v3
@@ -41,15 +53,44 @@ jobs:
4153

4254
- name: PHP Unit tests
4355
uses: php-actions/phpunit@v3
56+
env:
57+
XDEBUG_MODE: cover
4458
with:
45-
php_version: 8.1
59+
php_version: ${{ matrix.php }}
4660
php_extensions: xdebug
47-
configuration: test/phpunit/phpunit.xml
48-
bootstrap: vendor/autoload.php
61+
coverage_text: _coverage/coverage.txt
62+
coverage_clover: _coverage/clover.xml
63+
64+
- name: Store coverage data
65+
uses: actions/upload-artifact@v3
66+
with:
67+
name: code-coverage
68+
path: _coverage
69+
70+
coverage:
71+
runs-on: ubuntu-latest
72+
needs: [ phpunit ]
73+
74+
steps:
75+
- uses: actions/checkout@v3
76+
77+
- uses: actions/download-artifact@v3
78+
with:
79+
name: code-coverage
80+
path: _coverage
81+
82+
- name: Output coverage
83+
run: cat "_coverage/coverage.txt"
84+
85+
- name: Upload to Codecov
86+
uses: codecov/codecov-action@v3
4987

5088
phpstan:
5189
runs-on: ubuntu-latest
52-
needs: [composer]
90+
needs: [ composer ]
91+
strategy:
92+
matrix:
93+
php: [ 8.1, 8.2 ]
5394

5495
steps:
5596
- uses: actions/download-artifact@v3
@@ -63,4 +104,68 @@ jobs:
63104
- name: PHP Static Analysis
64105
uses: php-actions/phpstan@v3
65106
with:
107+
php_version: ${{ matrix.php }}
66108
path: src/
109+
level: 6
110+
111+
phpmd:
112+
runs-on: ubuntu-latest
113+
needs: [ composer ]
114+
strategy:
115+
matrix:
116+
php: [ 8.1, 8.2 ]
117+
118+
steps:
119+
- uses: actions/download-artifact@v3
120+
with:
121+
name: build-artifact
122+
path: /tmp/github-actions
123+
124+
- name: Extract build archive
125+
run: tar -xvf /tmp/github-actions/build.tar ./
126+
127+
- name: PHP Mess Detector
128+
uses: php-actions/phpmd@v1
129+
with:
130+
php_version: ${{ matrix.php }}
131+
path: src/
132+
output: text
133+
ruleset: phpmd.xml
134+
135+
phpcs:
136+
runs-on: ubuntu-latest
137+
needs: [ composer ]
138+
strategy:
139+
matrix:
140+
php: [ 8.1, 8.2 ]
141+
142+
steps:
143+
- uses: actions/download-artifact@v3
144+
with:
145+
name: build-artifact
146+
path: /tmp/github-actions
147+
148+
- name: Extract build archive
149+
run: tar -xvf /tmp/github-actions/build.tar ./
150+
151+
- name: PHP Code Sniffer
152+
uses: php-actions/phpcs@v1
153+
with:
154+
php_version: ${{ matrix.php }}
155+
path: src/
156+
standard: phpcs.xml
157+
158+
remove_old_artifacts:
159+
runs-on: ubuntu-latest
160+
161+
steps:
162+
- name: Remove old artifacts for prior workflow runs on this repository
163+
env:
164+
GH_TOKEN: ${{ github.token }}
165+
run: |
166+
gh api "/repos/${{ github.repository }}/actions/artifacts?name=build-artifact" | jq ".artifacts[] | select(.name == \"build-artifact\") | .id" > artifact-id-list.txt
167+
while read id
168+
do
169+
echo -n "Deleting artifact ID $id ... "
170+
gh api --method DELETE /repos/${{ github.repository }}/actions/artifacts/$id && echo "Done"
171+
done <artifact-id-list.txt

.scrutinizer.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Asynchronous HTTP client with promises.
22

3-
Asynchronous HTTP client, [PSR-7 compatible][psr-7] implementation of the [Fetch Standard][fetch-standard] which defines requests, responses, and the process that binds them: _fetching_.
4-
5-
This repository provides a [_PHP-HTTP Client Implementation_][php-http-client] for standardised HTTP interoperability.
3+
Asynchronous HTTP client, implementation of the [Fetch Standard][fetch-standard] which defines requests, responses, and the process that binds them: _fetching_.
64

75
See also, the [JavaScript implementation][fetch-js] that ships as standard in all modern browsers.
86

@@ -11,10 +9,10 @@ See also, the [JavaScript implementation][fetch-js] that ships as standard in al
119
<a href="https://github.com/PhpGt/Fetch/actions" target="_blank">
1210
<img src="https://badge.status.php.gt/fetch-build.svg" alt="Build status" />
1311
</a>
14-
<a href="https://scrutinizer-ci.com/g/PhpGt/Fetch" target="_blank">
12+
<a href="https://app.codacy.com/gh/PhpGt/Fetch" target="_blank">
1513
<img src="https://badge.status.php.gt/fetch-quality.svg" alt="Code quality" />
1614
</a>
17-
<a href="https://scrutinizer-ci.com/g/PhpGt/Fetch" target="_blank">
15+
<a href="https://app.codecov.io/gh/PhpGt/Fetch" target="_blank">
1816
<img src="https://badge.status.php.gt/fetch-coverage.svg" alt="Code coverage" />
1917
</a>
2018
<a href="https://packagist.org/packages/PhpGt/Fetch" target="_blank">
@@ -75,31 +73,7 @@ $http->all()->then(function() {
7573
});
7674
```
7775

78-
## Example usage: HTTPlug PHP-HTTP Client & Asynchronous Client
79-
80-
```php
81-
<?php
82-
$http = new Gt\Fetch\Http();
83-
84-
$slowRequest = new Request("GET", "http://slow.example.com");
85-
$fastRequest = new Request("GET", "http://fast.example.com");
86-
87-
// Send the slow request asynchronously (returns a Http\Promise)
88-
$http->sendAsyncRequest($slowRequest)
89-
->then(function(ResponseInterface $response) {
90-
echo $response->getBody();
91-
});
92-
93-
// Perform fast request synchronously (block until response ready)
94-
$response = $http->sendRequest($fastRequest);
95-
96-
// Wait for any asynchronous requests to be completed.
97-
$http->wait();
98-
```
99-
10076
For more extensive examples, check out the code in the [example directory](/example).
10177

102-
[psr-7]: http://www.php-fig.org/psr/psr-7/
10378
[fetch-standard]: https://fetch.spec.whatwg.org/
10479
[fetch-js]: https://developer.mozilla.org/en/docs/Web/API/Fetch_API
105-
[php-http-client]: http://docs.php-http.org/en/latest/index.html

composer.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@
99
"ext-curl": "*",
1010
"ext-json": "*",
1111
"phpgt/async": "dev-master",
12-
"phpgt/promise": "^v2.2.1",
13-
"phpgt/http": "^v1.1",
14-
"phpgt/curl": "^v3.0",
15-
"phpgt/json": "^v1.1"
12+
"phpgt/promise": "^2.2.1",
13+
"phpgt/http": "^1.1",
14+
"phpgt/curl": "^3.1.1",
15+
"phpgt/json": "^1.2",
16+
"phpgt/propfunc": "^1.0"
1617
},
1718

1819
"require-dev": {
19-
"phpstan/phpstan": "v1.8",
20-
"phpunit/phpunit": "v9.5"
20+
"phpstan/phpstan": "^1.10",
21+
"phpunit/phpunit": "^10.1",
22+
"phpmd/phpmd": "^2.13",
23+
"squizlabs/php_codesniffer": "^3.7"
2124
},
2225

2326
"autoload": {

0 commit comments

Comments
 (0)