6compareCest.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 -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);
  48. $directorioA = array('01_login/','02_base/','03_ftth/','04_map/');
  49. for ($i = 0; $i < 4; $i++)
  50. {
  51. $dir = $directorioA[$i];
  52. $directorio = opendir("./tests/comp/". $fecha . "_" . $hora . "_" . $head . "/" . $dir);
  53. while ($archivo = readdir($directorio))
  54. {
  55. if (is_dir($archivo))
  56. {
  57. }
  58. else
  59. {
  60. $result = $s3->putObject(array(
  61. 'Bucket' => 'comparaciones',
  62. 'Key' => $fecha . "_" . $hora . "_" . $head . '/' . $dir . $archivo,
  63. 'SourceFile' => './tests/comp/' . $fecha . "_" . $hora . "_" . $head . "/" . $dir . $archivo
  64. ));
  65. // We can poll the object until it is accessible
  66. $s3->waitUntil('ObjectExists', array(
  67. 'Bucket' => 'comparaciones',
  68. 'Key' => $fecha . "_" . $hora . "_" . $head . '/' . $dir . $archivo
  69. ));
  70. 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);
  71. }
  72. }
  73. echo "Directorio de comparación '" . $dir . "' actualizado. Fecha: " . $fecha . "_" . $hora . " Commit: " . $head . "\n" ;
  74. }
  75. 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);
  76. }
  77. }