commit 5fb41346310fef8090812362bd52295556beca0e Author: James Date: Wed Sep 18 19:41:13 2019 +0100 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..011fdab --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/src/config.php +/vendor/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..2221d1a --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +Post PHPUnit test results to Gitea diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..1561f34 --- /dev/null +++ b/composer.json @@ -0,0 +1,19 @@ +{ + "name": "jhodges/giteabot-phpunit", + "description": "Some examples for the giteabot php api", + "authors": [ + { + "name": "James", + "email": "inbox.dev@jhodges.co.uk" + } + ], + "require": { + "jhodges/giteabot": "~1.2.0" + }, + "repositories": { + "repo-name": { + "type": "composer", + "url": "https://git.jhodges.co.uk/composer" + } + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..dd7a3e0 --- /dev/null +++ b/composer.lock @@ -0,0 +1,44 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "8e21cb9a16c0817b84a9643dc47c1a78", + "packages": [ + { + "name": "jhodges/giteabot", + "version": "v1.2.1", + "source": { + "type": "git", + "url": "https://git.jhodges.co.uk/jhodges/GiteaBot", + "reference": "a2c44392b2b4eede6be4b132e55e3479232fda93" + }, + "type": "library", + "autoload": { + "psr-4": { + "JHodges\\GiteaBot\\": "src/" + } + }, + "license": [ + "GPL3" + ], + "authors": [ + { + "name": "James", + "email": "inbox.dev@jhodges.co.uk" + } + ], + "description": "Simple PHP library to interface with Gitea API", + "time": "2019-09-07T08:43:48+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/src/Poster.php b/src/Poster.php new file mode 100644 index 0000000..42e5af0 --- /dev/null +++ b/src/Poster.php @@ -0,0 +1,38 @@ +report=preg_replace('# \[#',' * [',$report); + + $log=file_get_contents($xml); + $p = xml_parser_create(); + xml_parse_into_struct($p, $log, $vals, $index); + xml_parser_free($p); + $this->vals=$vals; + $this->index=$index; + } + + function post($url, $user, $pass, $repoUser, $repo){ + //open connection and repo + $client=new Client($config['url'],$config['user'],$config['pass'],$debug); + $repo=$client->getRepo($repoUser, $repo); + + //create a test issue + $issue=$repo->createIssue([ + 'title'=>'Test Results', + 'body'=>$this->report + ]); + //$issue->addLabel($label); + + foreach($this->index['FAILURE'] as $id){ + $msg=$this->vals[$id]['value']; + $msg=str_replace('\n','',$msg); + $issue->addComment("```plain\n$msg\n```"); + } + + $issue->save(); + } +}