Skip to content
This repository has been archived by the owner on Jul 28, 2022. It is now read-only.

Commit

Permalink
Add static code analysis through GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
phansys authored and jordisala1991 committed Jul 16, 2020
1 parent f2cccd7 commit 97bf3bd
Show file tree
Hide file tree
Showing 97 changed files with 470 additions and 677 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/lint.yaml
@@ -0,0 +1,65 @@
on: [push, pull_request]

name: Lint

jobs:
php-cs-fixer:
name: PHP-CS-Fixer

runs-on: ubuntu-latest

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

- name: "Run PHP-CS-Fixer"
uses: docker://oskarstark/php-cs-fixer-ga:2.16.1
with:
args: --ansi --verbose --diff --dry-run

composer-normalize:
name: composer-normalize

runs-on: ubuntu-latest

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

- name: "Run composer-normalize"
uses: docker://localheinz/composer-normalize-action:0.5.2
with:
args: --dry-run

yaml-files:
name: YAML files

runs-on: ubuntu-latest

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

- name: "Install Ruby 2.6"
uses: actions/setup-ruby@v1
with:
ruby-version: '2.6'

- run: gem install yaml-lint

- name: "Linting..."
run: make lint-yaml

xml-files:
name: XML files

runs-on: ubuntu-latest

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

- run: sudo apt-get update && sudo apt-get install libxml2-utils

- name: "Linting..."
run: make lint-xml
15 changes: 15 additions & 0 deletions .github/workflows/qa.yaml
@@ -0,0 +1,15 @@
on: [push, pull_request]
name: Quality assurance
jobs:
phpstan:
name: PHPStan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: PHPStan
uses: "docker://oskarstark/phpstan-ga"
env:
CHECK_PLATFORM_REQUIREMENTS: false
REQUIRE_DEV: true
with:
args: analyse
64 changes: 63 additions & 1 deletion Makefile
Expand Up @@ -76,4 +76,66 @@ build:
git stash
app/console assets:install web
bin/qa_build_git.sh . /home/vagrant/sonata-sandbox-build 2.4 2.4
git stash pop
git stash pop

all:
@echo "Please choose a task."
.PHONY: all

lint: lint-composer lint-yaml lint-xml lint-php
.PHONY: lint

lint-composer:
composer validate
.PHONY: lint-composer

lint-yaml:
yaml-lint --ignore-non-yaml-files --quiet --exclude vendor .

.PHONY: lint-yaml

lint-xml:
find . \( -name '*.xml' -or -name '*.xliff' \) \
-not -path './vendor/*' \
-not -path './src/Resources/public/vendor/*' \
-not -path './public/*' \
| while read xmlFile; \
do \
XMLLINT_INDENT=' ' xmllint --encode UTF-8 --format "$$xmlFile"|diff - "$$xmlFile"; \
if [ $$? -ne 0 ] ;then exit 1; fi; \
done

.PHONY: lint-xml

lint-php:
php-cs-fixer fix --ansi --verbose --diff --dry-run
.PHONY: lint-php

cs-fix: cs-fix-php cs-fix-xml
.PHONY: cs-fix

cs-fix-php:
php-cs-fixer fix --verbose
.PHONY: cs-fix-php

cs-fix-xml:
find . \( -name '*.xml' -or -name '*.xliff' \) \
-not -path './vendor/*' \
-not -path './src/Resources/public/vendor/*' \
-not -path './public/*' \
| while read xmlFile; \
do \
XMLLINT_INDENT=' ' xmllint --encode UTF-8 --format "$$xmlFile" --output "$$xmlFile"; \
done
.PHONY: cs-fix-xml

build:
mkdir $@

test:
ifeq ($(shell php --modules|grep --quiet pcov;echo $$?), 0)
vendor/bin/simple-phpunit -c phpunit.xml.dist --coverage-clover build/logs/clover.xml
else
vendor/bin/simple-phpunit -c phpunit.xml.dist
endif
.PHONY: test
84 changes: 39 additions & 45 deletions build.xml
@@ -1,74 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>

<project name="sonata-sandbox" default="initialize-project" basedir=".">
<target name="initialize-project">
<!-- TODO: check for existence of app/config/parameters.yml -->

<property name="app.uploadsDir" value="./public/uploads/media" />
<property name="app.console" value="bin/console" />

<property name="app.uploadsDir" value="./public/uploads/media"/>
<property name="app.console" value="bin/console"/>
<if>
<os family="windows" />
<then><property name="app.console" value="bin\console.bat"/></then>
<else><property name="app.console" value="bin/console" /></else>
<os family="windows"/>
<then>
<property name="app.console" value="bin\console.bat"/>
</then>
<else>
<property name="app.console" value="bin/console"/>
</else>
</if>

<echo msg="Preparing ${app.uploadsDir} folder" />
<delete dir="${app.uploadsDir}" includeemptydirs="true" failonerror="false" />
<mkdir dir="${app.uploadsDir}" />

<echo msg="Removing any existing cache" />
<echo msg="Preparing ${app.uploadsDir} folder"/>
<delete dir="${app.uploadsDir}" includeemptydirs="true" failonerror="false"/>
<mkdir dir="${app.uploadsDir}"/>
<echo msg="Removing any existing cache"/>
<foreach param="dir" absparam="path" target="delete-dir">
<fileset dir="./var/cache">
<type type="dir" />
<depth max="0" min="0" />
<type type="dir"/>
<depth max="0" min="0"/>
</fileset>
</foreach>

<echo msg="Warming up cache for production environment" /> <!-- TODO: Is this even needed? -->
<echo msg="Warming up cache for production environment"/>
<!-- TODO: Is this even needed? -->
<SymfonyConsole console="${app.console}" command="cache:clear" checkReturn="true">
<arg name="env" value="prod" />
<arg name="no-warmup" />
<arg name="env" value="prod"/>
<arg name="no-warmup"/>
</SymfonyConsole>

