Skip to content

Commit 23d6192

Browse files
authored
Merge pull request #7 from jakzal/phar-releases
Package the extension as phar and deploy it during the build
2 parents 0bc529a + 6a3d3b7 commit 23d6192

File tree

8 files changed

+111
-13
lines changed

8 files changed

+111
-13
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/build/
2+
/box.json
23
/composer.lock
34
/vendor/
45
/.php_cs.cache

.travis.yml

+29-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
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+
- |
11+
if [ 'jakzal/phpunit-injector' == "$TRAVIS_PULL_REQUEST_SLUG" ]; then
12+
openssl aes-256-cbc -K $encrypted_a7af76e39835_key -iv $encrypted_a7af76e39835_iv -in .travis/secrets.tar.enc -out .travis/secrets.tar -d
13+
tar xvf .travis/secrets.tar -C .travis
14+
fi;
15+
- phpenv config-rm xdebug.ini
16+
install:
17+
- if [[ $deps = low ]]; then make update-min; else make install; fi
1418
script:
15-
- if [[ $deps = low ]]; then make test-min; else make test; fi
19+
- if [[ $deps = low ]]; then make test-min; else make test; fi
20+
- make package
21+
deploy:
22+
provider: releases
23+
api_key:
24+
secure: jn8Dw+WwWEnkF9BulSd8Jsah4piDP5KZYQd8ybV/JNAXwSUm5HQbZ8mCrVnWd/vqVCtnMPg+8+axU6bkhfAKZl7RHSwM0ZT3iJHNxQLwicOlx4MTgrwvD7HS3zf3WsguA84vNqipr+p/zzezhxzHALX6w7EkjqtF7MfC9H9jq7qPloaPzEqsLbwHnAV4usWTe1E7fNJ03LlJwgpiiU8TaGFJ+UVsuM7wcuGree0A8mttSd7ytE8s1mB2ph3UpXC7izSa/DXa3vOXXlB1AOKCbeunL0arKYGLrwmJq3wVw4oZSnCxgfM2P0uOwjQ7LhBF+OfQpnnS63OAlzeCQrOmMfXfdx8V8SyrjOeA1377MnrElbKgW/r4MGW0/cB1GMwSvsioJBMODFSRKmQH+TCcSpFHyzIij4QzWrfln7URpnRC1Vs0rOfZX+15iyyhI/UatNTrMlQXtIqJENeIg41PMqbmHMcQj63Wtz0DOJ+bBnWx3vsD+s7inuplkGo/JOjPXL4FMCRQvgFQNjoGNTrfoS6G7Ex4SV7toy26L8vzn5g2zys7dnF4mPQZRo81IFw++zP6dGYEbb+XJwNiVix/otKxA3d8PsnUj4zWqrYRBZIXntW1Gipgm3pKfQcuLE55witt5CPucIRYCph3MXB+6Tp+e2m5JaolknSN9LUgFK0=
25+
file:
26+
- build/zalas-phpunit-injector-extension.phar
27+
- build/zalas-phpunit-injector-extension.phar.pubkey
28+
skip_cleanup: true
29+
on:
30+
tags: true
31+
repo: jakzal/phpunit-injector
32+
condition: "$EXECUTE_DEPLOYMENT"

.travis/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.pem
2+
secrets.tar

.travis/secrets.tar.enc

6.02 KB
Binary file not shown.

Makefile

+30-1
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 deptrac phpunit infection
1923
.PHONY: test
2024

@@ -41,9 +45,31 @@ phpunit: tools/phpunit
4145
tools/phpunit
4246
.PHONY: phpunit
4347

44-
tools: tools/php-cs-fixer tools/deptrac tools/infection
48+
tools: tools/php-cs-fixer tools/deptrac tools/infection tools/box
4549
.PHONY: tools
4650

51+
clean:
52+
rm -rf build
53+
.PHONY: clean
54+
55+
package: tools/box
56+
$(eval VERSION=$(shell git describe --abbrev=0 --tags 2> /dev/null | sed -e 's/^v//' || echo 'dev'))
57+
@rm -rf build/phar && mkdir -p build/phar
58+
59+
cp -r src LICENSE composer.json build/phar
60+
sed -e 's/@@version@@/$(VERSION)/g' manifest.xml.in > build/phar/manifest.xml
61+
[ -f .travis/phpunit-injector-extension-private.pem ] || cat box.json.dist | sed -e '/\"key\": \".*\",/d' -e '/\"algorithm\": \".*\",/d' > box.json
62+
63+
cd build/phar && \
64+
composer remove phpunit/phpunit --no-update && \
65+
composer config platform.php 7.1 && \
66+
composer update --no-dev -o -a
67+
68+
tools/box compile
69+
70+
@rm -rf build/phar
71+
.PHONY: package
72+
4773
vendor: install
4874

4975
vendor/bin/phpunit: install
@@ -62,3 +88,6 @@ tools/infection: tools/infection.pubkey
6288

6389
tools/infection.pubkey:
6490
curl -Ls https://github.com/infection/infection/releases/download/0.8.1/infection.phar.pubkey -o tools/infection.pubkey
91+
92+
tools/box:
93+
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

+17
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,27 @@ to any property tagged with `@inject`.
1111

1212
## Installation
1313

14+
### Composer
15+
1416
```bash
1517
composer require --dev zalas/phpunit-injector
1618
```
1719

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

2037
Enable the service injector listener

box.json.dist

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

manifest.xml.in

+15
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-injector" 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-injector/blob/master/LICENSE"/>
10+
</copyright>
11+
12+
<requires>
13+
<php version="^7.1"/>
14+
</requires>
15+
</phar>

0 commit comments

Comments
 (0)