mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 00:50:18 +01:00 
			
		
		
		
	Allow Exclude to be defined globally.
This commit is contained in:
		
							parent
							
								
									ef72936c52
								
							
						
					
					
						commit
						0fe106610a
					
				@ -2,6 +2,7 @@ CHANGELOG for 3.X
 | 
				
			|||||||
=================
 | 
					=================
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* 3.2.0 (2017-04-xx)
 | 
					* 3.2.0 (2017-04-xx)
 | 
				
			||||||
 | 
					 * Allow to define excludes in the global scope.
 | 
				
			||||||
 * Improve code quality, remove duplications on Symfony Tasks.
 | 
					 * Improve code quality, remove duplications on Symfony Tasks.
 | 
				
			||||||
 * Improve code quality, remove duplications on Composer Tasks.
 | 
					 * Improve code quality, remove duplications on Composer Tasks.
 | 
				
			||||||
 * [PR#364] Allow to define custom timeout to Composer:Install
 | 
					 * [PR#364] Allow to define custom timeout to Composer:Install
 | 
				
			||||||
 | 
				
			|||||||
@ -54,7 +54,7 @@ class RsyncTask extends AbstractTask
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    protected function getExcludes()
 | 
					    protected function getExcludes()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $excludes = $this->runtime->getEnvOption('exclude', []);
 | 
					        $excludes = $this->runtime->getMergedOption('exclude', []);
 | 
				
			||||||
        $excludes = array_merge(['.git'], array_filter($excludes));
 | 
					        $excludes = array_merge(['.git'], array_filter($excludes));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach ($excludes as &$exclude) {
 | 
					        foreach ($excludes as &$exclude) {
 | 
				
			||||||
 | 
				
			|||||||
@ -51,7 +51,7 @@ class PrepareTask extends AbstractTask
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    protected function getExcludes()
 | 
					    protected function getExcludes()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $excludes = $this->runtime->getEnvOption('exclude', []);
 | 
					        $excludes = $this->runtime->getMergedOption('exclude', []);
 | 
				
			||||||
        $excludes = array_merge(['.git'], array_filter($excludes));
 | 
					        $excludes = array_merge(['.git'], array_filter($excludes));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach ($excludes as &$exclude) {
 | 
					        foreach ($excludes as &$exclude) {
 | 
				
			||||||
 | 
				
			|||||||
@ -80,6 +80,36 @@ class DeployCommandMiscTasksTest extends TestCase
 | 
				
			|||||||
        $this->assertEquals(0, $tester->getStatusCode());
 | 
					        $this->assertEquals(0, $tester->getStatusCode());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function testGlobalExcludeFlags()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $application = new MageApplicationMockup(__DIR__ . '/../../Resources/global-exclude.yml');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /** @var AbstractCommand $command */
 | 
				
			||||||
 | 
					        $command = $application->find('deploy');
 | 
				
			||||||
 | 
					        $this->assertTrue($command instanceof DeployCommand);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $tester = new CommandTester($command);
 | 
				
			||||||
 | 
					        $tester->execute(['command' => $command->getName(), 'environment' => 'test']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $ranCommands = $application->getRuntime()->getRanCommands();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $testCase = array(
 | 
				
			||||||
 | 
					            0 => '/usr/bin/composer.phar install --prefer-source',
 | 
				
			||||||
 | 
					            1 => '/usr/bin/composer.phar dump-autoload --no-scripts',
 | 
				
			||||||
 | 
					            2 => 'rsync -e "ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" -avz --exclude=.git --exclude=./var/cache/* --exclude=./var/log/* --exclude=./web/app_dev.php ./ tester@testhost:/var/www/test',
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Check total of Executed Commands
 | 
				
			||||||
 | 
					        $this->assertEquals(count($testCase), count($ranCommands));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Check Generated Commands
 | 
				
			||||||
 | 
					        foreach ($testCase as $index => $command) {
 | 
				
			||||||
 | 
					            $this->assertEquals($command, $ranCommands[$index]);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->assertEquals(0, $tester->getStatusCode());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function testComposerEnvFlags()
 | 
					    public function testComposerEnvFlags()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $application = new MageApplicationMockup(__DIR__ . '/../../Resources/composer-env.yml');
 | 
					        $application = new MageApplicationMockup(__DIR__ . '/../../Resources/composer-env.yml');
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										17
									
								
								tests/Resources/global-exclude.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								tests/Resources/global-exclude.yml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					magephp:
 | 
				
			||||||
 | 
					    log_dir: /tmp
 | 
				
			||||||
 | 
					    composer:
 | 
				
			||||||
 | 
					        path: /usr/bin/composer.phar
 | 
				
			||||||
 | 
					    exclude:
 | 
				
			||||||
 | 
					        - ./var/cache/*
 | 
				
			||||||
 | 
					        - ./var/log/*
 | 
				
			||||||
 | 
					        - ./web/app_dev.php
 | 
				
			||||||
 | 
					    environments:
 | 
				
			||||||
 | 
					        test:
 | 
				
			||||||
 | 
					            user: tester
 | 
				
			||||||
 | 
					            host_path: /var/www/test
 | 
				
			||||||
 | 
					            hosts:
 | 
				
			||||||
 | 
					                - testhost
 | 
				
			||||||
 | 
					            pre-deploy:
 | 
				
			||||||
 | 
					                - composer/install: { flags: '--prefer-source' }
 | 
				
			||||||
 | 
					                - composer/dump-autoload: { flags: '--no-scripts' }
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user