Skip to content

Commit

Permalink
add cs checking to ci flow
Browse files Browse the repository at this point in the history
  • Loading branch information
salehhashemi1992 committed Oct 4, 2023
1 parent e967070 commit 452d4dd
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 21 deletions.
40 changes: 20 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Validate composer.json and composer.lock
run: composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run PHPUnit
run: composer run-script test
- uses: actions/checkout@v2

- name: Validate composer.json and composer.lock
run: composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run PHPUnit
run: composer run-script test
25 changes: 25 additions & 0 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Code style

on: [push, pull_request]

permissions:
contents: read

jobs:
phpcs:
name: PHPCS
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'

- name: Install dependencies
run: composer update --prefer-dist --no-progress --no-suggest

- name: Run script
run: vendor/bin/phpcs
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
.phan
composer.lock

/.phpcs-cache
/phpcs.xml

.phpunit.result.cache
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"phan/phan": "^2.7"
},
"require-dev": {
"phpunit/phpunit": "^9"
"phpunit/phpunit": "^9",
"squizlabs/php_codesniffer": "^3.7"
},
"scripts": {
"test": "vendor/bin/phpunit tests"
Expand Down
12 changes: 12 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<ruleset name="The Algorithms - PHP">
<description>PHP CodeSniffer configuration for The Algorithms - PHP.</description>

<!-- Set the default standard to PSR-12 -->
<arg name="standard" value="PSR12"/>

<file>.</file>

<!-- Include only .php files -->
<arg name="extensions" value="php"/>
</ruleset>

0 comments on commit 452d4dd

Please sign in to comment.