summaryrefslogtreecommitdiffstats
path: root/php-guzzlehttp-ringphp.spec
blob: dfeeb9b191e965d1e21afb5ee92d3c11f7fb3ff7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# remirepo spec for php-guzzlehttp-ringphp, from Fedora:
#
# Fedora spec file for php-guzzlehttp-ringphp
#
# Copyright (c) 2014-2021 Shawn Iwinski <shawn.iwinski@gmail.com>
#
# License: MIT
# http://opensource.org/licenses/MIT
#
# Please preserve changelog entries
#

%global github_owner     guzzle
%global github_name      RingPHP
%global github_version   1.1.1
%global github_commit    5e2a174052995663dd68e6b5ad838afd47dd615b

%global composer_vendor  guzzlehttp
%global composer_project ringphp

# "php": ">=5.4.0"
%global php_min_ver      5.4.0
# "guzzlehttp/streams": "~3.0"
%global streams_min_ver  3.0.0
%global streams_max_ver  4.0
# "react/promise": "~2.0"
%global promise_min_ver  2.2.0
%global promise_max_ver  3.0

# Build using "--without tests" to disable tests
%global with_tests %{?_without_tests:0}%{!?_without_tests:1}

%{!?phpdir:    %global phpdir    %{_datadir}/php}
%{!?testsdir:  %global testsdir  %{_datadir}/tests}

Name:          php-%{composer_vendor}-%{composer_project}
Version:       %{github_version}
Release:       7%{?github_release}%{?dist}
Summary:       Simple handler system used to power clients and servers in PHP

License:       MIT
URL:           http://ringphp.readthedocs.org
Source0:       https://github.com/%{github_owner}/%{github_name}/archive/%{github_commit}/%{name}-%{github_version}-%{github_commit}.tar.gz

# Fix #41 use proper proxy attribute without ending /
# https://github.com/guzzle/RingPHP/pull/42
# https://github.com/guzzle/RingPHP/pull/42.patch
Patch0:        %{name}-upstream-pull-42.patch

BuildArch:     noarch
# Tests
%if %{with_tests}
BuildRequires: nodejs
BuildRequires: %{_bindir}/phpunit
## composer.json
BuildRequires: php(language)                    >= %{php_min_ver}
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
BuildRequires: (php-composer(guzzlehttp/streams) >= %{streams_min_ver}  with php-composer(guzzlehttp/streams) <  %{streams_max_ver})
BuildRequires: (php-composer(react/promise)      >= %{promise_min_ver}  with php-composer(react/promise)      <  %{promise_max_ver})
%else
BuildRequires: php-composer(guzzlehttp/streams) <  %{streams_max_ver}
BuildRequires: php-composer(guzzlehttp/streams) >= %{streams_min_ver}
BuildRequires: php-composer(react/promise)      <  %{promise_max_ver}
BuildRequires: php-composer(react/promise)      >= %{promise_min_ver}
%endif
BuildRequires: php-curl
## phpcompatinfo (computed from version 1.1.0)
BuildRequires: php-json
BuildRequires: php-pcre
BuildRequires: php-reflection
BuildRequires: php-spl
BuildRequires: php-zlib
## Autoloader
BuildRequires: php-composer(fedora/autoloader)
%endif

# composer.json
Requires:      php(language)                    >= %{php_min_ver}
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
Requires:      (php-composer(guzzlehttp/streams) >= %{streams_min_ver}  with php-composer(guzzlehttp/streams) <  %{streams_max_ver})
Requires:      (php-composer(react/promise)      >= %{promise_min_ver}  with php-composer(react/promise)      <  %{promise_max_ver})
%else
Requires:      php-composer(guzzlehttp/streams) <  %{streams_max_ver}
Requires:      php-composer(guzzlehttp/streams) >= %{streams_min_ver}
Requires:      php-composer(react/promise)      <  %{promise_max_ver}
Requires:      php-composer(react/promise)      >= %{promise_min_ver}
%endif
# composer.json: optional
Requires:      php-curl
# phpcompatinfo (computed from version 1.1.0)
Requires:      php-spl
# Autoloader
Requires:      php-composer(fedora/autoloader)

# Composer
Provides:      php-composer(%{composer_vendor}/%{composer_project}) = %{version}

%description
Provides low level APIs used to power HTTP clients and servers through a simple,
PHP callable that accepts a request hash and returns a future response hash.
RingPHP supports both synchronous and asynchronous workflows by utilizing both
futures and promises [1].

RingPHP is inspired by Clojure's Ring [2], but has been modified to accommodate
clients and servers for both blocking and non-blocking requests.

[1] https://github.com/reactphp/promise
[2] https://github.com/ring-clojure/ring


# ------------------------------------------------------------------------------


%package tests

Summary:  Tests for %{name}
Group:    Development/Libraries

Requires: %{name} = %{version}-%{release}
Requires: nodejs
Requires: php-composer(phpunit/phpunit)
# phpcompatinfo (computed from version 1.1.0)
Requires: php-json
Requires: php-pcre
Requires: php-reflection
Requires: php-zlib

%description tests
%{summary}.


# ------------------------------------------------------------------------------


