From 04e369fa4a89a06935c4a5d427ea35fe801a09f6 Mon Sep 17 00:00:00 2001 From: Jason Irish Date: Thu, 15 Sep 2022 22:01:58 -0500 Subject: [PATCH] CI Github Workflow (#231) * CI Github Workflow * allow plugins * recipe testing * bugfix locatorcontrollertest * LocatorTest * test bugfix * phpunit * geocoder version * Revert "geocoder version" This reverts commit 1bb421993374e403fd78b318249baaf1e1fedc56. * 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 Co-authored-by: Nic Horstmeier --- .github/workflows/ci.yml | 75 ++++++++++++++++++++++++++++ composer.json | 37 +++----------- phpcs.xml.dist | 37 ++++++++------ phpunit.xml.dist | 24 +++++---- tests/Page/LocatorControllerTest.php | 2 +- tests/Page/LocatorTest.php | 2 +- tests/form/LocatorFormTest.php | 2 +- 7 files changed, 122 insertions(+), 57 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6a86de3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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/" diff --git a/composer.json b/composer.json index c2be0f7..55bf1ab 100644 --- a/composer.json +++ b/composer.json @@ -16,31 +16,27 @@ { "name": "Dynamic", "email": "dev@dynamicagency.com", - "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": { @@ -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" ] } } diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 4e51a5d..48c5dad 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,17 +1,26 @@ - - - CodeSniffer ruleset for SilverStripe coding conventions. + + + Coding standard for SilverStripe 4.x - - - - - - - - - - - + + */thirdparty/* + + + + + + + + + + + + + + + + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 1c1547c..1350a2b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,14 +1,16 @@ - + + + - tests + tests/ - - - - src/ - - tests/ - - - + + + + src/ + + + tests/ + + diff --git a/tests/Page/LocatorControllerTest.php b/tests/Page/LocatorControllerTest.php index 9b051ec..fd9f24b 100644 --- a/tests/Page/LocatorControllerTest.php +++ b/tests/Page/LocatorControllerTest.php @@ -32,7 +32,7 @@ class LocatorControllerTest extends FunctionalTest /** * */ - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/Page/LocatorTest.php b/tests/Page/LocatorTest.php index ea5d2b1..a85e053 100644 --- a/tests/Page/LocatorTest.php +++ b/tests/Page/LocatorTest.php @@ -25,7 +25,7 @@ class LocatorTest extends FunctionalTest /** * */ - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/form/LocatorFormTest.php b/tests/form/LocatorFormTest.php index ed08b5f..0d08c3d 100644 --- a/tests/form/LocatorFormTest.php +++ b/tests/form/LocatorFormTest.php @@ -22,7 +22,7 @@ class LocatorFormTest extends FunctionalTest /** * */ - protected function setUp() + protected function setUp(): void { parent::setUp();