Coder Social home page Coder Social logo

component-split's Introduction

Zend Framework Component Split Utilities

Repository abandoned 2019-12-05

This repository is no longer maintained.

This repository contains utilities for splitting Zend Framework 2 components out of the main ZF2 repository and into their own repositories, complete with history.

Splitting a component

The primary entry-point utility is bin/split.sh. This script accepts up to two arguments:

  • -c COMPONENT for the component name (it should be the same as it appears in the ZF2 library directory)
  • -p PHP for the path to the PHP executable (if it cannot be found via which php)

This script will use the various files located under assets/root-files/COMPONENT to split the component.

As an example:

$ ./bin/split.sh -c Authentication

Two components have special rules: Zend\Permissions\Acl and Zend\Permissinos\Rbac; these are invoked as simply Acl and Rbac, respectively.

The files will be split into a directory named after the component; e.g., Authentication becomes zend-authentication, Acl becomes zend-permissions-acl, etc. This allows parallel runs in the same directory.

Custom split

The heavy-lifting utility is bin/split-component.sh. This script accepts the component name, paths to a number of component-specific assets, and then performs a git filter-branch that rewrites each commit to only contain the source code and tests for the given component, as well as repository assets such as the license, README, and QA tool configuration.

It's usage is as follows:

ZF2 Component Split Tool, v0.1.0

Usage:
-h                      Help; this message
-c <Component>          Component to split out (REQUIRED)
-u <phpunit.xml.dist>   Path to phpunit.xml.dist to use for this component (REQUIRED)
-t <phpunit.xml.travis> Path to the component's TestConfiguration.php.dist file (REQUIRED)
-z <ZF2 path>           Path in which to clone ZF2; defaults to 'zf2-migrate'
-s <.php_cs>            Path to the component-specific .php_cs file, if any
-T <.travis.yml>        Path to the component-specific .travis.yml file, if any
-r <README.md>          Path to the component-specific README.md file; a template is used by default
-p <PHP executable>     PHP executable to use (for composer rewrite); defaults to /usr/bin/env php

The required options are:

  • -c <Component> to provide the component name. This should be the name of the directory in which it appears under the library/Zend/ tree.
  • -u <phpunit.xml.dist> to provide the customized, component-specific phpunit.xml.dist file. A full example is under assets/root-files/; copy that to another location and edit it.
  • -t <phpunit.xml.travis> to provide the customized, component-specific phpunit.xml.travis file. A full example is under assets/root-files/; copy that to another location and edit it.

We recommend that you create an appropriate, minimal README.md file to use as well, in order to provide details around the purpose of a component. Do not provide specifics on usage, as usage may have changed over the lifetime of the component.

Finally, you may need to customize the .php_cs and/or .travis.yml files if the component you're splitting has additional files to ignore for coding standards, or dependencies on non-standard extensions when testing. Write these to files locally, and specify their paths to the tool.

As an example:

# Assume the phpunit.xml.* files were already prepared and are in the root
# directory when running.
$ ./bin/split-component.sh \
> -c Dom \
> -u phpunit.xml.dist \
> -t phpunit.xml.travis 2>&1 | tee -a split.log

Note on duration

Splitting a component takes a very, very long time due to the amount of history in Zend Framework โ€” over 20k commits! The process does not consume a large number of system resources, but will take between 4 and 6 hours depending on your hardware (and possibly longer).

As such, we recommend:

  • Do not reboot mid-process!
  • Run in screen or tmux.
  • Pipe STDERR and STDOUT to a log file; if you use the tee command, you can even tail a log file from another terminal window. See the example above for how to accomplish that.

Once done, enter the directory in which the split occurred, and check the composer.json across a number of tags to verify it looks okay; run composer install and phpunit as spot-checks. (This will only work within tags!)

Note on unit tests

We've made the decision to support a single version of PHPUnit across the entire history of each component. In some cases, this will fail, due to differences in PHPUnit syntax, missing dependencies, etc. The main thing is to ensure it runs at all.

Once done, create a component repository under your own username on GitHub, add it as a remote to your local repository, and push the full history to it:

$ cd zf2-migrate
$ git remote add username [email protected]:username/zend-{component}.git
$ git push --all --tags username

(Where "username" is your GitHub username, and {component} is the component name.)

