7compareCest.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. class compareCest
  3. {
  4. public function compare(AcceptanceTester $I)
  5. {
  6. $hora = date("H:i");
  7. $fecha = date("Y-n-j");
  8. $head = shell_exec('git rev-parse HEAD');
  9. $head = substr($head,0,-1);
  10. $head1 = shell_exec('git rev-parse HEAD~1');
  11. $head1 = substr($head1,0,-1);
  12. $directorioA = array('01_login/','02_base/','03_ftth/','04_map/','05_stats/');
  13. $cantdir= count($directorioA);
  14. for ($i = 0; $i < $cantdir; $i++)
  15. {
  16. $directorio = $directorioA[$i];
  17. shell_exec('mkdir -p ./tests/comp/' . $fecha . "_" . $hora . "_" . $head . "/" . $directorio);
  18. $dir = opendir("tests/_output/debug/" . $head . "/" . $directorio);
  19. while ($archivo = readdir($dir))
  20. {
  21. if (is_dir($archivo))
  22. {
  23. }
  24. else
  25. {
  26. shell_exec('compare tests/_output/debug/'.$head."/". $directorio . $archivo . ' tests/to_compare/'.$head1."/". $directorio . $archivo . ' tests/comp/' . $fecha . "_" . $hora . "_" . $head . "/" . $directorio .'comp'. $archivo . "\n");
  27. }
  28. }
  29. }
  30. //subo comparaciones
  31. date_default_timezone_set('America/Argentina/Buenos_Aires');
  32. require 'vendor/autoload.php';
  33. $s3 = new Aws\S3\S3Client([
  34. 'version' => 'latest',
  35. 'region' => 'sa-east-1',
  36. 'endpoint' => 'https://s3.infra.flowdat.com/minio/login',
  37. 'use_path_style_endpoint' => true,
  38. 'credentials' => [
  39. 'key' => 'iksop',
  40. 'secret' => '8htoiwn44g204th',
  41. ],
  42. ]);
  43. //subo al HipChat
  44. $ROOM_ID="drone-ci";
  45. $AUTH_TOKEN="umxTgNpdzUS4egXqpZvGmmYrpLWApANHBKUcciMk";
  46. $MESSAGE1="Inicio Commit ID: " . $head;
  47. $MESSAGE2="Fin Commit ID: " . $head;
  48. shell_exec('curl -H "Content-Type: application/json" -X POST -d "{\"color\": \"purple\", \"message_format\": \"text\", \"message\": \"' . $MESSAGE1 . '\" }" https://api.hipchat.com/v2/room/' . $ROOM_ID . '/notification?auth_token=' . $AUTH_TOKEN);
  49. $directorioA = array('01_login/','02_base/','03_ftth/','04_map/','05_stats');
  50. for ($i = 0; $i < $cantdir; $i++)
  51. {
  52. $dir = $directorioA[$i];
  53. $directorio = opendir("./tests/comp/". $fecha . "_" . $hora . "_" . $head . "/" . $dir);
  54. while ($archivo = readdir($directorio))
  55. {
  56. if (is_dir($archivo))
  57. {
  58. }
  59. else
  60. {
  61. $result = $s3->putObject(array(
  62. 'Bucket' => 'comparaciones',
  63. 'Key' => $fecha . "_" . $hora . "_" . $head . '/' . $dir . $archivo,
  64. 'SourceFile' => './tests/comp/' . $fecha . "_" . $hora . "_" . $head . "/" . $dir . $archivo
  65. ));
  66. // We can poll the object until it is accessible
  67. $s3->waitUntil('ObjectExists', array(
  68. 'Bucket' => 'comparaciones',
  69. 'Key' => $fecha . "_" . $hora . "_" . $head . '/' . $dir . $archivo
  70. ));
  71. shell_exec('curl -H "Content-Type: multipart/related; boundary=boundary123456" -F "file=@tests/comp/' . $fecha . '_' . $hora . '_' . $head . '/' . $dir . $archivo.'" -X POST https://api.hipchat.com/v2/room/'.$ROOM_ID.'/share/file?auth_token='.$AUTH_TOKEN);
  72. }
  73. }
  74. echo "Directorio de comparación '" . $dir . "' actualizado. Fecha: " . $fecha . "_" . $hora . " Commit: " . $head . "\n" ;
  75. }
  76. shell_exec('curl -H "Content-Type: application/json" -X POST -d "{\"color\": \"purple\", \"message_format\": \"text\", \"message\": \"' . $MESSAGE2 . '\" }" https://api.hipchat.com/v2/room/' . $ROOM_ID . '/notification?auth_token=' . $AUTH_TOKEN);
  77. }
  78. }