Skip to content

Commit

Permalink
Add coding standards and psalm checks on PRs (#620)
Browse files Browse the repository at this point in the history
  • Loading branch information
justnero authored Sep 18, 2023
1 parent 53b4299 commit c6e0eab
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 0 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: "Check SDK"

on:
pull_request:
paths:
- '.github/workflows/pr.yaml'
- 'src/**'

jobs:
psalm:
name: "Psalm"
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-version: ['8.0', '8.1', '8.2']

steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: "Install PHP w/ Extensions"
uses: rebilly/setup-php@main
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl, curl, json
tools: composer:v2

- name: "Get composer cache directory"
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-
- name: "Install dependencies"
run: composer install --no-interaction --no-scripts --no-suggest

- name: "Run tests"
run: vendor/bin/psalm

cs:
name: "Coding Standards"
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-version: ['8.0', '8.1', '8.2']

steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: "Install PHP w/ Extensions"
uses: rebilly/setup-php@main
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl, curl, json
tools: composer:v2

- name: "Get composer cache directory"
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-
- name: "Install dependencies"
run: composer install --no-interaction --no-scripts --no-suggest

- uses: actions/cache@v3
with:
path: .php-cs-fixer.cache
key: ${{ runner.os }}-cs-fixer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-cs-fixer-
- name: "Run tests"
run: vendor/bin/php-cs-fixer fix -vv --dry-run
30 changes: 30 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0"?>
<psalm
errorLevel="4"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
findUnusedBaselineEntry="true"
findUnusedCode="true"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<UnusedClass>
<errorLevel type="suppress">
<file name="src/CombinedService.php" />
<file name="src/CoreService.php" />
<file name="src/ReportsService.php" />
<file name="src/UsersService.php" />
</errorLevel>
</UnusedClass>
<PossiblyUnusedMethod errorLevel="suppress"/>
<UnusedMethod errorLevel="suppress"/>
<PossiblyUnusedReturnValue errorLevel="suppress"/>
</issueHandlers>
</psalm>

0 comments on commit c6e0eab

Please sign in to comment.