Skip to content

Commit

Permalink
Merge pull request #5 from aligent/feature/Github-Workflows
Browse files Browse the repository at this point in the history
GitHub workflows
  • Loading branch information
AdamJHall authored Jul 6, 2022
2 parents 330f43e + 6f77d12 commit e7c9772
Show file tree
Hide file tree
Showing 15 changed files with 374 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* @AdamJHall @aligent/oro-developers

7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2

updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
44 changes: 44 additions & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Code Style Checks

on: [pull_request]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.0]
stability: [prefer-lowest, prefer-stable]

name: PHP-${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }} - PHPCS

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: "dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo"
coverage: none

- name: Validate composer.json
run: composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction

- name: Execute PHPCS
run: bin/phpcs
44 changes: 44 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Static analysis

on: [pull_request]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.0]
stability: [prefer-lowest, prefer-stable]

name: PHP-${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }} - PHPStan

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: "dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo"
coverage: none

- name: Validate composer.json
run: composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction

- name: Execute PHPStan
run: bin/phpstan
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

name: Create Release

jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
name: Release ${{ github.ref }}
draft: false
prerelease: false
body_path: RELEASE_NOTES.md

- name: Update Packagist
env:
API_TOKEN: ${{ secrets.PackagistApiToken }}
run: curl -XPOST -H'content-type:application/json' 'https://packagist.org/api/update-package?username=aligent&apiToken='$API_TOKEN -d'{"repository":{"url":"https://packagist.org/packages/aligent/oro-geo-detection"}}'
32 changes: 32 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Tests

on: [pull_request]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.0]
stability: [prefer-lowest, prefer-stable]

name: PHP-${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }} - PHPUnit

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: "dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo"
coverage: none

- name: Install dependencies
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction

- name: Execute tests
run: bin/phpunit
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
# IDE
.idea

# PHPUnit
.phpunit.result.cache

# Composer
composer.lock
vendor/
.idea/

# Binaries
bin/
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### 4.2.3 Release

- Added Github Workflows (PHPCS, PHPStan and PHPUnit)
60 changes: 41 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,44 @@
{
"name": "aligent/oro-geo-detection",
"description": "A Bundle for OroCommerce to provide application level geo-detection using the maxmind db",
"type": "library",
"license": "GPL-3.0",
"version": "4.2.0",
"authors": [
{
"name": "Adam Hall",
"email": "[email protected]"
}
],
"require": {
"php": "~7.4.14 || ~8.0.0",
"oro/commerce": "^4.2",
"geoip2/geoip2": "~2.0",
"guzzlehttp/guzzle": "^7.2"
},
"autoload": {
"psr-4": { "Aligent\\GeoDetectionBundle\\": "./src/" }
"name": "aligent/oro-geo-detection",
"description": "A Bundle for OroCommerce to provide application level geo-detection using the maxmind db",
"type": "library",
"license": "GPL-3.0",
"authors": [
{
"name": "Adam Hall",
"email": "[email protected]"
}
],
"repositories": {
"oro": {
"type": "composer",
"url": "https://packagist.orocrm.com"
}
},
"autoload": {
"psr-4": {
"Aligent\\GeoDetectionBundle\\": "./src/"
}
},
"config": {
"bin-dir": "bin"
},
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "~7.4.14 || ~8.0.0",
"oro/commerce": "^4.2",
"geoip2/geoip2": "~2.0",
"guzzlehttp/guzzle": "^7.2"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^1.7",
"phpmd/phpmd": "^2.12",
"friendsofphp/php-cs-fixer": "~2.18.2 || ~3.1.0",
"nelmio/alice": "~3.8.0 || ~3.9.0",
"theofidry/alice-data-fixtures": "~1.4.0 || ~1.5.0",
"symfony/phpunit-bridge": "~4.4.24 || ~6.1.0",
"squizlabs/php_codesniffer": "^3.6"
}
}
10 changes: 10 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<ruleset name="PSR2">
<description>The PSR-2 coding standard.</description>
<rule ref="PSR2"/>
<rule ref="Generic.Files.ByteOrderMark"/>
<rule ref="Generic.Files.LineEndings"/>
<rule ref="MySource.PHP.GetRequestData"/>
<file>src/</file>
<exclude-pattern>*\.js</exclude-pattern>
</ruleset>
4 changes: 4 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
level: 1
paths:
- src
49 changes: 49 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
stopOnError="false"
stopOnFailure="false"
stopOnWarning="false"
stopOnIncomplete="false"
stopOnRisky="false"
stopOnSkipped="false"
failOnRisky="false"
failOnWarning="false"
beStrictAboutChangesToGlobalState="false"
beStrictAboutOutputDuringTests="false"
beStrictAboutResourceUsageDuringSmallTests="false"
beStrictAboutTestsThatDoNotTestAnything="false"
beStrictAboutTodoAnnotatedTests="false"
beStrictAboutCoversAnnotation="false"
enforceTimeLimit="false"
verbose="false">

<testsuites>
<testsuite name="unit">
<directory>src/Tests/Unit</directory>
</testsuite>
</testsuites>
<php>
<env name="SYMFONY_ENV" value="test"/>
<env name="SYMFONY_DEBUG" value="0"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak" />
<ini name="error_reporting" value="-1"/>
<ini name="memory_limit" value="-1"/>
<server name="KERNEL_DIR" value="src/"/>
</php>
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
<listener class="Oro\Component\TestUtils\Listener\TestListener"/>
</listeners>
<coverage>
<include>
<directory>src</directory>
</include>
</coverage>
</phpunit>
2 changes: 1 addition & 1 deletion src/Providers/GeoDetectionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ public function getClientCountry(): ?string

return $country;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* @category Aligent
* @package
* @author Chris Rossi <[email protected]>
* @copyright 2022 Aligent Consulting.
* @license
* @link http://www.aligent.com.au/
*/
namespace Aligent\GeoDetectionBundle\Tests\Unit\DependencyInjection;

use Aligent\GeoDetectionBundle\DependencyInjection\AligentGeoDetectionExtension;
use Oro\Bundle\TestFrameworkBundle\Test\DependencyInjection\ExtensionTestCase;

class AligentGeoDetectionExtensionTest extends ExtensionTestCase
{
public function testLoad(): void
{
$this->loadExtension(new AligentGeoDetectionExtension(), ['aligent_geo_detection' => ['database' => '']]);

// Services
$expectedDefinitions = [
'aligent_geo_detection.form.type.geo_detection_countries_collection',
'aligent_geo_detection.form.type.geo_detection_country',
'aligent_geo_detection.form.type.geo_detection_system_config',
'aligent_geo_detection.reader',
'aligent_geo_detection.layout_context_configurator.geo_detection',
'aligent_geo_detection.provider.redirection_config_provider',
'aligent_geo_detection.provider.geo_detection',
'aligent_geo_detection.cache',
'aligent_geo_detection.layout.block_type.redirection_block',
'aligent_geo_detection.layout.block_type.site_select_block',
'aligent_geo_detection.layout.data_provider.redirection_provider',
'aligent_geo_detection.cache.warmer',
];
$this->assertDefinitionsLoaded($expectedDefinitions);

$expectedExtensionConfigs = ['aligent_geo_detection'];
$this->assertExtensionConfigsLoaded($expectedExtensionConfigs);
}
}
Loading

0 comments on commit e7c9772

Please sign in to comment.