Skip to content

Commit

Permalink
Testsuite cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianfeldmann committed May 11, 2021
1 parent 9f291c5 commit 628d1df
Show file tree
Hide file tree
Showing 120 changed files with 98 additions and 72 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ jobs:
run: GITHUB_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }} tools/phive --no-progress --home ./.phive install --force-accept-unsigned --trust-gpg-keys 4AA394086372C20A,31C7E470E2138192,8E730BA25823D8B5,CF1A108D0E7AE720

- name: Execute unit tests
run: tools/phpunit --configuration=phpunit.ci.xml --testsuite CaptainHook
run: tools/phpunit --no-coverage --testsuite UnitTests

- name: Execute integration tests
run: tools/phpunit --configuration=phpunit.ci.xml --testsuite Integration
run: tools/phpunit --no-coverage --testsuite IntegrationTests

- name: Check coding style
run: tools/phpcs --standard=psr12 src tests
Expand Down
83 changes: 40 additions & 43 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ on:

jobs:
release:
name: "Release"

runs-on: "ubuntu-latest"

name: Release
runs-on: ubuntu-latest
strategy:
matrix:

dependencies:
- "locked"
- locked

env:
PHAR: "build/phar/captainhook.phar"
Expand All @@ -40,55 +37,55 @@ jobs:
- name: Install dependencies
run: composer install --prefer-dist --no-dev --no-interaction --no-progress

- name: "Install tooling"
- name: Install tooling
run: "GITHUB_AUTH_TOKEN=${{ secrets.GITHUB_API_TOKEN }} tools/phive --no-progress --home ./.phive install --force-accept-unsigned --trust-gpg-keys 4AA394086372C20A,31C7E470E2138192,8E730BA25823D8B5,CF1A108D0E7AE720"

- name: "Validate configuration for humbug/box"
run: "tools/box validate box.json"
- name: Validate configuration for humbug/box
run: tools/box validate box.json

- name: Force install Symfony 3
run: composer require symfony/console ^3.0 symfony/process ^3.0 symfony/filesystem ^3.0

- name: "Compile phar with humbug/box"
run: "tools/box compile"
- name: Compile phar with humbug/box
run: tools/box compile

- name: "Show info about generated phar with humbug/box"
run: "tools/box info ${{ env.PHAR }}"
- name: Show info about generated phar with humbug/box
run: tools/box info ${{ env.PHAR }}

- name: "Run phar"
run: "${{ env.PHAR }} --help"
- name: Run phar
run: ${{ env.PHAR }} --help

- name: "Show gpg version"
run: "gpg --version"
- name: Show gpg version
run: gpg --version

- name: "Decrypt signing key with gpg"
- name: Decrypt signing key with gpg
run: "gpg --batch --output ${{ env.GPG_KEYS }} --passphrase \"${{ secrets.GPG_DECRYPT_PASSPHRASE }}\" --yes --ignore-mdc-error --decrypt ${{ env.GPG_KEYS_ENCRYPTED }}"

- name: "Import keys with gpg"
- name: Import keys with gpg
run: "gpg --batch --import ${{ env.GPG_KEYS }}"

- name: "Sign phar with gpg"
- name: Sign phar with gpg
run: "gpg --armor --local-user \"${{ secrets.GPG_KEY_EMAIL }}\" --output ${{ env.PHAR_SIGNATURE }} --passphrase \"${{ secrets.GPG_KEY_PASSPHRASE }}\" --pinentry-mode loopback --yes --detach-sig ${{ env.PHAR }}"

- name: "Verify signature with gpg"
- name: Verify signature with gpg
run: "gpg --verify ${{ env.PHAR_SIGNATURE }} ${{ env.PHAR }}"

- name: "Remove decrypted keys"
- name: Remove decrypted keys
run: "rm ${{ env.GPG_KEYS }}"

- name: "Determine tag"
id: "determine-tag"
- name: Determine tag
id: determine-tag
run: "echo \"::set-output name=tag::${GITHUB_REF#refs/tags/}\""

- name: "Fetch all"
- name: Fetch all
run: git fetch --all && git fetch --tags --force

- name: "Determine previous tag"
id: "determine-prev-tag"
- name: Determine previous tag
id: determine-prev-tag
run: echo "##[set-output name=tag;]$(git describe --abbrev=0 ${{ steps.determine-tag.outputs.tag }})^"

