123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <?php
- class compareCest
- {
- public function compare(AcceptanceTester $I)
- {
- $hora = date("H:i");
- $fecha = date("Y-n-j");
- $head = shell_exec('git rev-parse HEAD');
- $head = substr($head,0,-1);
- $head1 = shell_exec('git rev-parse HEAD~1');
- $head1 = substr($head1,0,-1);
- $directorioA = array('01_login/','02_base/','03_ftth/','04_map/');
- for ($i = 0; $i < 4; $i++)
- {
- $directorio = $directorioA[$i];
- shell_exec('mkdir -p ./tests/comp/' . $fecha . "_" . $hora . "_" . $head . "/" . $directorio);
- $dir = opendir("tests/_output/debug/" . $head . "/" . $directorio);
- while ($archivo = readdir($dir))
- {
- if (is_dir($archivo))
- {
- }
- else
- {
- shell_exec('compare tests/_output/debug/'.$head."/". $directorio . $archivo . ' tests/to_compare/'.$head1."/". $directorio . $archivo . ' tests/comp/' . $fecha . "_" . $hora . "_" . $head . "/" . $directorio .'comp'. $archivo . "\n");
- }
- }
- }
- //subo comparaciones
- date_default_timezone_set('America/Argentina/Buenos_Aires');
- require 'vendor/autoload.php';
- $s3 = new Aws\S3\S3Client([
- 'version' => 'latest',
- 'region' => 'sa-east-1',
- 'endpoint' => 'https://s3.infra.flowdat.com/minio/login',
- 'use_path_style_endpoint' => true,
- 'credentials' => [
- 'key' => 'iksop',
- 'secret' => '8htoiwn44g204th',
- ],
- ]);
- //subo al HipChat
- $ROOM_ID="drone-ci";
- $AUTH_TOKEN="umxTgNpdzUS4egXqpZvGmmYrpLWApANHBKUcciMk";
- $MESSAGE1="Inicio Commit ID: " . $head;
- $MESSAGE2="Fin Commit ID: " . $head;
- 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"');
- # 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);
- $directorioA = array('01_login/','02_base/','03_ftth/','04_map/');
- for ($i = 0; $i < 4; $i++)
- {
- $dir = $directorioA[$i];
- $directorio = opendir("./tests/comp/". $fecha . "_" . $hora . "_" . $head . "/" . $dir);
- while ($archivo = readdir($directorio))
- {
- if (is_dir($archivo))
- {
- }
- else
- {
- $result = $s3->putObject(array(
- 'Bucket' => 'comparaciones',
- 'Key' => $fecha . "_" . $hora . "_" . $head . '/' . $dir . $archivo,
- 'SourceFile' => './tests/comp/' . $fecha . "_" . $hora . "_" . $head . "/" . $dir . $archivo
- ));
- // We can poll the object until it is accessible
- $s3->waitUntil('ObjectExists', array(
- 'Bucket' => 'comparaciones',
- 'Key' => $fecha . "_" . $hora . "_" . $head . '/' . $dir . $archivo
- ));
-
- $token = 'qGKQBdZpcRFxPCwoHYZI';
- $cloudId = '9a250d57-9fd5-44d1-b514-e8664f32952e';
- $conversationId = '7a10296d-521a-4b7b-a927-8bd8275bdf86';
- $filename = 'tests/comp/' . $fecha . '_' . $hora . '_' . $head . '/' . $dir . $archivo;
- $path = '/home/iksop/Escritorio/te/installer/behat/testScreenshot/'.$filename;
- $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}'";
- var_dump($command);
- $upload = shell_exec($command);
- var_dump($upload);
- $upload = json_decode($upload, true);
- $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'");
- var_dump($message);
- }
- }
- echo "Directorio de comparación '" . $dir . "' actualizado. Fecha: " . $fecha . "_" . $hora . " Commit: " . $head . "\n" ;
- }
- 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"');
- }
- }
|