Skip to content

Commit

Permalink
REFACTOR Elemental 5 (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirish committed Jun 13, 2023
1 parent bf63a71 commit f5e647a
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 110 deletions.
76 changes: 7 additions & 69 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,75 +1,13 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
name: CI

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

name: "CI"
workflow_dispatch:

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/"
ci:
name: CI
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1
with:
phpcoverage: true
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

## Requirements

* dnadesign/silverstripe-elemental: ^4.8
* dynamic/silverstripe-elemental-baseobject: ^3.0
* dnadesign/silverstripe-elemental: ^5
* dynamic/silverstripe-elemental-baseobject: ^4

#### Optional

Expand Down
24 changes: 20 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,25 @@
}
],
"require": {
"dnadesign/silverstripe-elemental": "^4.8",
"dynamic/silverstripe-elemental-baseobject": "^3.0"
"dnadesign/silverstripe-elemental": "^5",
"dynamic/silverstripe-elemental-baseobject": "^4",
"gorriecoe/silverstripe-link": "dev-refactor/allowSS5 as 1.4.1",
"gorriecoe/silverstripe-linkfield": "dev-refactor/gridfieldextensions4 as 1.0.3",
"silverstripe/framework": "^5"
},
"require-dev": {
"silverstripe/recipe-testing": "^2"
"silverstripe/recipe-testing": "^3"
},
"repositories": [
{
"type": "vcs",
"url": "git@github.com:jsirish/silverstripe-link.git"
},
{
"type": "vcs",
"url": "git@github.com:jsirish/silverstripe-linkfield.git"
}
],
"suggest": {
"colymba/gridfield-bulk-editing-tools": "Bulk upload images to a gallery."
},
Expand All @@ -48,6 +61,9 @@
"extra": {
"expose": [
"thirdparty"
]
],
"branch-alias": {
"dev-master": "4.x-dev"
}
}
}
34 changes: 12 additions & 22 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
<?xml version="1.0"?>
<ruleset name="SS4">
<description>Coding standard for SilverStripe 4.x</description>

<!-- Don't sniff third party libraries -->
<exclude-pattern>*/vendor/*</exclude-pattern>
<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"/>
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="SilverStripe">
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description>

<file>src</file>
<file>tests</file>

<!-- base rules are PSR-2 -->
<rule ref="PSR2" >
<!-- Current exclusions -->
<exclude name="PSR1.Methods.CamelCapsMethodName" />
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" />
</rule>
</ruleset>
26 changes: 14 additions & 12 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">
<testsuite name="silverstripe-elemental-blocks">
<directory>tests</directory>
</testsuite>

<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/silverstripe/cms/tests/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage includeUncoveredFiles="true">
<include>
<directory suffix=".php">src/</directory>
<exclude>
<directory suffix=".php">tests/</directory>
</exclude>
</whitelist>
</filter>
</include>
<exclude>
<directory suffix=".php">tests/</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="elemental-promos">
<directory>tests/</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 1 addition & 1 deletion src/Model/GalleryImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function getCMSFields()
));
$image = $fields->dataFieldByName('Image')
->setFolderName('Uploads/Elements/PhotoGallery/');
$fields->insertBefore($image, 'Content');
$fields->insertBefore('Content', $image);

// so if anything depends on PageLink it doesn't flake out
$fields->replaceField('PageLink', new LiteralField('PageLink', ''));
Expand Down

0 comments on commit f5e647a

Please sign in to comment.