Browse Source

test gitlab-ci

drone 6 năm trước cách đây
mục cha
commit
635b9e8310
3 tập tin đã thay đổi với 33 bổ sung31 xóa
  1. 1 1
      .gitlab-ci.yml
  2. 1 0
      tools/cmd.php
  3. 31 30
      tools/src/ComposerRequireCommand.php

+ 1 - 1
.gitlab-ci.yml

@@ -71,7 +71,7 @@ installer_tag:
     - php cmd.php make:installImages $(pwd) --client='develop' --develop=1
     - chmod 0600 keys/bitbucket.id_rsa ; eval $(ssh-agent); ssh-add keys/bitbucket.id_rsa ; php cmd.php make:tag:vendors repositories.ini ${CI_COMMIT_TAG}
     - chmod 0600 keys/bitbucket.id_rsa ; eval $(ssh-agent); ssh-add keys/bitbucket.id_rsa ; php cmd.php get:source git.ini --timeout=120
-    - chmod 0600 keys/bitbucket.id_rsa ; eval $(ssh-agent); ssh-add keys/bitbucket.id_rsa ; php cmd.php composer:require git.ini 'ik/*' ${CI_COMMIT_TAG}
+    - chmod 0600 keys/bitbucket.id_rsa ; eval $(ssh-agent); ssh-add keys/bitbucket.id_rsa ; php cmd.php composer:require git.ini 'ik/*' ${CI_COMMIT_TAG} --composer_update=0
     - chmod 0600 keys/bitbucket.id_rsa ; eval $(ssh-agent); ssh-add keys/bitbucket.id_rsa ; php cmd.php make:tag:modules git.ini ${CI_COMMIT_TAG}
   only:
     refs:

+ 1 - 0
tools/cmd.php

@@ -24,5 +24,6 @@ $app->add(new FD3\UpdateFlowdatModulesCommand());
 $app->add(new FD3\Command\ImportONUCommand());
 $app->add(new FD3\Command\TagVendorsCommand());
 $app->add(new FD3\Command\TagModulesCommand());
+$app->add(new FD3\Command\TagDeleteVendorsCommand());
 
 $app->run();

+ 31 - 30
tools/src/ComposerRequireCommand.php

@@ -3,8 +3,8 @@
 namespace FD3;
 
 use Symfony\Component\Console\Command\Command;
-use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Output\OutputInterface;
 
@@ -18,9 +18,9 @@ class ComposerRequireCommand extends Command
             ->setHelp('This command allows you to tag and change the required code on the composer.json file...')
             ->addArgument('ini_file', InputArgument::REQUIRED, 'The ini file from where to get the source code config.')
             ->addArgument('packages', InputArgument::REQUIRED, 'Tag the required packages (suggested value : ik/*).')
-	    ->addArgument('version', InputArgument::REQUIRED, 'Use the version expression.')
-	    ->addOption('composer_update', null, InputOption::VALUE_OPTIONAL, 'If true, run "docker-compose run ... bin/composer-update.sh" to generate composer.lock', 'true')
-	    ->addOption('pull', null, InputOption::VALUE_OPTIONAL, 'Indicates branch to pull for every modules', '');
+            ->addArgument('version', InputArgument::REQUIRED, 'Use the version expression.')
+            ->addOption('composer_update', null, InputOption::VALUE_OPTIONAL, 'If true, run "docker-compose run ... bin/composer-update.sh" to generate composer.lock', 'true')
+            ->addOption('pull', null, InputOption::VALUE_OPTIONAL, 'Indicates branch to pull for every modules', '');
     }
 
     protected function execute(InputInterface $input, OutputInterface $output)
@@ -43,54 +43,55 @@ class ComposerRequireCommand extends Command
                 $output->writeln("----------------------------------------------------------------------");
                 $output->writeln($sec);
                 $composer_data = json_decode(file_get_contents($composer_file), true);
-		try {
+                try {
                     foreach (array("require", "require-dev") as $k) {
-		        $output->writeln('Ejecutando:');
-		        $command = 'cd ' . $sec . '; git stash; git fetch; git checkout master; git pull origin master';
-		        $output->writeln("\t" . $command);
+                        $output->writeln('Ejecutando:');
+                        $command = 'cd ' . $sec . '; git stash; git fetch; git checkout master; git pull origin master';
+                        $output->writeln("\t" . $command);
                         shell_exec($command);
                         if (strlen($pull) > 0) {
-		            $command = 'cd ' . $sec . '; git pull origin ' . $pull;
-		            $output->writeln("\t" . $command);
+                            $command = 'cd ' . $sec . '; git pull origin ' . $pull;
+                            $output->writeln("\t" . $command);
                             shell_exec($command);
                         }
-		        $output->writeln("\t" . 'Reemplazo composer.json');
+                        $output->writeln("\t" . 'Reemplazo composer.json');
                         foreach ($composer_data[$k] as $package => $version) {
                             if (strpos($packages, "*") !== false) {
                                 $preg = "|^" . str_replace("*", "[^\b]*", $packages) . "$|";
                                 if (preg_match($preg, $package)) {
-                                    $composer_data[$k][$package] = (string)$new_version;
+                                    $composer_data[$k][$package] = (string) $new_version;
                                     $output->writeln("\t\t" . $package . " = " . $new_version);
                                 }
-			    } else {
+                            } else {
                                 if (strcmp($packages, $package) === 0) {
-                                    $composer_data[$k][$package] = (string)$new_version;
-				    $output->writeln("\t\t" . $package . " = " . $new_version);
+                                    $composer_data[$k][$package] = (string) $new_version;
+                                    $output->writeln("\t\t" . $package . " = " . $new_version);
                                 }
                             }
                         }
                     }
                     file_put_contents($composer_file, json_encode($composer_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
-		    if ($dockerCompose) {
-		        $output->writeln('Composer update');
-		        $command = 'docker-compose exec ' . $sec . ' bin/composer-update.sh';
-		        $output->writeln("\t" . $command);
-			$resp = shell_exec($command);
-			if ($resp) {
-			    $output->writeln("\tSalida comando."); 
-			    $output->writeln("\t\t" . $resp); 
-			}
+                    $output->writeln('Composer update');
+                    if ($dockerCompose) {
+                        $command = 'docker-compose exec ' . $sec . ' bin/composer-update.sh';
+                    } else {
+                        $command = 'bash bin/composer-update.sh';
                     }
-		} catch (Throwable $t) {
-		    $output->writeln('Se produjo un error. Reestableciendo datos.');
-		    $command = 'cd ' . $sec . '; git reset';
-		    $output->writeln("\t" . $command);
+                    $output->writeln("\t" . $command);
+                    $resp = shell_exec($command);
+                    if ($resp) {
+                        $output->writeln("\tSalida comando.");
+                        $output->writeln("\t\t" . $resp);
+                    }
+                } catch (Throwable $t) {
+                    $output->writeln('Se produjo un error. Reestableciendo datos.');
+                    $command = 'cd ' . $sec . '; git reset';
+                    $output->writeln("\t" . $command);
                     $shell_exec($command);
-		}
+                }
             } else {
                 $output->writeln($sec . " no composer.json found");
             }
         }
     }
 }
-