- name: "Prepare release notes"
id: "changelog"
- name: Prepare release notes
id: changelog
run: |
changelog=$(php build/release-notes)
echo $changelog
Expand All @@ -97,12 +94,12 @@ jobs:
changelog="${changelog//$'\r'/'%0D'}"
echo "::set-output name=changelog::$changelog"
- name: "Check release notes"
- name: Check release notes
run: "echo \"${{ steps.changelog.outputs.changelog }}\""

- name: "Create release"
id: "create-release"
uses: "actions/create-release@master"
- name: Create release
id: create-release
uses: actions/create-release@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_API_TOKEN }}"
with:
Expand All @@ -112,34 +109,34 @@ jobs:
release_name: "${{ steps.determine-tag.outputs.tag }}"
body: "${{ steps.changelog.outputs.changelog }}"

- name: "Upload captainhook.phar"
uses: "actions/upload-release-asset@v1.0.1"
- name: Upload captainhook.phar
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_API_TOKEN }}"
with:
asset_content_type: "text/plain"
asset_name: "captainhook.phar"
asset_content_type: text/plain
asset_name: captainhook.phar
asset_path: "${{ env.PHAR }}"
upload_url: "${{ steps.create-release.outputs.upload_url }}"

- name: "Upload captainhook.phar.asc"
uses: "actions/upload-release-asset@v1.0.1"
- name: Upload captainhook.phar.asc
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_API_TOKEN }}"
with:
asset_content_type: "text/plain"
asset_name: "captainhook.phar.asc"
asset_content_type: text/plain
asset_name: captainhook.phar.asc
asset_path: "${{ env.PHAR_SIGNATURE }}"
upload_url: "${{ steps.create-release.outputs.upload_url }}"

- name: "Check out the phar repo"
- name: Check out the phar repo
uses: actions/checkout@v2
with:
repository: captainhookphp/captainhook-phar
token: ${{ secrets.PAT_SF }}
path: phar-repo

- name: "Tag and push the phar repo"
- name: Tag and push the phar repo
run: |
cd phar-repo
git config user.name "Sebastian Feldmann"
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"autoload-dev": {
"psr-4": {
"CaptainHook\\App\\": "tests/CaptainHook/",
"CaptainHook\\App\\": "tests/unit/",
"CaptainHook\\App\\Integration\\": "tests/integration/"
}
},
Expand Down Expand Up @@ -68,8 +68,8 @@
"post-install-cmd": "tools/phive install --force-accept-unsigned",
"tools": "tools/phive install --force-accept-unsigned",
"compile": "tools/box compile",
"test": "tools/phpunit --testsuite CaptainHook",
"test:integration": "tools/phpunit --testsuite Integration --no-coverage",
"test": "tools/phpunit --testsuite UnitTests",
"test:integration": "tools/phpunit --testsuite IntegrationTests --no-coverage",
"analyse": "tools/phpstan analyse",
"style": "tools/phpcs --standard=psr12 src tests"
}
Expand Down
11 changes: 0 additions & 11 deletions phpunit.ci.xml

This file was deleted.

6 changes: 3 additions & 3 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
</report>
</coverage>
<testsuites>
<testsuite name="CaptainHook">
<directory>tests/CaptainHook</directory>
<testsuite name="UnitTests">
<directory>tests/unit</directory>
</testsuite>
<testsuite name="Integration">
<testsuite name="IntegrationTests">
<directory>tests/integration</directory>
</testsuite>
</testsuites>
Expand Down
34 changes: 34 additions & 0 deletions tests/integration/PreCommit/SuccessTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/**
* This file is part of CaptainHook.
*
* (c) Sebastian Feldmann <sf@sebastian-feldmann.info>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace CaptainHook\App\Integration\PreCommit;

use CaptainHook\App\Integration\IntegrationTestCase;

class SuccessTest extends IntegrationTestCase
{
public function testPreCommitSuccess(): void
{
$repoPath = $this->setUpRepository();

$this->enableHook($repoPath, 'pre-commit', [
['action' => 'echo "test action placeholder {$STAGED_FILES|of-type:html}" > html.log']
]);

$this->filesystem()->touch($repoPath . '/foo.html');
$this->mustRunInShell(['git', 'add', 'foo.html'], $repoPath);
$this->mustRunInShell(['git', 'commit', '-m', 'Test successful pre-commit execution'], $repoPath);

$log = file_get_contents($repoPath . '/html.log');

$this->assertStringContainsString("foo.html", $log);
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace CaptainHook\App\Config;

use CaptainHook\App\Config as CHConfig;
use PHPUnit\Framework\MockObject\MockBuilder;

trait Mockery
{
Expand Down Expand Up @@ -74,5 +75,5 @@ public function createPluginConfigMock(): Plugin
* @param $type
* @return \PHPUnit\Framework\MockObject\MockBuilder
*/
abstract public function getMockBuilder(string $type): \PHPUnit\Framework\MockObject\MockBuilder;
abstract public function getMockBuilder(string $type): MockBuilder;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace CaptainHook\App\Console\IO;

