Skip to content

Commit

Permalink
CI Github Workflow (#231)
Browse files Browse the repository at this point in the history
* CI Github Workflow

* allow plugins

* recipe testing

* bugfix locatorcontrollertest

* LocatorTest

* test bugfix

* phpunit

* geocoder version

* Revert "geocoder version"

This reverts commit 1bb4219.

* UPDATE require phpunit directly

* UPDATE revert back to recipe-testing

UPDATE bootstrap path to framework

* UPDATE xml to PHPUnit v9 format

* UPDATE remove project-files-installed and public-files-installed from composer.json

* UPDATE allow for geocoder ^2.0

Co-authored-by: Nic Horstmeier <[email protected]>
Co-authored-by: Nic Horstmeier <[email protected]>
  • Loading branch information
3 people authored Sep 16, 2022
1 parent c54da72 commit 04e369f
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 57 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions

on:
push:
branches: [ '**' ]
pull_request:
branches: [ '**' ]

name: "CI"

jobs:
tests:
name: "Tests"

runs-on: "ubuntu-latest"

env:
php_extensions: ctype, dom, fileinfo, hash, intl, mbstring, session, simplexml, tokenizer, xml, pdo, mysqli, gd, zip

services:
mysql:
image: "mysql:5.7"
env:
MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_ROOT_PASSWORD:
MYSQL_DATABASE: test_db
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

strategy:
fail-fast: false
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP with extensions"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.php_extensions }}"
coverage: "xdebug"

- name: "Start mysql service"
run: "sudo /etc/init.d/mysql start"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v1"
with:
path: "~/.composer/cache"
key: "php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}"
restore-keys: "php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Install dependencies with composer"
run: "composer install --no-ansi --no-interaction --no-progress"

- name: "Run tests with phpunit/phpunit"
env:
SS_DATABASE_PORT: ${{ job.services.mysql.ports['3306'] }}
run: "vendor/bin/phpunit --coverage-clover=coverage.xml"

- name: "Upload coverage results to CodeCov"
uses: codecov/codecov-action@v1
with:
files: ./coverage.xml # optional
flags: unittests # optional

- name: "Run tests with squizlabs/php_codesniffer"
run: "vendor/bin/phpcs -s --report=summary --standard=phpcs.xml.dist --extensions=php,inc --ignore=autoload.php --ignore=vendor/ src/ tests/"
37 changes: 8 additions & 29 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,27 @@
{
"name": "Dynamic",
"email": "[email protected]",
"homepage": "http://www.dynamicagency.com"
"homepage": "https://www.dynamicagency.com"
}
],
"require": {
"colymba/gridfield-bulk-editing-tools": "^3.0",
"dynamic/silverstripe-geocoder": "^1.0",
"ext-dom": "*",
"ext-json": "*",
"dynamic/silverstripe-geocoder": "^1.3 || ^2.0",
"littlegiant/silverstripe-catalogmanager": "^5.2",
"muskie9/data-to-arraylist": "^2.0",
"silverstripe/lumberjack": "^2.0",
"silverstripe/recipe-cms": "^4.0",
"silverstripe/vendor-plugin": "^1.0",
"symbiote/silverstripe-gridfieldextensions": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"squizlabs/php_codesniffer": "^3.0",
"phpmd/phpmd": "^2.6",
"sebastian/phpcpd": "^3.0",
"phploc/phploc": "^4.0",
"pdepend/pdepend": "^2.5",
"theseer/phpdox": "^0.11.0"
"silverstripe/recipe-testing": "^2"
},
"config": {
"allow-plugins": {
"composer/installers": true,
"silverstripe/vendor-plugin": true,
"silverstripe/recipe-plugin": true
},
"process-timeout": 600
},
"autoload": {
Expand All @@ -56,23 +52,6 @@
"thirdparty",
"css",
"client"
],
"branch-alias": {
"dev-master": "4.x-dev"
},
"project-files-installed": [
"app/.htaccess",
"app/_config.php",
"app/_config/mysite.yml",
"app/src/Page.php",
"app/src/PageController.php"
],
"public-files-installed": [
".htaccess",
"index.php",
"install-frameworkmissing.html",
"install.php",
"web.config"
]
}
}
37 changes: 23 additions & 14 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="SilverStripe">
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description>
<?xml version="1.0"?>
<ruleset name="SS3">
<description>Coding standard for SilverStripe 4.x</description>

<!-- base rules are PSR-12 -->
<rule ref="PSR12" >
<!-- Current exclusions -->
<!--<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" />-->
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
</rule>
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="205" />
<property name="absoluteLineLimit" value="0" />
</properties>
<!-- Don't sniff third party libraries -->
<exclude-pattern>*/thirdparty/*</exclude-pattern>

<!-- Show progress and output sniff names on violation, and add colours -->
<arg value="sp"/>
<arg name="colors"/>

<!-- Use PSR-2 as a base standard -->
<rule ref="PSR2">
<!-- Allow classes to not declare a namespace -->
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>

<!-- Allow underscores in class names -->
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>

<!-- Allow non camel cased method names -->
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>

<!-- Allow line length greater than 120 -->
<exclude name="Generic.Files.LineLength"/>
</rule>
</ruleset>
24 changes: 13 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<phpunit bootstrap="vendor/silverstripe/cms/tests/bootstrap.php" colors="true">
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/silverstripe/framework/tests/bootstrap.php" colors="true">
<testsuites>
<testsuite name="locator">
<directory>tests</directory>
<directory>tests/</directory>
</testsuite>

<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/</directory>
<exclude>
<directory suffix=".php">tests/</directory>
</exclude>
</whitelist>
</filter>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src/</directory>
</include>
<exclude>
<directory suffix=".php">tests/</directory>
</exclude>
</coverage>
</phpunit>
2 changes: 1 addition & 1 deletion tests/Page/LocatorControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class LocatorControllerTest extends FunctionalTest
/**
*
*/
protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Page/LocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LocatorTest extends FunctionalTest
/**
*
*/
protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/form/LocatorFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class LocatorFormTest extends FunctionalTest
/**
*
*/
protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down

0 comments on commit 04e369f

Please sign in to comment.