Skip to content

Create a .phar file#124

Merged
tmatsuo merged 6 commits intophp-coveralls:masterfrom
onema:phar-box
Dec 5, 2015
Merged

Create a .phar file#124
tmatsuo merged 6 commits intophp-coveralls:masterfrom
onema:phar-box

Conversation

@onema
Copy link
Contributor

@onema onema commented Dec 4, 2015

Objective:

This PR aims to add the basic files and configuration to create a coveralls.phar using the box-project. The .phar file can be build by travis and attached to a release when tagged.

The .phar can be downloaded by third party projects and used instead of requiring it as a dependency.

Summary of changes:

  • Moved coveralls CLI application out of the composer file into the bin file.
  • Simplified bin\coveralls file
  • Updates all paths in .travis.yml and compsoer.json
  • Added box.json file with configuration required to build phar using box-project

Building and deployment:

The coveralls.phar file can be build and deployed using travis every time a release is tagged by adding the following to the .travis.yml:

before_script:
  - curl -LSs http://box-project.github.io/box2/installer.php | php
  - mkdir -p build/artifacts
  # ...
before_deploy:
  - php composer.phar install --no-dev --no-interaction
  - php box.phar build
  - rm box.phar
deploy:
  provider: releases
  api_key:
    secure: AbCD...xYZ
  file: build/artifacts/coveralls.phar
  on:
    repo: CPCStrategy/oauth2-flow-runner
    tags: true
    all_branches: true
    php: 5.5

Notice that composer is run with the flag --no-dev to avoid including any require-dev dependencies.

See the travis deployment documentation for more information on how to securely add the API key to the deployment section

@tmatsuo
Copy link
Collaborator

tmatsuo commented Dec 4, 2015

@onema, At the first glance, it really looks promising! Thanks! Really appreciated :)
I'll review this in detail tomorrow.

.gitignore Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are you removing build dir?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, there is no need to remove the build from.gitignore. Will fix

@tmatsuo
Copy link
Collaborator

tmatsuo commented Dec 4, 2015

@onema, also thanks for the great description. This is super helpful.

Notice that composer is run with the flag --no-dev to avoid including any require-dev dependencies.

Does this mean we need to clean up the vendor directory before the release since we're calling composer update (without --no-dev flag) in the earlier stage?

This was referenced Dec 4, 2015
Copy link
Collaborator

Choose a reason for hiding this comment

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

If it is called by the phar file, do we still need to require autoload file? If the phar file includes all the deps, there is no need to require them, right?

Is there a way to detect if it's called from within a phar file? If so, can we skip this section in that case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll double check this tonight/tomorrow and report back.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm also fine with having a separate files for calling from phar, and calliing from git clone, or composer installation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Line 5 is required by the phar. Let me know what you want to do as far as keeping this file as is or just using it for the phar.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@onema
Thanks much for checking!

Copy link
Member

Choose a reason for hiding this comment

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

Instead of this You can just use Phar::mapPhar.

@keradus
Copy link
Member

keradus commented Dec 4, 2015

Please, do not create a phar file if one job passed (eg 5.6) and other failed (eg 5.5).

@tmatsuo
Copy link
Collaborator

tmatsuo commented Dec 4, 2015

@keradus Great point and agreed. I'm wondering if there's a clean way of doing that just with .travis.yml. Do you know?

@keradus
Copy link
Member

keradus commented Dec 4, 2015

No. Travis is no-good of deploying libraries and tools, as they are supposed to work on multiple envs. Travis is only good for deploying applications, as they are run under one, unified environment (so 1 job in Travis build using Travis in classic way).

At least that is how it works few months ago, if it changes and you could run deploy not as job section, but as after-whole-build part, that would be sth I would like to see!

@onema
Copy link
Contributor Author

onema commented Dec 4, 2015

@keradus, @tmatsuo: The build using travis would only run when a tag is created using the selected version of PHP.This would only happen after all the test have been run for all version and have been merged into a common branch (master).

In any case, that is just a proposal and is not present in this PR. The phar can still be created using any method you like by doing this:

curl -LSs http://box-project.github.io/box2/installer.php | php
mkdir -p build/artifacts
php composer.phar install --no-dev --no-interaction
php box.phar build

It can latter be attached to the tag release or distribute in any way you like :)

@tmatsuo
Copy link
Collaborator

tmatsuo commented Dec 4, 2015

Ah, @onema thanks!

So I can run the release script only for push build to master, also only with a one single env.

I think we should build the phar with --prefer-stable --prefer-lowest in order to make it runnable for older PHP. Is it reasonable to create the phar with the PHP 5.3.3 env with --prefer-stable --prefer-lowest? Is the phar file generated by PHP 5.3.3 also runnable with PHP 7.0?

If you don't have an answer for now, nevermind, I'll test that anyways.

@keradus
Copy link
Member

keradus commented Dec 4, 2015

I know @onema, but it isn't protect from tag created on code that works on PHP5.6 and didnt work on PHP5.3.
It's true, that that tag shouldn't be created, but you never know.

@tmatsuo, build it on 5.3.3 with highest deps to ensure it works everywhere.
It would also work if builded on any version with lowest deps, but it is great to have it as high as possible, so highest deps for lowest PHP ver.

@tmatsuo
Copy link
Collaborator

tmatsuo commented Dec 4, 2015

it isn't protect from tag created on code that works on PHP5.6 and didnt work on PHP5.3.

@keradus, From now on, we will never merge red builds into master, so it should be fine.

build it on 5.3.3 with highest deps to ensure it works everywhere.

Thanks! As always :)

@tmatsuo
Copy link
Collaborator

tmatsuo commented Dec 4, 2015

Just a note, this will fix #92

@keradus
Copy link
Member

keradus commented Dec 5, 2015

From now on, we will never merge red builds into master, so it should be fine.

It could happen even by accident. Just having multiple jobs on Travis and deploy by Travis isn't the best option.
I do not say it is bad or wont work, it just has some edge cases in which it will build not working code. Sth to have in mind...

@tmatsuo
Copy link
Collaborator

tmatsuo commented Dec 5, 2015

LGTM

I'm going to merge this. For a time being, I will manually creat the phar. I will revisit automation later.

Thanks again!

tmatsuo pushed a commit that referenced this pull request Dec 5, 2015
@tmatsuo tmatsuo merged commit ced76e8 into php-coveralls:master Dec 5, 2015
Copy link
Member

Choose a reason for hiding this comment

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

using compactors would be cool

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please file an issue

Copy link
Member

Choose a reason for hiding this comment

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

nope, just to prove that merging is too fast ;)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Well, everything doesn't need to be perfect :) I'll file it then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants