6compareCest.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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/');
  13. for ($i = 0; $i < 4; $i++)
  14. {
  15. $directorio = $directorioA[$i];
  16. shell_exec('mkdir -p ./tests/comp/' . $fecha . "_" . $hora . "_" . $head . "/" . $directorio);
  17. $dir = opendir("tests/_output/debug/" . $head . "/" . $directorio);
  18. while ($archivo = readdir($dir))
  19. {
  20. if (is_dir($archivo))
  21. {
  22. }
  23. else
  24. {
  25. shell_exec('compare tests/_output/debug/'.$head."/". $directorio . $archivo . ' tests/to_compare/'.$head1."/". $directorio . $archivo . ' tests/comp/' . $fecha . "_" . $hora . "_" . $head . "/" . $directorio .'comp'. $archivo . "\n");
  26. }
  27. }
  28. }
  29. //subo comparaciones
  30. date_default_timezone_set('America/Argentina/Buenos_Aires');
  31. require 'vendor/autoload.php';
  32. $s3 = new Aws\S3\S3Client([
  33. 'version' => 'latest',
  34. 'region' => 'sa-east-1',
  35. 'endpoint' => 'https://s3.infra.flowdat.com/minio/login',
  36. 'use_path_style_endpoint' => true,
  37. 'credentials' => [
  38. 'key' => 'iksop',
  39. 'secret' => '8htoiwn44g204th',
  40. ],
  41. ]);
  42. //subo al HipChat
  43. $ROOM_ID="drone-ci";
  44. $AUTH_TOKEN="umxTgNpdzUS4egXqpZvGmmYrpLWApANHBKUcciMk";
  45. $MESSAGE1="Inicio Commit ID: " . $head;
  46. $MESSAGE2="Fin Commit ID: " . $head;
  47. shell_exec('curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer qGKQBdZpcRFxPCwoHYZI" -d \'{"body":{"version":1,"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"'.$MESSAGE1.'"}]}]}}\' --url "https://api.atlassian.com/site/9a250d57-9fd5-44d1-b514-e8664f32952e/conversation/7a10296d-521a-4b7b-a927-8bd8275bdf86/message"');
  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/');
  50. for ($i = 0; $i < 4; $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. $token = 'qGKQBdZpcRFxPCwoHYZI';
  72. $cloudId = '9a250d57-9fd5-44d1-b514-e8664f32952e';
  73. $conversationId = '7a10296d-521a-4b7b-a927-8bd8275bdf86';
  74. $filename = 'tests/comp/' . $fecha . '_' . $hora . '_' . $head . '/' . $dir . $archivo;
  75. $path = '/home/iksop/Escritorio/te/installer/behat/testScreenshot/'.$filename;
  76. $command = "curl --request POST --header 'Authorization: Bearer {$token}' --header 'Accept: application/json' --header 'Content-Type: application/octet-stream' --url 'https://api.atlassian.com/site/{$cloudId}/conversation/{$conversationId}/media?name={$filename}' --data-binary '@{$path}'";
  77. var_dump($command);
  78. $upload = shell_exec($command);
  79. var_dump($upload);
  80. $upload = json_decode($upload, true);
  81. $message = shell_exec("curl -X POST -H 'Content-Type: application/json' -H 'Authorization: Bearer {$token}' -d '{\"body\":{\"version\":1,\"type\":\"doc\",\"content\":[{\"type\":\"mediaGroup\",\"content\":[{\"type\":\"media\",\"attrs\":{\"type\":\"file\",\"id\":\"{$upload['data']['id']}\",\"collection\":\"{$conversationId}\"}}]}]}}' --url 'https://api.atlassian.com/site/{$cloudId}/conversation/{$conversationId}/message'");
  82. var_dump($message);
  83. }
  84. }
  85. echo "Directorio de comparación '" . $dir . "' actualizado. Fecha: " . $fecha . "_" . $hora . " Commit: " . $head . "\n" ;
  86. }
  87. shell_exec('curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer qGKQBdZpcRFxPCwoHYZI" -d \'{"body":{"version":1,"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"'.$MESSAGE2.'"}]}]}}\' --url "https://api.atlassian.com/site/9a250d57-9fd5-44d1-b514-e8664f32952e/conversation/7a10296d-521a-4b7b-a927-8bd8275bdf86/message"');
  88. }
  89. }