Skip to content

Add Github Action #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage_clover: clover.xml
json_path: coveralls-upload.json
94 changes: 94 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Build
on: [push]
jobs:
check:
runs-on: ubuntu-latest
name: Check CodingStyle
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
tools: phive
- name: Install CS-Fixer
run: phive install --trust-gpg-keys E82B2FB314E9906E php-cs-fixer
- name: Run CS-Check
run: composer fix-dry
test:
needs: check
runs-on: ubuntu-latest # ${{ matrix.operating-system }}
continue-on-error: ${{ matrix.experimental }}
strategy:
max-parallel: 2
matrix:
# operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.3', '7.4']
experimental: [false]
include:
- php-versions: '8.0'
experimental: true
- php-versions: '8.1'
experimental: true
name: PHP ${{ matrix.php-versions }} # Test on ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: sodium
tools: phive
- name: prepare
run: composer update
- name: Download phpunit
run: phive --no-progress install --trust-gpg-keys 4AA394086372C20A phpunit
- name: test
run: composer test
analyze:
#needs: test
runs-on: ubuntu-latest
continue-on-error: false
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
tools: phive
- name: Download psalm
run: phive --no-progress install --trust-gpg-keys 8A03EA3B385DBAA1 psalm
- name: install
run: composer update
- name: analyze
run: ./tools/psalm
coverage:
# needs: test
# if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
continue-on-error: false
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
coverage: xdebug
tools: phive
- name: Download phpunit
run: phive --no-progress install --trust-gpg-keys 4AA394086372C20A phpunit
- name: Install
run: composer update
- name: run testsuite
run: composer test-coverage
- name: Upload coverage results to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
composer global require php-coveralls/php-coveralls
php-coveralls --coverage_clover=clover.xml -v
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Deploying PHAR files via Composer

![Build](https://github.com/phar-io/composer-distributor/workflows/Build/badge.svg)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/phar-io/composer-distributor/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/phar-io/composer-distributor/?branch=main)

If you have a tool that behaves like a binary and want to distribute this tool as a
PHAR file instead of the source-code, but you don't want to give up the convenience
to install your tool via Composer you can use this library to create a Composer-Plugin
Expand Down
66 changes: 66 additions & 0 deletions build/psalm/baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="3.18.2@19aa905f7c3c7350569999a93c40ae91ae4e1626">
<file src="src/ConfiguredMediator.php">
<PossiblyNullArgument occurrences="1">
<code>$config-&gt;keyDirectory()</code>
</PossiblyNullArgument>
</file>
<file src="src/IteratorImplementation.php">
<DocblockTypeContradiction occurrences="1">
<code>false === key($this-&gt;getList())</code>
</DocblockTypeContradiction>
</file>
<file src="src/PackageVersion.php">
<MissingPropertyType occurrences="3">
<code>$name</code>
<code>$semver</code>
<code>$versionString</code>
</MissingPropertyType>
<UndefinedInterfaceMethod occurrences="1">
<code>getReason</code>
</UndefinedInterfaceMethod>
<UndefinedMethod occurrences="2">
<code>getInstalledRepo</code>
<code>getJob</code>
</UndefinedMethod>
</file>
<file src="src/PluginBase.php">
<MissingPropertyType occurrences="2">
<code>$composer</code>
<code>$io</code>
</MissingPropertyType>
<MissingReturnType occurrences="3">
<code>activate</code>
<code>deactivate</code>
<code>uninstall</code>
</MissingReturnType>
</file>
<file src="src/SemanticVersion.php">
<TypeDoesNotContainType occurrences="1">
<code>$b</code>
</TypeDoesNotContainType>
</file>
<file src="src/Service/Installer.php">
<PossiblyNullReference occurrences="1">
<code>toString</code>
</PossiblyNullReference>
<UndefinedClass occurrences="1">
<code>$factory-&gt;createGnuPG(new Directory(sys_get_temp_dir()))</code>
</UndefinedClass>
</file>
<file src="src/Service/Verify.php">
<UndefinedClass occurrences="1">
<code>GnuPG</code>
</UndefinedClass>
<UndefinedDocblockClass occurrences="2">
<code>$this-&gt;gpg</code>
<code>Gnupg</code>
</UndefinedDocblockClass>
</file>
<file src="src/Url.php">
<TypeDoesNotContainType occurrences="2">
<code>$parts['port'] === ''</code>
<code>$parts['port'] === ''</code>
</TypeDoesNotContainType>
</file>
</files>
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@
"phar-io/filesystem": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "^9.4",
"composer/composer": "^2.0"
},
"scripts": {
"test": "tools/phpunit --testsuite=default",
"test-coverage": "tools/phpunit --coverage-clover clover.xml",
"test-all": "tools/phpunit",
"fix": "tools/php-cs-fixer fix",
"fix-dry": "tools/php-cs-fixer fix --dry-run"
Expand Down
6 changes: 1 addition & 5 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,9 @@
<directory name="src"/>
<ignoreFiles>
<directory name="vendor"/>
<file name="src/autoload.php"/>
</ignoreFiles>
</projectFiles>

<stubs>
<file name="./build/phpstan/bootstrap.php"/>
</stubs>

<issueHandlers>
<LessSpecificReturnType errorLevel="info"/>

Expand Down Expand Up @@ -57,5 +52,6 @@
<!-- <RawObjectIteration errorLevel="info" />-->

<!-- <InvalidStringClass errorLevel="info" />-->
<RedundantCast errorLevel="info"/>
</issueHandlers>
</psalm>
2 changes: 1 addition & 1 deletion src/Config/InvalidXML.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ final class InvalidXML extends RuntimeException
/**
* @param \LibXMLError[] $errors
*/
public static function fromXMLErrors(array $errors): InvalidXml
public static function fromXMLErrors(array $errors): self
{
$message = 'Error loading config file' . PHP_EOL;

Expand Down
2 changes: 1 addition & 1 deletion src/Config/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function createConfig(DOMDocument $docDocument): Config
);
}

