Skip to content

Commit 3bd9ca0

Browse files
committed
Package and deploy a phar during the build
1 parent e18a1f0 commit 3bd9ca0

File tree

6 files changed

+101
-12
lines changed

6 files changed

+101
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/.php_cs.cache
2+
/box.json
23
/build/
34
/composer.lock
45
/vendor/

.travis.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
language: php
2-
32
matrix:
4-
include:
5-
- php: 7.1
6-
- php: 7.2
7-
env: deps=low
8-
fast_finish: true
9-
10-
before_script:
11-
- phpenv config-rm xdebug.ini
12-
- if [[ $deps = low ]]; then make update-min; else make install; fi
13-
3+
include:
4+
- php: 7.1
5+
env: EXECUTE_DEPLOYMENT=true
6+
- php: 7.2
7+
env: deps=low
8+
fast_finish: true
9+
before_install:
10+
- phpenv config-rm xdebug.ini
11+
install:
12+
- if [[ $deps = low ]]; then make update-min; else make install; fi
1413
script:
15-
- if [[ $deps = low ]]; then make test-min; else make test; fi
14+
- if [[ $deps = low ]]; then make test-min; else make test; fi
15+
- make package
16+
deploy:
17+
provider: releases
18+
api_key:
19+
secure: bcQjAVuB0a/aMXFZ/dMeiiaipDDJQUmmwaHBMyRwZgTjd1m3ruz+D1vHUGCH8CBSEBf97aKh4mpzqllC0/DoKSZVUK8wf3elZv3Aw2q5RlmiXoigtNscBYxc9rCpqvoy1p8ituwQjKfEubRgAIBTpIiunEsbOfjV2jTHOpKUcz1+TiNCuS7JMbcnB0xIvKCz9EKvzbxIlrIaZ6erKRGwU2GqSnmchfimANyJZJbAYZD68BSetAWnCGhIunblr7c7abDBY72bphsJdAkAkaIvV8x8CABX52m+Uq5ceTVXvcltHWinht/lRehyvJH7TAJSi+arRGCKQPOGGvzKjH3Y7tkbm3KdR/gKQ5E0U1iK/7Dm3wp1AWQB3FGfRN20nccqIDpO/7MCwH0NE3eLGNLlMzVFuX9+iLz3a5i4Emnm2KY9YoLgHGvswyFcPUZrWbI0Q7unmyKQ3HPqUMpLaMU40Tt68KiG2+T4bPSjE8ZqdPpwFoE8OmNXLral/oOWueaMpSNpyatULaFt8rG0WLOG+LOSc6Ket2IU4mmQ3zo6a8zgnEIBatTxpzYnwiE21j0GzsNUIXVeHDQ3DVDANM5Lv3J3tiIEJVkJfvNC6T3WvT7FOITVhVUU9OLXBwAtrOesXmVlyAv+0IxLL48IIvmcp2hkIX7mVd8kCLFk8/T6Njg=
20+
file: build/zalas-phpunit-globals-extension.phar
21+
skip_cleanup: true
22+
on:
23+
tags: true
24+
repo: jakzal/phpunit-globals
25+
condition: "$EXECUTE_DEPLOYMENT"

Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ update-min:
1515
composer update --prefer-stable --prefer-lowest
1616
.PHONY: update-min
1717

18+
update-no-dev:
19+
composer update --prefer-stable --no-dev
20+
.PHONY: update-no-dev
21+
1822
test: vendor cs phpunit
1923
.PHONY: test
2024

@@ -33,12 +37,39 @@ phpunit: tools/phpunit
3337
tools/phpunit
3438
.PHONY: phpunit
3539

40+
clean:
41+
rm -rf build
42+
.PHONY: clean
43+
44+
package: tools/box
45+
$(eval VERSION=$(shell git describe --abbrev=0 --tags 2> /dev/null | sed -e 's/^v//' || echo 'dev'))
46+
@rm -rf build/phar && mkdir -p build/phar
47+
48+
cp -r src LICENSE composer.json build/phar
49+
sed -e 's/@@version@@/$(VERSION)/g' manifest.xml.in > build/phar/manifest.xml
50+
51+
cd build/phar && \
52+
composer remove phpunit/phpunit --no-update && \
53+
composer config platform.php 7.1 && \
54+
composer update --no-dev -o -a
55+
56+
tools/box compile
57+
58+
@rm -rf build/phar
59+
.PHONY: package
60+
3661
vendor: install
3762

3863
vendor/bin/phpunit: install
3964

65+
tools: tools/php-cs-fixer tools/phpunit tools/box
66+
.PHONY: tools
67+
4068
tools/phpunit: vendor/bin/phpunit
4169
ln -sf ../vendor/bin/phpunit tools/phpunit
4270

4371
tools/php-cs-fixer:
4472
curl -Ls http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -o tools/php-cs-fixer && chmod +x tools/php-cs-fixer
73+
74+
tools/box:
75+
curl -Ls https://github.com/humbug/box/releases/download/3.0.0-beta.0/box.phar -o tools/box && chmod +x tools/box

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,27 @@ and brought to the original state after each test case has finished.
1414

1515
## Installation
1616

17+
### Composer
18+
1719
```bash
1820
composer require --dev zalas/phpunit-globals
1921
```
2022

23+
### Phar
24+
25+
The extension is also distributed as a PHAR, which can be downloaded from the most recent
26+
[Github Release](https://github.com/jakzal/phpunit-globals/releases).
27+
28+
Put the extension in your PHPUnit extensions directory.
29+
Remember to instruct PHPUnit to load extensions in your `phpunit.xml`:
30+
31+
```xml
32+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.0/phpunit.xsd"
33+
extensionsDirectory="tools/phpunit.d"
34+
>
35+
</phpunit>
36+
```
37+
2138
## Usage
2239

2340
Enable the globals listener in your PHPUnit configuration:

box.json.dist

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"base-path": "build/phar",
3+
"output": "../zalas-phpunit-globals-extension.phar",
4+
"compression": "GZ",
5+
"directories": ["."],
6+
"dump-autoload": true,
7+
"exclude-composer-files": true,
8+
"check-requirements": false,
9+
"main": "vendor/autoload.php",
10+
"banner": [
11+
"This file is part of the zalas/phpunit-globals project.",
12+
"",
13+
"(c) Jakub Zalas <[email protected]>"
14+
]
15+
}

manifest.xml.in

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<phar xmlns="https://phar.io/xml/manifest/1.0">
3+
<contains name="zalas/phpunit-globals" version="@@version@@" type="extension">
4+
<extension for="phpunit/phpunit" compatible="^7.0"/>
5+
</contains>
6+
7+
<copyright>
8+
<author name="Jakub Zalas" email="[email protected]"/>
9+
<license type="MIT" url="https://github.com/jakzal/phpunit-globals/blob/master/LICENSE"/>
10+
</copyright>
11+
12+
<requires>
13+
<php version="^7.1"/>
14+
</requires>
15+
</phar>

0 commit comments

Comments
 (0)