%prep
%setup -qn %{github_name}-%{github_commit}

# Fix #41 use proper proxy attribute without ending /
%patch0 -p1

: Modify tests bootstrap
sed -e "s#.*require.*autoload.*#require __DIR__ . '/autoload.php';#" \
    -i tests/bootstrap.php


%build
: Create library autoloader
cat <<'AUTOLOAD' | tee src/autoload.php
<?php
/**
 * Autoloader for %{name} and its' dependencies
 * (created by %{name}-%{version}-%{release}).
 */
require_once '%{phpdir}/Fedora/Autoloader/autoload.php';

\Fedora\Autoloader\Autoload::addPsr4('GuzzleHttp\\Ring\\', __DIR__);

\Fedora\Autoloader\Dependencies::required([
    '%{phpdir}/GuzzleHttp/Stream/autoload.php',
    '%{phpdir}/React/Promise/autoload.php',
]);
AUTOLOAD

: Create tests autoloader
cat <<'AUTOLOAD' | tee tests/autoload.php
<?php
/**
 * Autoloader for %{name} and its' dependencies
 * (created by %{name}-tests-%{version}-%{release}).
 */

// Require library autoloader.  Allow for both RPM builds of %{name}
// and other packages' usage of %{name}-tests.
$libraryAutoload = '%{phpdir}/GuzzleHttp/Ring/autoload.php';
$rpmBuildRoot = getenv('RPM_BUILD_ROOT');
if ($rpmBuildRoot && file_exists($rpmBuildRoot . $libraryAutoload)) {
    require_once $rpmBuildRoot . $libraryAutoload;
} else {
    require_once $libraryAutoload;
}
unset($libraryAutoload, $rpmBuildRoot);

\Fedora\Autoloader\Autoload::addPsr4('GuzzleHttp\\Tests\\Ring\\', __DIR__);
AUTOLOAD

: Create custom tests PHPUnit config
rm -f phpunit.xml.dist
cat <<'PHPUNIT' | tee phpunit.xml.dist
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./bootstrap.php" colors="true">
    <testsuites>
        <testsuite>
            <directory>.</directory>
        </testsuite>
    </testsuites>
</phpunit>
PHPUNIT


%install
: Library
mkdir -p %{buildroot}%{phpdir}/GuzzleHttp/Ring
cp -rp src/* %{buildroot}%{phpdir}/GuzzleHttp/Ring/

: Tests
mkdir -p %{buildroot}%{testsdir}
cp -rp tests %{buildroot}%{testsdir}/%{name}
cp -p phpunit.xml.dist %{buildroot}%{testsdir}/%{name}/


%check
%if %{with_tests}
: Upstream tests

# testEmitsDebugInfoToStream have strange failure on F29+
# testCreatesCurlHandle and testEmitsProgressToFunction fail on F35+

RETURN_CODE=0
for PHP_EXEC in php %{?rhel:php55 php56 php70 php71 php72} php73 php74 php80; do
    if [ "php" == "$PHP_EXEC" ] || which $PHP_EXEC; then
        $PHP_EXEC %{_bindir}/phpunit --verbose \
            --filter '^((?!(testEmitsDebugInfoToStream|testCreatesCurlHandle|testEmitsProgressToFunction)).)*$' \
            --configuration %{buildroot}%{testsdir}/%{name} \
            || RETURN_CODE=1
    fi
done
exit $RETURN_CODE
%else
: Tests skipped
%endif


%files
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc *.md
%doc *.rst
%doc composer.json
%{phpdir}/GuzzleHttp/Ring

%files tests
%{testsdir}/%{name}


%changelog
* Thu Apr  1 2021 Remi Collet <remi@remirepo.net> - 1.1.1-7
- skip 2 tests failing with PHP 8

* Tue Oct 16 2018 Remi Collet <remi@remirepo.net> - 1.1.1-1
- update to 1.1.1 for PHP 7.3 compatibility
- use range dependencies
- skip 1 test with strange failure on F29+ (everything seems ok)

* Fri Apr 07 2017 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.1.0-9
- Fix rawhide (F27) FTBS
- Switch autoloader to php-composer(fedora/autoloader)
- Test with SCLs if available

* Tue Sep 22 2015 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.1.0-6
- Updated autoloader to load dependencies after self registration
- Minor cleanups

* Sun Jun 28 2015 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.1.0-5
- Autoloader updates

* Fri Jun 12 2015 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.1.0-3
- Fix tests' autoload

* Fri Jun 12 2015 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.1.0-2
- Use new $fedoraClassLoader concept in autoloader
- Remove secondary "tests" directory from tests sub-package

* Mon Jun 01 2015 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.1.0-1
- Updated to 1.1.0
- Updated source URL
- Added autoloader
- Sub-packaged tests

* Fri Feb 13 2015 Remi Collet <remi@fedoraproject.org> - 1.0.5-1
- backport for remi repository

* Sun Dec 28 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.0.5-1
- Updated to 1.0.5

* Thu Nov 13 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.0.3-1
- Updated to 1.0.3
- Removed color turn off and default timezone for phpunit

* Mon Oct 27 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.0.1-1
- Initial package