use CaptainHook\App\Console\IO;
use PHPUnit\Framework\MockObject\MockBuilder;

trait Mockery
{
Expand All @@ -31,5 +32,5 @@ public function createIOMock(): IO
* @param $type
* @return \PHPUnit\Framework\MockObject\MockBuilder
*/
abstract public function getMockBuilder(string $type): \PHPUnit\Framework\MockObject\MockBuilder;
abstract public function getMockBuilder(string $type): MockBuilder;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use CaptainHook\App\Console\IO\NullIO;
use CaptainHook\App\Mockery as GitMockery;
use CaptainHook\App\Console\IO\Mockery as IOMockery;
use Exception;
use PHPUnit\Framework\TestCase;

class IsNotEmptyTest extends TestCase
Expand Down Expand Up @@ -111,7 +112,7 @@ public function testConfigWithGlobs(): void
*/
public function testFailCommitEmptyFile(): void
{
$this->expectException(\Exception::class);
$this->expectException(Exception::class);


$io = new NullIO();
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace CaptainHook\App\Hook;

use PHPUnit\Framework\MockObject\MockBuilder;

trait Mockery
{
/**
Expand All @@ -29,5 +31,5 @@ public function createTemplateMock(): Template
* @param $type
* @return \PHPUnit\Framework\MockObject\MockBuilder
*/
abstract public function getMockBuilder(string $type): \PHPUnit\Framework\MockObject\MockBuilder;
abstract public function getMockBuilder(string $type): MockBuilder;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TestCoverageTest extends TestCase
*/
public function testCoverageViaCloverXML(): void
{
if (\defined('PHP_WINDOWS_VERSION_MAJOR')) {
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
$this->markTestSkipped('not tested on windows');
}

Expand Down Expand Up @@ -75,7 +75,7 @@ public function testCoverageLow(): void
*/
public function testCoverageViaPHPUnit(): void
{
if (\defined('PHP_WINDOWS_VERSION_MAJOR')) {
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
$this->markTestSkipped('not tested on windows');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PHPUnitTest extends TestCase
*/
public function testValid(): void
{
if (\defined('PHP_WINDOWS_VERSION_MAJOR')) {
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
$this->markTestSkipped('not tested on windows');
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use CaptainHook\App\Mockery as CHMockery;
use org\bovigo\vfs\vfsStream;
use PHPUnit\Framework\TestCase;
use RuntimeException;
use SebastianFeldmann\Git\Repository;

class InstallerTest extends TestCase
Expand Down Expand Up @@ -53,7 +54,7 @@ public function testSetInvalidHook(): void
*/
public function testMoveAfterSkippingFail(): void
{
$this->expectException(\RuntimeException::class);
$this->expectException(RuntimeException::class);

$io = $this->createIOMock();
$config = $this->createConfigMock();
Expand All @@ -73,7 +74,7 @@ public function testMoveAfterSkippingFail(): void
*/
public function testSkipAfterMovingFail(): void
{
$this->expectException(\RuntimeException::class);
$this->expectException(RuntimeException::class);

$io = $this->createIOMock();
$config = $this->createConfigMock();
Expand Down Expand Up @@ -212,7 +213,7 @@ public function testMoveNotExistingHook(): void
*/
public function testMoveExistingHookTargetIsFile(): void
{
$this->expectException(\RuntimeException::class);
$this->expectException(RuntimeException::class);

$fakeRepo = new DummyRepo(
// git repo
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 628d1df

Please sign in to comment.