Once done, drop an email to [email protected] indicating the component you've split and the URI to your GitHub repository so we can verify. Once we have, we'll add you to the team for the canonical repository, and have you push to it.

component-split's People

Contributors

ezimuel avatar maks3w avatar weierophinney avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

component-split's Issues

Things to do before 2.5

  • Many components have an empty description in composer.json.
  • Add a deprecated notice + forward on zendframework/Components_ repositories
  • Migrate issues from zendframework/zf2

/cc @weierophinney

try split "Authentication" component got Invalid component name 'Authentication'

I've tried run :

$ ./bin/split-component.sh \
> -c Authentication \
> -t TestConfiguration.php.dist \
> -i TestConfiguration.php.travis 2>&1 | tee -a split.log

Got log :

ZF2 Component Split Tool, v0.1.0

Splitting component Authentication
Using:
    PHP:                           /usr/local/php5/bin/php
    ZF2 path:                      zf2-migrate
    TestConfiguration.php.dist:    readlink: illegal option -- f
usage: readlink [-n] [file ...]
    TestConfiguration.php.travis:  readlink: illegal option -- f
usage: readlink [-n] [file ...]

readlink: illegal option -- f
usage: readlink [-n] [file ...]
Cloning into 'zf2-migrate'...
readlink: illegal option -- f
usage: readlink [-n] [file ...]
Invalid component name 'Authentication'!

composer install on splitted "Stdlib" error

I've just done a split, and try run composer install, and got error :

$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - zendframework/zend-serializer 2.3.x-dev requires zendframework/zend-json == 2.3.9999999.9999999-dev -> no matching package found.
    - zendframework/zend-serializer 2.3.x-dev requires zendframework/zend-json == 2.3.9999999.9999999-dev -> no matching package found.
    - Installation request for zendframework/zend-serializer == 2.3.9999999.9999999-dev -> satisfiable by zendframework/zend-serializer[2.3.x-dev].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Splitted component pushed at https://github.com/samsonasik/zend-stdlib

[Split] PHP CS Fixer

From @gianarb on April 1, 2015 23:36

Hi!
In your opinion current flow of cs-fix's check is good??
In my opinion this check is not on the same level of the tests failure.

I'm follow this project StyleCI - code || StyleCI - service this is a good idea for a lot of reasons.

  • Centralize configuration.. We can manage change of config for all components from single point.
  • We can do a different signal if a build failure because a tests is broken or because there is a problem of code style..

In my opinion if I know which PRs don't follow a standard code I can merge them anyway and after a lot of merge I can run CS-fix

Copied from original issue: zendframework/zendframework#7402

error : PHP Warning: copy(/home/vagrant/component-split/TestConfiguration.php.travis): failed to open stream:

when i call the split, i got error :

PHP Warning:  copy(/home/vagrant/component-split/TestConfiguration.php.travis): failed to open stream: No such file or directory in /home/vagrant/component-split/bin/tree-filter.php on line 124
Rewrite 430b6208122daf2076e2b677e5b1a3cdd7602a1c (1182/13544)PHP Warning:  copy(/home/vagrant/component-split/TestConfiguration.php.dist): failed to open stream: No such file or directory in /home/vagrant/component-split/bin/tree-filter.php on line 123
PHP Warning:  copy(/home/vagrant/component-split/TestConfiguration.php.travis): failed to open stream: No such file or directory in /home/vagrant/component-split/bin/tree-filter.php on line 124
Rewrite

seems it should be fixed by #3 by @Maks3w ?

History is duplicated master branch and tags have duplicated commits

image

Master branch and 2.4.* tags share the same contents but they are different trees

For ex: [2.4.2] Release readiness is duplicated in both trees

zendframework/zend-version@4ac7fba 2.4.2 Tag

zendframework/zend-version@d59789c Master branch

Options:

  • Hard reset master HEAD to match 2.4.2 commit

    Pro: Simple to do and master branch is not stable so rewrite history is not a BC break
    Con: Latest commit in master will be lost (bump to 2.4.3-dev), however this version is not in the roadmap

or

  • Rewrite tags and match a master commit

    Pro: Git history will be smaller. This tree has more empty commits than master
    Con: Require to change "stable" tags references

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.