private function validateConfigurationAgainstSchema()
private function validateConfigurationAgainstSchema(): void
{
$original = \libxml_use_internal_errors(true);
$xsdFilename = __DIR__ . '/../../distributor.xsd';
Expand Down
15 changes: 15 additions & 0 deletions src/PluginBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,33 @@ abstract class PluginBase implements PluginInterface, EventSubscriberInterface

abstract public function installOrUpdateFunction(PackageEvent $event) : void;

/**
* @param Composer $composer
* @param IOInterface $io
* @return void
*/
public function activate(Composer $composer, IOInterface $io)
{
$this->composer = $composer;
$this->io = $io;
}

/**
* @param Composer $composer
* @param IOInterface $io
* @return void
*/
public function deactivate(Composer $composer, IOInterface $io)
{
$this->composer = $composer;
$this->io = $io;
}

/**
* @param Composer $composer
* @param IOInterface $io
* @return void
*/
public function uninstall(Composer $composer, IOInterface $io)
{
$this->composer = $composer;
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/InstallationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use function getenv;
use function sys_get_temp_dir;
use function unlink;
use function var_dump;

class InstallationTest extends TestCase
{
Expand Down Expand Up @@ -122,6 +121,7 @@ public function setUp() : void
parent::setUp();

$gpgHome = getenv('GNUPGHOME');
$gpgHome = sys_get_temp_dir();

if (file_exists($gpgHome . '/trustdb.gpg')) {
unlink($gpgHome . '/trustdb.gpg');
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/_assets/installWithFaultySignature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://phar.io/xml/distributor/1.0/schema.xsd"
packageName="foo/bar"
keyDirectory="tests/integration/_assets/faultykeys">
keyDirectory="faultykeys">

<phar name="foo"
file="https://github.com/heiglandreas/JUnitDiff/releases/download/0.5.0/junitdiff.phar"
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/_assets/installWithSignature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://phar.io/xml/distributor/1.0/schema.xsd"
packageName="foo/bar"
keyDirectory="tests/integration/_assets/keys">
keyDirectory="keys">

<phar name="foo"
file="https://github.com/heiglandreas/JUnitDiff/releases/download/0.5.0/junitdiff.phar"
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/Service/VerifyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function setUp() : void

/**
* @covers \PharIo\ComposerDistributor\Service\Verify::__construct
* @runInSeparateProcess
*/
public function testThatConstructorThrowsWithoutKeys(): void
{
Expand All @@ -43,6 +44,7 @@ public function testThatConstructorThrowsWithoutKeys(): void

/**
* @covers \PharIo\ComposerDistributor\Service\Verify::__construct
* @runInSeparateProcess
*/
public function testThatConstructorWorksWithSingleKey(): void
{
Expand All @@ -61,6 +63,7 @@ public function testThatConstructorWorksWithSingleKey(): void

/**
* @covers \PharIo\ComposerDistributor\Service\Verify::__construct
* @runInSeparateProcess
*/
public function testThatConstructorWorksWithAlreadyImportedKey(): void
{
Expand All @@ -80,6 +83,7 @@ public function testThatConstructorWorksWithAlreadyImportedKey(): void

/**
* @covers \PharIo\ComposerDistributor\Service\Verify::fileWithSignature
* @runInSeparateProcess
*/
public function testThatCorrectVerificationWillNotThrowAnException(): void
{
Expand Down