Skip to content

Commit

Permalink
[FEATURE] Add relativeProjectRootPath to deployment (#404)
Browse files Browse the repository at this point in the history
* [FEATURE] Add relativeProjectRootPath to deployment
  • Loading branch information
simonschaufi committed May 30, 2020
1 parent 8c97c95 commit f4d4f51
Show file tree
Hide file tree
Showing 13 changed files with 1,276 additions and 514 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/php_cs_fixer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Format (PHP)

on:
pull_request:
branches:
- master
- 2.0

jobs:
php-cs-fixer:
runs-on: ubuntu-latest
# dont run jobs on forks, because we are not allowed to commit
if: github.event.pull_request.draft == false && github.repository == 'TYPO3/Surf'

steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}

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

- uses: shivammathur/setup-php@v2
with:
php-version: 7.2
coverage: none # disable xdebug, pcov

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

- name: Install Composer Dependencies
run: composer install --no-progress

- name: Run php-cs-fixer
run: vendor/bin/php-cs-fixer fix --config=./.php_cs --diff

- name: Commit changed files
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply php-cs-fixer changes
branch: ${{ github.head_ref }}
28 changes: 28 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Tests

on: [push, pull_request]

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.2', '7.3', '7.4']

name: PHP ${{ matrix.php }} tests
steps:
- uses: actions/checkout@v2.0.0
- id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- uses: shivammathur/setup-php@v1
with:
php-version: ${{ matrix.php }}
coverage: none # disable xdebug, pcov
- run: composer install --no-suggest --no-progress
- run: vendor/bin/phpunit
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
phpunit.xml
vendor/
.php_cs.cache
.php_cs
# The Api reference is auto generated and should not be part of the repository
/Documentation-GENERATED-temp
sphpdox.phar
Expand Down
1 change: 0 additions & 1 deletion .php_cs.dist → .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ $finder = PhpCsFixer\Finder::create()
->exclude('.github')
->exclude('Configuration')
->exclude('Documentation')
->exclude('Migrations')
->exclude('Resources')
->exclude('vendor')
->in(__DIR__);
Expand Down
9 changes: 4 additions & 5 deletions Documentation/DeploymentFlow/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ If you like to add your own tasks to a specific stage of the flow, you can just
// Add tasks that shall be executed before the given stage
$workflow->beforeStage('YourTask', 'cleanup');

// Add tasks that shall be executed before the given task
$workflow->beforeTask(CreatePackageStatesTask::class, 'YourTask');
// Add tasks that shall be executed before the given task
$workflow->beforeTask(AnotherTask::class, 'YourTask');

// Add tasks that shall be executed after the given task
$workflow->afterTask(CreatePackageStatesTask::class, 'YourTask');
// Add tasks that shall be executed after the given task
$workflow->afterTask(AnotherTask::class, 'YourTask');

If you like to remove certain tasks from the flow, just do it like that::

Expand All @@ -94,4 +94,3 @@ If you like to remove certain tasks from the flow, just do it like that::

// Only remove the task for a specific application
$workflow->removeTask(FlushCachesTask::class, $application);

4 changes: 2 additions & 2 deletions Migrations/Code/LegacyClassMap.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
return array (
return [
'typo3.surf:cleanupreleases' => 'TYPO3\\Surf\\Task\\CleanupReleasesTask',
'typo3.surf:composer:download' => 'TYPO3\\Surf\\Task\\Composer\\DownloadTask',
'typo3.surf:composer:install' => 'TYPO3\\Surf\\Task\\Composer\\InstallTask',
Expand Down Expand Up @@ -54,4 +54,4 @@
'createtargzdistribution' => 'TYPO3\\Surf\\DefinedTask\\CreateTarGzDistributionTask',
'createtarbz2distribution' => 'TYPO3\\Surf\\DefinedTask\\CreateTarBz2DistributionTask',
'pushtags' => 'TYPO3\\Surf\\DefinedTask\\Git\\PushTagsTask',
);
];
45 changes: 41 additions & 4 deletions Tests/Unit/Domain/Model/DeploymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class DeploymentTest extends TestCase
/**
* @test
*/
public function initializeUsesSimpleWorkflowAsDefault()
public function initializeUsesSimpleWorkflowAsDefault(): void
{
$deployment = new Deployment('Test deployment');
$deployment->initialize();
Expand All @@ -34,7 +34,7 @@ public function initializeUsesSimpleWorkflowAsDefault()
/**
* @test
*/
public function getNodesReturnsNodesFromApplicationsAsSet()
public function getNodesReturnsNodesFromApplicationsAsSet(): void
{
$deployment = new Deployment('Test deployment');
$application1 = new Application('Test application 1');
Expand All @@ -51,7 +51,7 @@ public function getNodesReturnsNodesFromApplicationsAsSet()
->addApplication($application2);

$nodes = $deployment->getNodes();
$nodeNames = array_map(function ($node) {
$nodeNames = array_map(static function (Node $node) {
return $node->getName();
}, $nodes);
sort($nodeNames);
Expand All @@ -62,7 +62,7 @@ public function getNodesReturnsNodesFromApplicationsAsSet()
/**
* @test
*/
public function constructorCreatesReleaseIdentifier()
public function constructorCreatesReleaseIdentifier(): void
{
$deployment = new Deployment('Test deployment');

Expand Down Expand Up @@ -119,6 +119,43 @@ public function deploymentHasLockIdentifierDefinedByEnvironmentVariable()
$this->assertEquals($deploymentLockIdentifier, $deployment->getDeploymentLockIdentifier());
}

/**
* @test
*/
public function deploymentContainsRelativeProjectRootPathForApplicationReleasePath(): void
{
$deployment = new Deployment('Some name');

$application = new Application('Test application 1');
$application->setDeploymentPath('/deployment/path');

$releaseIdentifier = $deployment->getReleaseIdentifier();

$this->assertEquals(
'/deployment/path/releases/' . $releaseIdentifier,
$deployment->getApplicationReleasePath($application)
);
}

/**
* @test
*/
public function deploymentContainsChangedRelativeProjectRootPathForApplicationReleasePath(): void
{
$deployment = new Deployment('Some name');
$deployment->setRelativeProjectRootPath('htdocs');

$application = new Application('Test application 1');
$application->setDeploymentPath('/deployment/path');

$releaseIdentifier = $deployment->getReleaseIdentifier();

$this->assertEquals(
'/deployment/path/releases/' . $releaseIdentifier . '/htdocs',
$deployment->getApplicationReleasePath($application)
);
}

/**
* @return array
*/
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "TYPO3 Surf is a deployment tool, suited for a wide variety of applications",
"license": "GPL-3.0-or-later",
"require": {
"php": "^5.6 || >=7.0 <7.4",
"php": "^5.6 || >=7.0 <7.5",
"monolog/monolog": "^1.17",
"neos/utility-files": "^3.0",
"padraic/phar-updater": "1.0.5",
Expand Down
Loading

0 comments on commit f4d4f51

Please sign in to comment.