Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create phar build flow #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
name: Release workflow
jobs:
build-phar:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.3
ini-values: memory_limit=2G, display_errors=On, error_reporting=-1, phar.readonly=0
tools: phive

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ hashFiles('**/composer.lock') }}
restore-keys: composer-

- name: Install Composer dependencies
run: |
composer install --no-dev --no-progress --prefer-dist --optimize-autoloader

- name: Remove phpunit
run: composer remove phpunit/phpunit

- name: Install phive tools
run: phive install --trust-gpg-keys 2A8299CE842DD38C

- name: Build phar
run: make phar

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if we tag a prerelease tag instead of a stable one ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to discuss how to handle those, I didn't find any pre-releases in this package.
Rethinking this, we need to release every time prophecy itself is released.
This would mean that we need to connect the projects more tightly. Of course this can be automated some in some way. But before we spend to much time on this I would like to know your opinion about is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the releasing of the phar needs to depend on releasing both prophecy and prophecy-phpunit, it should not be managed in the releases of the prophecy-phpunit repository itself, as that would mess things up. We should either have separate phars for each package or a separate repo managing the combined phar

Copy link
Author

@jaapio jaapio Feb 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, when you would release a bugfix for prophecy people using prophecy-phpunit would need to get that patch. Seen the amount of code in this repo I don't expect too many changes. With composer this problem doesn't exist, when shipping a phar this problem does exist since all dependencies are included. I don't think phpunit can load multiple phars for a single plugin. We could investigate that. It would mean that we would deliver a prophecy phar which includes a manifest file and a prophecy-phpunit for the integration of the packages.

But maybe you are right, and a separate repo is better since it would have it's own releases.

Since this is kind of an edge case I don't want to take too much of your time. So maybe it is better to create a separate project first. And move it under the phpspec flag later if we are going to share maintenance.
That was also the mean reason for me to open an issue first before creating this PR.


- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/prophecy-phpunit.phar
asset_name: prophecy-phpunit.phar
asset_content_type: application/zip
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
vendor
build
composer.lock
phpunit.xml
.*.cache
4 changes: 4 additions & 0 deletions .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpab" version="^1.26.0" installed="1.26.0" location="./tools/phpab" copy="true"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't tools be added in .gitignore ?

</phive>
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"phpspec/prophecy": "^1.18",
"phpunit/phpunit":"^9.1 || ^10.1"
},
"require-dev": {
"phar-io/manifest": "^2.0"
jaapio marked this conversation as resolved.
Show resolved Hide resolved
},
"autoload": {
"psr-4": {
"Prophecy\\PhpUnit\\": "src"
Expand Down
11 changes: 11 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
phar:
mkdir build;
cp -r src build/src;
cp -r vendor build;
rm -r build/vendor/phpspec;
cp manifest.xml build/manifest.xml;
cp LICENSE build/LICENSE
php -dphar.readonly=0 ./tools/phpab --phar -o ./build/prophecy-phpunit.phar --all --hash SHA-1 ./build

clean:
rm -r build
15 changes: 15 additions & 0 deletions manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<phar xmlns="https://phar.io/xml/manifest/1.0">
<contains name="prophecy/prophecy-phpunit" version="1.0" type="extension">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hardcoding the version as 1.0 here looks wrong to me

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version here should be equal to the version of the package. When we have a release strategy for the phar releases I can have a look at how to implement this properly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, isn't this PR precisely about implementing that strategy ?

<extension for="phpunit/phpunit" compatible="^9.1"/>
</contains>

<copyright>
<author name="Christophe Coevoet" email="stof@notk.org"/>
<license type="MIT" url="https://github.com/phpspec/prophecy-phpunit/blob/master/LICENSE"/>
</copyright>

<requires>
<php version="^7.3 || ^8.0"/>
</requires>
</phar>