Skip to content

Commit

Permalink
Merge pull request #57 from open-sausages/pulls/2.0/archive-recipes
Browse files Browse the repository at this point in the history
API Restore archive and upload steps
  • Loading branch information
robbieaverill authored Oct 11, 2017
2 parents 4b172ec + 902c0c3 commit 2c77958
Show file tree
Hide file tree
Showing 23 changed files with 695 additions and 379 deletions.
17 changes: 13 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,25 @@ language: php

php: 5.6

dist: trusty

env:
matrix:
- PHPUNIT_TEST=1
- PHPCS_TEST=1

before_script:
- composer install --dev --prefer-dist
- pyrus install pear/PHP_CodeSniffer
# php setup
- phpenv rehash
- export PATH=~/.composer/vendor/bin:$PATH

# phpcs setup
- if [[ $PHPCS_TEST ]]; then composer global require squizlabs/php_codesniffer:^3 --prefer-dist --no-interaction --no-progress --no-suggest -o; fi

# Install
- composer validate
- composer install --dev --prefer-dist

script:
- "if [ \"$PHPUNIT_TEST\" = \"1\" ]; then vendor/bin/phpunit tests; fi"
- "if [ \"$PHPCS_TEST\" = \"1\" ]; then phpcs --standard=PSR2 bin/ src/ tests/; fi"
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit tests; fi
- if [[ $PHPCS_TEST ]]; then phpcs --standard=PSR2 bin/ src/ tests/; fi
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"gitonomy/gitlib": "~1.0",
"psr/log": "^1",
"knplabs/github-api": "^2.1",
"php-http/guzzle6-adapter": "^1.1.1"
"php-http/guzzle6-adapter": "^1.1.1",
"justinrainbow/json-schema": "^5.2"
},
"require-dev": {
"phpunit/phpunit": "^5.7"
Expand Down
16 changes: 16 additions & 0 deletions cow-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ Basic options are:
"vendor/bin/phpunit framework/admin/tests",
"vendor/bin/phpunit framework/tests",
"vendor/bin/phpunit cms/tests"
],
"archives": [
{
"recipe": "silverstripe/recipe-core",
"files": [
"SilverStripe-framework-v{version}.zip",
"SilverStripe-framework-v{version}.tar.gz",
]
},
{
"recipe": "silverstripe/installer",
"files": [
"SilverStripe-cms-v{version}.zip",
"SilverStripe-cms-v{version}.tar.gz",
]
}
]
}
```
82 changes: 82 additions & 0 deletions cow.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "cow",
"description": "cow release settings file",
"type": "object",
"properties": {
"github-slug": {
"type": "string"
},
"commit-link": {
"type": "string"
},
"changelog-holder": {
"type": "string"
},
"changelog-path": {
"type": "string"
},
"changelog-type": {
"type": "string",
"enum": [
"flat",
"grouped"
]
},
"changelog-github": {
"type": "boolean"
},
"child-stability-inherit": {
"type": "boolean"
},
"dependency-constraint": {
"type": "string",
"enum": [
"exact",
"loose",
"semver"
]
},
"vendors": {
"type": "array",
"items": {
"type": "string"
}
},
"exclude": {
"type": "array",
"items": {
"type": "string"
}
},
"upgrade-only": {
"type": "array",
"items": {
"type": "string"
}
},
"tests": {
"type": "array",
"items": {
"type": "string"
}
},
"archives": {
"type": "array",
"items": {
"type": "object",
"properties": {
"recipe": {
"type": "string"
},
"files": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
}
31 changes: 30 additions & 1 deletion src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,39 @@
namespace SilverStripe\Cow;

use SilverStripe\Cow\Commands;
use SilverStripe\Cow\Utility\Config;
use Symfony\Component\Console;

class Application extends Console\Application
{
/**
* Get version of this module
*
* @param string $directory
* @return string
*/
protected function getVersionInDir($directory)
{
if (!$directory) {
return null;
}
$installed = $directory . '/vendor/composer/installed.json';
if (file_exists($installed)) {
$content = Config::loadFromFile($installed);
foreach ($content as $library) {
if ($library['name'] == 'silverstripe/cow') {
return $library['version'];
}
}
}
return $this->getVersionInDir(dirname($directory));
}


public function getLongVersion()
{
return '<info>cow release tool</info>';
$version = $this->getVersionInDir(__DIR__);
return "<comment>cow release tool</comment> <info>{$version}</info>";
}

/**
Expand All @@ -29,7 +55,10 @@ protected function getDefaultCommands()
$commands[] = new Commands\Release\Translate();
$commands[] = new Commands\Release\Test();
$commands[] = new Commands\Release\ChangeLog();

// Publish sub-commands
$commands[] = new Commands\Release\Tag();
$commands[] = new Commands\Release\Wait();
$commands[] = new Commands\Release\Archive();
$commands[] = new Commands\Release\Upload();

Expand Down
25 changes: 11 additions & 14 deletions src/Commands/Release/Archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
namespace SilverStripe\Cow\Commands\Release;

use SilverStripe\Cow\Steps\Release\BuildArchive;
use SilverStripe\Cow\Steps\Release\WaitStep;

/**
* Create archives
*
* @author dmooyman
* Create local archives for this release to upload later to s3
*/
class Archive extends Publish
{
Expand All @@ -20,18 +19,16 @@ class Archive extends Publish

protected function fire()
{
throw new \Exception("Not implemented");

// @todo - Implement archive / upload steps

/*
// Get arguments
$version = $this->getInputVersion();
$recipe = $this->getInputRecipe();
$directory = $this->getInputDirectory($version, $recipe);
$project = $this->getProject();
$releasePlan = $this->getReleasePlan();

// Ensure we wait, even if just building archive
$wait = new WaitStep($this, $project, $releasePlan);
$wait->run($this->input, $this->output);

// Steps
$step = new BuildArchive($this, $version, $directory);
$step->run($this->input, $this->output);*/
// Create packages
$package = new BuildArchive($this, $project, $releasePlan);
$package->run($this->input, $this->output);
}
}
11 changes: 2 additions & 9 deletions src/Commands/Release/Branch.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,11 @@

namespace SilverStripe\Cow\Commands\Release;

use SilverStripe\Cow\Commands\Command;
use SilverStripe\Cow\Model\Modules\Project;
use SilverStripe\Cow\Steps\Release\CreateBranch;
use SilverStripe\Cow\Steps\Release\RewriteReleaseBranches;
use SilverStripe\Cow\Steps\Release\PlanRelease;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use SilverStripe\Cow\Steps\Release\RewriteReleaseBranches;

/**
* Create a new branch
*
* @author dmooyman
* Create branches for this release
*/
class Branch extends Release
{
Expand Down
18 changes: 8 additions & 10 deletions src/Commands/Release/Publish.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

use Exception;
use SilverStripe\Cow\Model\Release\LibraryRelease;
use SilverStripe\Cow\Steps\Release\BuildArchive;
use SilverStripe\Cow\Steps\Release\PublishRelease;
use SilverStripe\Cow\Steps\Release\UploadArchive;
use SilverStripe\Cow\Steps\Release\WaitStep;
use Symfony\Component\Console\Input\InputOption;

/**
* Description of Create
*
* @author dmooyman
* Top level publish command
*/
class Publish extends Release
{
Expand All @@ -35,26 +36,23 @@ protected function fire()
// Get arguments
$project = $this->getProject();
$releasePlan = $this->getReleasePlan();
$awsProfile = $this->getInputAWSProfile();

// Does bulk of module publishing, rewrite of dev branches, rewrite of tags, and actual tagging
$publish = new PublishRelease($this, $project, $releasePlan);
$publish->run($this->input, $this->output);

// @todo - Implement archive / upload steps

/*
// Once pushed, wait until installable
$wait = new Wait($this, $version);
$wait = new WaitStep($this, $project, $releasePlan);
$wait->run($this->input, $this->output);

// Create packages
$package = new BuildArchive($this, $version, $directory);
$package = new BuildArchive($this, $project, $releasePlan);
$package->run($this->input, $this->output);

// Upload
$upload = new UploadArchive($this, $version, $directory, $awsProfile);
$upload = new UploadArchive($this, $project, $releasePlan, $awsProfile);
$upload->run($this->input, $this->output);
*/
}

/**
Expand Down
13 changes: 4 additions & 9 deletions src/Commands/Release/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,13 @@ class Upload extends Publish

protected function fire()
{
throw new \Exception("Not implemented");

// @todo - Implement archive / upload steps

/*
// Get arguments
$version = $this->getInputVersion();
$directory = $this->getInputDirectory($version);
$project = $this->getProject();
$releasePlan = $this->getReleasePlan();
$awsProfile = $this->getInputAWSProfile();

// Steps
$step = new UploadArchive($this, $version, $directory, $awsProfile);
$step->run($this->input, $this->output);*/
$upload = new UploadArchive($this, $project, $releasePlan, $awsProfile);
$upload->run($this->input, $this->output);
}
}
28 changes: 28 additions & 0 deletions src/Commands/Release/Wait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace SilverStripe\Cow\Commands\Release;

use Exception;
use SilverStripe\Cow\Model\Release\LibraryRelease;
use SilverStripe\Cow\Steps\Release\WaitStep;

/**
* Top level publish command
*/
class Wait extends Publish
{
protected $name = 'release:wait';

protected $description = 'Wait for this release to be available';

protected function fire()
{
// Get arguments
$project = $this->getProject();
$releasePlan = $this->getReleasePlan();

// Once pushed, wait until installable
$wait = new WaitStep($this, $project, $releasePlan);
$wait->run($this->input, $this->output);
}
}
Loading

0 comments on commit 2c77958

Please sign in to comment.