<echo msg="Preparing database" />
<echo msg="Preparing database"/>
<SymfonyConsole console="${app.console}" command="doctrine:database:drop" checkReturn="true">
<arg name="force" />
<arg name="if-exists" />
<arg name="force"/>
<arg name="if-exists"/>
<!-- TODO: Fallback to doctrine:schema:drop in case user doesn't have permissions to drop/create databases? -->
</SymfonyConsole>
<SymfonyConsole console="${app.console}" command="doctrine:database:create" checkReturn="true" />
<SymfonyConsole console="${app.console}" command="doctrine:database:create" checkReturn="true"/>
<SymfonyConsole console="${app.console}" command="doctrine:schema:update" checkReturn="true">
<arg name="force" />
<arg name="dump-sql" />
<arg name="force"/>
<arg name="dump-sql"/>
</SymfonyConsole>
<SymfonyConsole console="${app.console}" command="doctrine:fixtures:load" checkReturn="true">
<!--<arg name="verbose" />-->
<arg name="no-interaction" />
<!--<arg name="verbose"/>-->
<arg name="no-interaction"/>
</SymfonyConsole>

<echo msg="Preparing sonata news and page bundles" />
<SymfonyConsole console="${app.console}" command="sonata:news:sync-comments-count" checkReturn="true" />
<echo msg="Preparing sonata news and page bundles"/>
<SymfonyConsole console="${app.console}" command="sonata:news:sync-comments-count" checkReturn="true"/>
<SymfonyConsole console="${app.console}" command="sonata:page:update-core-routes" checkReturn="true">
<arg name="site" value="all" />
<arg name="site" value="all"/>
</SymfonyConsole>
<SymfonyConsole console="${app.console}" command="sonata:page:create-snapshots" checkReturn="true">
<arg name="site" value="all" />
<arg name="site" value="all"/>
</SymfonyConsole>

<echo msg="Preparing ACLs" />
<SymfonyConsole console="${app.console}" command="sonata:admin:setup-acl" checkReturn="true" />
<SymfonyConsole console="${app.console}" command="sonata:admin:generate-object-acl" checkReturn="true" />

<echo msg="Preparing ACLs"/>
<SymfonyConsole console="${app.console}" command="sonata:admin:setup-acl" checkReturn="true"/>
<SymfonyConsole console="${app.console}" command="sonata:admin:generate-object-acl" checkReturn="true"/>
<!-- TODO: check for existence of yarn|npm -->
<echo msg="Generating assets" />
<SymfonyConsole console="${app.console}" command="assets:install" checkReturn="true" />
<echo msg="Generating assets"/>
<SymfonyConsole console="${app.console}" command="assets:install" checkReturn="true"/>
<!--
<SymfonyConsole console="yarn" command="encore dev" checkReturn="true" />
<SymfonyConsole console="yarn" command="encore dev" checkReturn="true"/>
-->
</target>

<target name="delete-dir" hidden="true">
<delete dir="${path}" includeemptydirs="true" failonerror="true" />
<delete dir="${path}" includeemptydirs="true" failonerror="true"/>
</target>
</project>
</project>
77 changes: 37 additions & 40 deletions composer.json
@@ -1,24 +1,7 @@
{
"name": "sonata-project/sandbox",
"description": "Sonata Project's sandbox (with ecommerce bundles)",

"license": "MIT",

"autoload": {
"psr-4": {
"App\\": "src/",
"AppBundle\\": "src/AppBundle",
"Sonata\\Bundle\\": "src/Sonata/Bundle"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},

"minimum-stability": "stable",

"require": {
"php": "^7.2",
"ext-bcmath": "*",
Expand Down Expand Up @@ -63,8 +46,10 @@
"symfony/browser-kit": "^4.2",
"symfony/debug": "^4.4",
"symfony/debug-bundle": "^4.4",
"symfony/dependency-injection": "^4.4",
"symfony/flex": "^1.6",
"symfony/form": "^4.4",
"symfony/http-kernel": "^4.4",
"symfony/monolog-bundle": "^3.1",
"symfony/polyfill-apcu": "^1.0",
"symfony/security-acl": "^3.0",
Expand All @@ -77,7 +62,15 @@
"twig/twig": "^2.12.1",
"willdurand/faker-bundle": "^1.3"
},

"replace": {
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php56": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php71": "*"
},
"conflict": {
"symfony/symfony": "*"
},
"require-dev": {
"behat/behat": "^3.4",
"behat/mink": "^1.7.1",
Expand All @@ -86,29 +79,38 @@
"behat/mink-goutte-driver": "^1.2.1",
"behat/mink-selenium2-driver": "^1.3.1",
"phing/phing": "^2.16",
"phpstan/phpstan": "^0.12.32",
"symfony/dotenv": "^4.0",
"symfony/phpunit-bridge": "^5.1",
"symfony/profiler-pack": "^1.0"
},

"replace": {
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php71": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php56": "*"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"extra": {
"branch-alias": "3.0",
"symfony": {
"allow-contrib": true,
"require": "4.4.*"
}
},
"autoload": {
"psr-4": {
"App\\": "src/",
"AppBundle\\": "src/AppBundle",
"Sonata\\Bundle\\": "src/Sonata/Bundle"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "stable",
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
Expand All @@ -118,16 +120,11 @@
"post-create-project-cmd": [
"@auto-scripts",
"php vendor/bin/phing"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"branch-alias": "3.0",
"symfony": {
"allow-contrib": true,
"require": "4.4.*"
],
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
}
}
}

0 comments on commit 97bf3bd

Please sign in to comment.