Skip to content

Commit c6a8387

Browse files
committed
with psalm
1 parent 3b64f0f commit c6a8387

File tree

3 files changed

+114
-0
lines changed

3 files changed

+114
-0
lines changed

.github/psaml.baseline.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<files psalm-version="4.x-dev@">
3+
</files>

.github/workflows/psalm.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Static analysis
2+
3+
on:
4+
pull_request: ~
5+
6+
jobs:
7+
psalm:
8+
name: Psalm
9+
runs-on: Ubuntu-20.04
10+
11+
steps:
12+
- name: Set up PHP
13+
uses: shivammathur/setup-php@v2
14+
with:
15+
php-version: '8.0'
16+
extensions: "json,memcached,mongodb,redis,xsl,ldap,dom"
17+
ini-values: "memory_limit=-1"
18+
coverage: none
19+
20+
- name: Checkout PR
21+
uses: actions/checkout@v2
22+
with:
23+
path: pr
24+
25+
- name: Checkout base
26+
uses: actions/checkout@v2
27+
with:
28+
ref: ${{ github.base_ref }}
29+
path: base
30+
31+
- name: Configure composer
32+
run: |
33+
cd base
34+
COMPOSER_HOME="$(composer config home)"
35+
([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json"
36+
echo "COMPOSER_ROOT_VERSION=$(grep -m1 SYMFONY_VERSION .travis.yml | grep -o '[0-9.x]*').x-dev" >> $GITHUB_ENV
37+
- name: Determine composer cache directory
38+
id: composer-cache
39+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
40+
41+
- name: Cache composer dependencies
42+
uses: actions/cache@v2
43+
with:
44+
path: ${{ steps.composer-cache.outputs.dir }}
45+
key: composer-${{ github.base_ref }}
46+
restore-keys: composer-
47+
48+
- name: Install Psalm
49+
run: |
50+
composer require psalm/phar
51+
cp ./vendor/bin/psalm.phar base/psalm.phar
52+
cp ./vendor/bin/psalm.phar pr/psalm.phar
53+
- name: Install dependencies for base
54+
run: |
55+
cd base
56+
echo "::group::modify composer.json"
57+
sed -i -re 's/"replace": \{/"replace": \{"symfony\/phpunit-bridge": "self.version",/' composer.json
58+
composer require --no-update phpunit/phpunit php-http/discovery
59+
echo "::endgroup::"
60+
echo "::group::composer update"
61+
composer update --no-progress --ansi
62+
echo "::endgroup::"
63+
- name: Generate Psalm baseline
64+
run: |
65+
cd base
66+
./psalm.phar --set-baseline=.github/psalm/psalm.baseline.xml --no-progress
67+
- name: Copy baseline
68+
run: |
69+
cp base/.github/psalm/psalm.baseline.xml pr/.github/psalm/psalm.baseline.xml
70+
- name: Install dependencies for PR
71+
run: |
72+
cd pr
73+
echo "::group::modify composer.json"
74+
sed -i -re 's/"replace": \{/"replace": \{"symfony\/phpunit-bridge": "self.version",/' composer.json
75+
composer require --no-update phpunit/phpunit php-http/discovery
76+
echo "::endgroup::"
77+
echo "::group::composer update"
78+
composer update --no-progress --ansi
79+
echo "::endgroup::"
80+
- name: Cache Psalm
81+
uses: actions/cache@v2
82+
with:
83+
path: pr/.github/psalm/cache/
84+
key: psalm-${{ github.base_ref }}
85+
restore-keys: psalm-
86+
87+
- name: Psalm
88+
run: |
89+
cd pr
90+
./psalm.phar --version
91+
./psalm.phar --output-format=github --no-progress

psaml.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="5"
4+
resolveFromConfigFile="true"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xmlns="https://getpsalm.org/schema/config"
7+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
8+
cacheDirectory="./.github/psalm/cache/"
9+
errorBaseline=".github/psalm/psalm.baseline.xml"
10+
>
11+
<projectFiles>
12+
<directory name="src" />
13+
<ignoreFiles>
14+
<directory name="src/Symfony/*/*/Tests" />
15+
<directory name="src/Symfony/*/*/*/Tests" />
16+
<directory name="src/Symfony/*/*/*/*/Tests" />
17+
<directory name="vendor" />
18+
</ignoreFiles>
19+
</projectFiles>
20+
</psalm>

0 commit comments

Comments
 (0)