Skip to content

Commit

Permalink
CI initial workflow (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirish authored Sep 4, 2024
1 parent 00948e5 commit 5447507
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 93 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
16 changes: 7 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
{
"name": "dynamic/silverstripe-elemental-locations",
"description": "A locations block for Silverstripe. Display one or more locations on a map.",
"license": "BSD-3-Clause",
"type": "silverstripe-vendormodule",
"keywords": [
"silverstripe",
"CMS"
],
"license": "BSD-3-Clause",
"require": {
"dnadesign/silverstripe-elemental": "^4.8",
"symbiote/silverstripe-addressable": "^5.0"
"dnadesign/silverstripe-elemental": "^5.0"
},
"require-dev": {
"silverstripe/recipe-testing": "^2",
"squizlabs/php_codesniffer": "^3.0"
"silverstripe/recipe-testing": "^3"
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"Dynamic\\Elements\\Locations\\": "src/",
"Dynamic\\Elements\\Blog\\Locations\\": "tests/"
"Dynamic\\Elements\\Locations\\Test\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
10 changes: 6 additions & 4 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="SilverStripe">
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description>
<ruleset name="Silverstripe">
<description>CodeSniffer ruleset for Silverstripe coding conventions.</description>

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

<!-- base rules are PSR-12 -->
<rule ref="PSR12" >
<!-- Current exclusions -->
<!--<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" />-->
<!-- You may need to use this exclusion if you override some core methods -->
<!--<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />-->
</rule>
</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: 4
paths:
- src
25 changes: 14 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<phpunit bootstrap="vendor/silverstripe/cms/tests/bootstrap.php" colors="true">
<testsuite name="silverstripe-module/skeleton">
<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="default">
<directory>tests/</directory>
</testsuite>
</testsuites>
</phpunit>

0 comments on commit 5447507

Please sign in to comment.