$30 off During Our Annual Pro Sale. View Details »

Phing All The Things!

Phing All The Things!

Phing is a build system that lets you do all sorts of neat things quickly and easily. If you find yourself manually running complicated processes or frequently having to look up command line parameters for your tools, Phing can help make you more efficient. If your deployments have many error-prone steps or you find yourself dealing with fragile procedures, Phing can help keep your sanity.

Omni Adams

May 22, 2014
Tweet

More Decks by Omni Adams

Other Decks in Programming

Transcript

  1. Phing All The Things - Omni Adams

    View Slide

  2. Phing All The Things - Omni Adams
    lazy
    development

    View Slide

  3. Phing All The Things - Omni Adams

    View Slide

  4. Phing All The Things - Omni Adams
    Stay DRY

    View Slide

  5. Phing All The Things - Omni Adams

    View Slide

  6. Phing All The Things - Omni Adams



    checkreturn="true" />


    View Slide

  7. Phing All The Things - Omni Adams



    checkreturn="true" />


    View Slide

  8. Phing All The Things - Omni Adams



    checkreturn="true" />


    View Slide

  9. Phing All The Things - Omni Adams



    checkreturn="true" />


    View Slide

  10. Phing All The Things - Omni Adams



    checkreturn="true" />


    View Slide

  11. Phing All The Things - Omni Adams
    phing-the-things$ phing test
    Buildfile: /Users/Omni/phing-example/build.xml
    [property] Loading /Users/Omni/phing-example/build.properties
    phing-example > test:
    PHPUnit 3.7.13 by Sebastian Bergmann.
    Configuration read from /Users/Omni/phing-example/phpunit.xml
    ..............................
    Time: 0 seconds, Memory: 7.25Mb
    OK (30 tests, 52 assertions)
    BUILD FINISHED
    Total time: 0.3155 seconds

    View Slide

  12. Phing All The Things - Omni Adams
    F.............................
    Time: 0 seconds, Memory: 7.25Mb
    There was 1 failure:
    1) GitTest::testGetCommitInfo
    LOL cats have clogged the tubes!
    /Users/Omni/phing-example/tests/GitTest.php:51
    FAILURES!
    Tests: 30, Assertions: 51, Failures: 1.Execution of target "test" failed for the following reason: /
    Users/Omni/phing-example/build.xml:102:46: Task exited with code 1
    BUILD FAILED
    /Users/Omni/phing-example/build.xml:102:46: Task exited with code 1
    Total time: 0.5653 seconds

    View Slide

  13. Phing All The Things - Omni Adams



    checkreturn="true" />


    View Slide

  14. Phing All The Things - Omni Adams



    checkreturn="true" />


    View Slide

  15. Phing All The Things - Omni Adams
    F.............................
    Time: 0 seconds, Memory: 7.25Mb
    There was 1 failure:
    1) GitTest::testGetCommitInfo
    LOL cats have clogged the tubes!
    /Users/Omni/phing-example/tests/GitTest.php:51
    FAILURES!
    Tests: 30, Assertions: 51, Failures: 1.
    BUILD FINISHED
    Total time: 0.5619 seconds

    View Slide

  16. Phing All The Things - Omni Adams

    View Slide

  17. Phing All The Things - Omni Adams
    ●  strict
    ●  colors
    ●  groups
    ●  command line flags

    View Slide

  18. Phing All The Things - Omni Adams

    checkreturn="true">



    View Slide

  19. Phing All The Things - Omni Adams

    checkreturn="true">



    View Slide

  20. Phing All The Things - Omni Adams

    View Slide

  21. Phing All The Things - Omni Adams


    View Slide

  22. Phing All The Things - Omni Adams
    phing-the-things$ phing test -DphpunitFlag=--group=smoke
    Buildfile: /Users/Omni/phing-example/build.xml
    [property] Loading /Users/Omni/phing-example/build.properties
    phing-example > test:
    PHPUnit 3.7.13 by Sebastian Bergmann.
    Configuration read from /Users/Omni/phing-example/phpunit.xml
    ........
    Time: 0 seconds, Memory: 7.25Mb
    OK (8 tests, 12 assertions)
    BUILD FINISHED
    Total time: 0.1058 seconds

    View Slide

  23. Phing All The Things - Omni Adams
    composer=/opt/composer.phar
    server1.user=oadams
    server1.url=www.example.lan








    View Slide

  24. Phing All The Things - Omni Adams
    things

    View Slide

  25. Phing All The Things - Omni Adams
    author=Omni
    title=Phing All The Things



    View Slide

  26. Phing All The Things - Omni Adams

    View Slide

  27. Phing All The Things - Omni Adams





    format="full" showWarnings="true">





    View Slide

  28. Phing All The Things - Omni Adams

    View Slide

  29. Phing All The Things - Omni Adams











    View Slide

  30. Phing All The Things - Omni Adams











    View Slide

  31. Phing All The Things - Omni Adams











    View Slide

  32. Phing All The Things - Omni Adams











    View Slide

  33. Phing All The Things - Omni Adams









    ...

    View Slide

  34. Phing All The Things - Omni Adams



    View Slide

  35. Phing All The Things - Omni Adams

    View Slide

  36. Phing All The Things - Omni Adams

    View Slide

  37. Phing All The Things - Omni Adams

    View Slide

  38. Phing All The Things - Omni Adams







    View Slide

  39. Phing All The Things - Omni Adams










    View Slide

  40. Phing All The Things - Omni Adams












    View Slide

  41. Phing All The Things - Omni Adams

    View Slide

  42. Phing All The Things - Omni Adams



    View Slide

  43. Phing All The Things - Omni Adams



    View Slide

  44. Phing All The Things - Omni Adams



    View Slide

  45. Phing All The Things - Omni Adams



    View Slide

  46. Phing All The Things - Omni Adams



    View Slide

  47. Phing All The Things - Omni Adams




    checkreturn="true">





    View Slide

  48. Phing All The Things - Omni Adams

    View Slide

  49. Phing All The Things - Omni Adams










    View Slide

  50. Phing All The Things - Omni Adams










    View Slide

  51. Phing All The Things - Omni Adams

    View Slide

  52. Phing All The Things - Omni Adams

    View Slide

  53. Phing All The Things - Omni Adams
    ASS UMPTIONS

    View Slide

  54. Phing All The Things - Omni Adams

    View Slide

  55. Phing All The Things - Omni Adams

    View Slide

  56. Phing All The Things - Omni Adams

    View Slide

  57. Phing All The Things - Omni Adams

    message="Tagged version ${version}" />


    View Slide

  58. Phing All The Things - Omni Adams
    phing-the-things$ phing tag
    Buildfile: /Users/Omni/Sites/phing/build.xml
    [property] Loading /Users/Omni/Sites/phing/build.properties
    phing-the-things > require-version:
    [if] Error in IfTask
    Execution of target "require-version" failed for the following reason: /Users/Omni/Sites/phing/build.xml:146:12: /
    Users/Omni/Sites/phing/build.xml:150:18: You must pass in a version: -Dversion=1.2.3
    BUILD FAILED
    /Users/Omni/Sites/phing/build.xml:146:12: /Users/Omni/Sites/phing/build.xml:150:18: You must pass in a
    version: -Dversion=1.2.3
    Total time: 1.5921 second

    View Slide

  59. Phing All The Things - Omni Adams
    phing-the-things$ phing tag-no-version
    Buildfile: /Users/Omni/Sites/phing/build.xml
    [property] Loading /Users/Omni/Sites/phing/build.properties
    phing-the-things > tag-no-version:
    [gittag] git-tag command: /usr/bin/git tag -a -m'Tagged version ${version}' '${version}'
    [gittag] git-tag: tags for "." repository
    [gittag] git-tag output:
    BUILD FINISHED
    Total time: 0.2039 seconds
    phing-the-things $ git tag
    ${version}

    View Slide

  60. Phing All The Things - Omni Adams

    property="version" />






    message="Tagged version ${version}" />

    View Slide

  61. Phing All The Things - Omni Adams

    property="version" />






    message="Tagged version ${version}" />

    View Slide

  62. Phing All The Things - Omni Adams

    property="version" />






    message="Tagged version ${version}" />

    View Slide

  63. Phing All The Things - Omni Adams

    property="version" />






    message="Tagged version ${version}" />

    View Slide

  64. Phing All The Things - Omni Adams

    property="version" />






    message="Tagged version ${version}" />

    View Slide

  65. Phing All The Things - Omni Adams
    phing-the-things$ phing tag-version -Drelease=minor
    Buildfile: /Users/Omni/Sites/phing/build.xml
    [property] Loading /Users/Omni/Sites/phing/build.properties
    phing-the-things > tag-version:
    [master 4b48e9f] Updated version file to 0.1.0
    1 file changed, 1 insertion(+), 1 deletion(-)
    [gittag] git-tag command: /usr/bin/git tag -a -m'Tagged version 0.1.0' '0.1.0'
    [gittag] git-tag: tags for "." repository
    [gittag] git-tag output:
    BUILD FINISHED
    Total time: 0.3507 seconds
    phing-the-things $ git tag
    0.0.1
    0.1.0

    View Slide

  66. Phing All The Things - Omni Adams










    View Slide

  67. Phing All The Things - Omni Adams

    password="${svnpass}" nocache="true"
    repositoryurl="svn://localhost/phing-the-things/trunk/"
    todir="svn://localhost/phing-the-things/tags/${version}" />

    View Slide

  68. Phing All The Things - Omni Adams




    ${latest-version}
    property="version" />

    message="Tagged version ${version}" />

    View Slide

  69. Phing All The Things - Omni Adams
    value="https://jenkins/job/phing/lastBuild/api/json" />









    View Slide

  70. Phing All The Things - Omni Adams





    View Slide

  71. Phing All The Things - Omni Adams

    View Slide

  72. Phing All The Things - Omni Adams

    targetPath="build" />
    branchname="${version}" quiet="true" />


    includeemptydir="true" compression="bzip2" />


    View Slide

  73. Phing All The Things - Omni Adams






    View Slide

  74. Phing All The Things - Omni Adams










    View Slide

  75. Phing All The Things - Omni Adams







    View Slide

  76. Phing All The Things - Omni Adams

    passthru="true">




    View Slide

  77. Phing All The Things - Omni Adams








    View Slide

  78. Phing All The Things - Omni Adams
    Sanity
    Check

    View Slide

  79. Phing All The Things - Omni Adams

    View Slide

  80. Phing All The Things - Omni Adams
    phing-the-things$ phing go-live -Dversion=1.2.3

    View Slide

  81. Phing All The Things - Omni Adams
    phing-the-things$ phing go-live -Dversion=1.2.3

    View Slide

  82. Phing All The Things - Omni Adams
    !$monitored == !$exist

    View Slide

  83. Phing All The Things - Omni Adams

    View Slide

  84. Phing All The Things - Omni Adams
    require_once 'phing/Task.php';
    class UpdateNewRelicTask extends Task {
    public function init() {
    // Runs when task is imported
    }
    public function main() {
    // Runs when task is executed
    }
    }

    View Slide

  85. Phing All The Things - Omni Adams
    classname="UpdateNewRelicTask" />



    View Slide

  86. Phing All The Things - Omni Adams
    classname="UpdateNewRelicTask" />



    View Slide

  87. Phing All The Things - Omni Adams
    class UpdateNewRelicTask extends Task {
    protected $version;
    public function setVersion($version) {
    $this->version = $version;
    }
    }

    View Slide

  88. Phing All The Things - Omni Adams



    View Slide

  89. Phing All The Things - Omni Adams
    public function main() {
    $options = array(
    CURLOPT_POSTFIELDS => array(
    'deployment[application_id]' => $this->appId,
    'deployment[description]' => $this->version ),
    CURLOPT_HTTPHEADER => array(
    'x-api-key: ' . $this->apiKey ),
    CURLOPT_URL => $this->url,
    );
    ...
    }

    View Slide

  90. Phing All The Things - Omni Adams
    public function main() {
    ...
    $ch = curl_init();
    curl_setopt_array($ch, $options);
    curl_exec($ch);
    curl_close($ch);
    }

    View Slide

  91. Phing All The Things - Omni Adams

    View Slide

  92. Phing All The Things - Omni Adams

    View Slide

  93. Phing All The Things - Omni Adams
    •  Omni Adams
    •  @omnicolor
    •  http://omni-spot.blogspot.com
    •  [email protected]
    •  https://joind.in/11182

    View Slide