Skip to content

Commit

Permalink
Merged branch '1.0' into 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
konradoboza committed May 28, 2021
2 parents 46368ee + f309573 commit 6083a6b
Show file tree
Hide file tree
Showing 15 changed files with 697 additions and 7 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Automatic Changelog Generator for tag

on:
push:
tags:
- 'v*'
- '!v*-alpha*'

jobs:
release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- name: Set Environment
run: |
echo "BUILD_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: Get previous release tag based on type
id: prevrelease
uses: ibexa/version-logic-action@master
with:
currentTag: ${{ env.BUILD_TAG }}

- name: Generate changelog
id: changelog
uses: ibexa/changelog-generator-action@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
jira_token: ${{ secrets.JIRA_TOKEN }}
currentTag: ${{ env.BUILD_TAG }}
previousTag: ${{ steps.prevrelease.outputs.previousTag }}

- name: Print the changelog
run: echo "${{ steps.changelog.outputs.changelog }}"

- name: Create Release
id: create_release
uses: zendesk/action-create-release@v1
with:
tag_name: ${{ env.BUILD_TAG }}
body: |
${{ steps.changelog.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 4 additions & 0 deletions src/bundle/Resources/config/default_settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ parameters:
template: '@@ezdesign/system_info/symfony_kernel.html.twig'
match:
SystemInfo\Identifier: 'symfony_kernel'
invalid:
template: '@@ezdesign/system_info/invalid.html.twig'
match:
SystemInfo\Identifier: 'invalid'
5 changes: 5 additions & 0 deletions src/bundle/Resources/translations/systeminfo.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@
<target state="new">You can read more about Service Life for Ibexa DXP with a business license at</target>
<note>key: ibexa.read_more</note>
</trans-unit>
<trans-unit id="5a3d301a871855ae4b3809c19b76fcccdb65b8ce" resname="invalid.system_unable_to_fetch">
<source>System was unable to fetch corresponding data</source>
<target state="new">System was unable to fetch corresponding data</target>
<note>key: invalid.system_unable_to_fetch</note>
</trans-unit>
<trans-unit id="608cb271bb7fb52c99a1a8e003e0f80f57fb41e1" resname="hardware">
<source>Hardware</source>
<target state="new">Hardware</target>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% trans_default_domain "systeminfo" %}

<section class="ez-fieldgroup">
<h2 class="ez-fieldgroup__name">{{ 'invalid.system_unable_to_fetch'|trans|desc('System was unable to fetch corresponding data') }}</h2>
<div class="ez-fieldgroup__content">
<table class="table ez-table--list">
<tbody>
<tr class="ez-table__row">
<td class="ez-table__cell">
{{ info.errorMessage }}
</td>
</tr>
</tbody>
</table>
</div>
</section>
3 changes: 2 additions & 1 deletion src/bundle/SystemInfo/Collector/IbexaSystemInfoCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace EzSystems\EzSupportToolsBundle\SystemInfo\Collector;

use EzSystems\EzPlatformCoreBundle\EzPlatformCoreBundle;
use EzSystems\EzSupportToolsBundle\SystemInfo\Exception\ComposerFileValidationException;
use EzSystems\EzSupportToolsBundle\SystemInfo\Exception\ComposerLockFileNotFoundException;
use EzSystems\EzSupportToolsBundle\SystemInfo\Value\ComposerPackage;
use EzSystems\EzSupportToolsBundle\SystemInfo\Value\IbexaSystemInfo;
Expand Down Expand Up @@ -114,7 +115,7 @@ public function __construct(SystemInfoCollector $composerCollector, $debug = fal
{
try {
$this->composerInfo = $composerCollector->collect();
} catch (ComposerLockFileNotFoundException $e) {
} catch (ComposerLockFileNotFoundException | ComposerFileValidationException $e) {
// do nothing
}
$this->debug = $debug;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public function __construct($lockFile, $jsonFile)
* Collects information about installed composer packages.
*
* @throws Exception\ComposerLockFileNotFoundException if the composer.lock file was not found.
* @throws Exception\ComposerJsonFileNotFoundException if the composer.json file was not found.
* @throws Exception\ComposerFileValidationException if composer.lock of composer.json are not valid.
*
* @return Value\ComposerSystemInfo
*/
Expand All @@ -72,6 +74,14 @@ public function collect()
$lockData = json_decode(file_get_contents($this->lockFile), true);
$jsonData = json_decode(file_get_contents($this->jsonFile), true);

if (!is_array($lockData)) {
throw new Exception\ComposerFileValidationException($this->lockFile);
}

if (!is_array($jsonData)) {
throw new Exception\ComposerFileValidationException($this->jsonFile);
}

return $this->value = new Value\ComposerSystemInfo([
'packages' => $this->extractPackages($lockData),
'repositoryUrls' => $this->extractRepositoryUrls($jsonData),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace EzSystems\EzSupportToolsBundle\SystemInfo\Exception;

use Exception;

final class ComposerFileValidationException extends Exception implements SystemInfoException
{
public function __construct(string $path, $code = 0, Exception $previous = null)
{
$message = sprintf('Composer file %s is not valid.', $path);

parent::__construct($message, $code, $previous);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Exception;
use eZ\Publish\Core\Base\Exceptions\NotFoundException as BaseNotFoundException;

class ComposerJsonFileNotFoundException extends BaseNotFoundException
class ComposerJsonFileNotFoundException extends BaseNotFoundException implements SystemInfoException
{
public function __construct(string $path, Exception $previous = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Exception;
use eZ\Publish\Core\Base\Exceptions\NotFoundException as BaseNotFoundException;

class ComposerLockFileNotFoundException extends BaseNotFoundException
class ComposerLockFileNotFoundException extends BaseNotFoundException implements SystemInfoException
{
public function __construct($path, Exception $previous = null)
{
Expand Down
11 changes: 11 additions & 0 deletions src/bundle/SystemInfo/Exception/SystemInfoException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace EzSystems\EzSupportToolsBundle\SystemInfo\Exception;

interface SystemInfoException
{
}
22 changes: 22 additions & 0 deletions src/bundle/SystemInfo/Value/InvalidSystemInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace EzSystems\EzSupportToolsBundle\SystemInfo\Value;

use eZ\Publish\API\Repository\Values\ValueObject;

/**
* Invalid value for system info used in case of any errors occur while collecting data.
*/
final class InvalidSystemInfo extends ValueObject implements SystemInfo
{
/**
* Error message shown in the System info tab.
*
* @var string
*/
public $errorMessage;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace EzSystems\EzSupportToolsBundle\Tests\SystemInfo\Collector;

use EzSystems\EzSupportToolsBundle\SystemInfo\Collector\JsonComposerLockSystemInfoCollector;
use EzSystems\EzSupportToolsBundle\SystemInfo\Exception\ComposerFileValidationException;
use EzSystems\EzSupportToolsBundle\SystemInfo\Exception\ComposerJsonFileNotFoundException;
use EzSystems\EzSupportToolsBundle\SystemInfo\Exception\ComposerLockFileNotFoundException;
use EzSystems\EzSupportToolsBundle\SystemInfo\Value\ComposerPackage;
Expand All @@ -18,7 +19,7 @@ class JsonComposerLockSystemInfoCollectorTest extends TestCase
/**
* @covers \EzSystems\EzSupportToolsBundle\SystemInfo\Collector\JsonComposerLockSystemInfoCollector::collect()
*/
public function testCollect()
public function testCollect(): void
{
$expected = new ComposerSystemInfo([
'packages' => [
Expand Down Expand Up @@ -78,7 +79,7 @@ public function testCollect()
/**
* @covers \EzSystems\EzSupportToolsBundle\SystemInfo\Collector\JsonComposerLockSystemInfoCollector::collect()
*/
public function testCollectLockFileNotFound()
public function testCollectLockFileNotFound(): void
{
$this->expectException(ComposerLockFileNotFoundException::class);

Expand All @@ -89,11 +90,39 @@ public function testCollectLockFileNotFound()
/**
* @covers \EzSystems\EzSupportToolsBundle\SystemInfo\Collector\JsonComposerLockSystemInfoCollector::collect()
*/
public function testCollectJsonFileNotFound()
public function testCollectJsonFileNotFound(): void
{
$this->expectException(ComposerJsonFileNotFoundException::class);

$composerCollectorNotFound = new JsonComposerLockSystemInfoCollector(__DIR__ . '/_fixtures/composer.lock', __DIR__ . '/_fixtures/snafu.json');
$composerCollectorNotFound->collect();
}

/**
* @covers \EzSystems\EzSupportToolsBundle\SystemInfo\Collector\JsonComposerLockSystemInfoCollector::collect()
*/
public function testCollectLockFileCorrupted(): void
{
$composerCollectorCorrupted = new JsonComposerLockSystemInfoCollector(
__DIR__ . '/_fixtures/corrupted_composer.lock',
__DIR__ . '/_fixtures/composer.json'
);

$this->expectException(ComposerFileValidationException::class);
$composerCollectorCorrupted->collect();
}

/**
* @covers \EzSystems\EzSupportToolsBundle\SystemInfo\Collector\JsonComposerLockSystemInfoCollector::collect()
*/
public function testCollectJsonFileCorrupted(): void
{
$composerCollectorCorrupted = new JsonComposerLockSystemInfoCollector(
__DIR__ . '/_fixtures/composer.lock',
__DIR__ . '/_fixtures/corrupted_composer.json'
);

$this->expectException(ComposerFileValidationException::class);
$composerCollectorCorrupted->collect();
}
}
Loading

0 comments on commit 6083a6b

Please sign in to comment.