-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Adding a Github action to run Psalm #40291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<files psalm-version="4.x-dev@"> | ||
</files> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
name: Static analysis | ||
|
||
on: | ||
pull_request: ~ | ||
|
||
jobs: | ||
psalm: | ||
name: Psalm | ||
runs-on: Ubuntu-20.04 | ||
|
||
steps: | ||
- name: Set up PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.0' | ||
extensions: "json,memcached,mongodb,redis,xsl,ldap,dom" | ||
ini-values: "memory_limit=-1" | ||
coverage: none | ||
|
||
- name: Checkout PR | ||
uses: actions/checkout@v2 | ||
with: | ||
path: pr | ||
|
||
- name: Checkout base | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.base_ref }} | ||
path: base | ||
|
||
- name: Configure composer | ||
run: | | ||
cd base | ||
COMPOSER_HOME="$(composer config home)" | ||
([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json" | ||
echo "COMPOSER_ROOT_VERSION=$(grep -m1 SYMFONY_VERSION .travis.yml | grep -o '[0-9.x]*').x-dev" >> $GITHUB_ENV | ||
|
||
- name: Determine composer cache directory | ||
id: composer-cache | ||
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
|
||
- name: Cache composer dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: composer-${{ github.base_ref }} | ||
restore-keys: composer- | ||
|
||
- name: Install Psalm | ||
run: | | ||
composer require psalm/phar | ||
cp ./vendor/bin/psalm.phar base/psalm.phar | ||
cp ./vendor/bin/psalm.phar pr/psalm.phar | ||
|
||
- name: Install dependencies for base | ||
run: | | ||
cd base | ||
echo "::group::modify composer.json" | ||
sed -i -re 's/"replace": \{/"replace": \{"symfony\/phpunit-bridge": "self.version",/' composer.json | ||
composer require --no-update phpunit/phpunit php-http/discovery psr/event-dispatcher | ||
echo "::endgroup::" | ||
echo "::group::composer update" | ||
composer update --no-progress --ansi | ||
echo "::endgroup::" | ||
|
||
- name: Generate Psalm baseline | ||
run: | | ||
cd base | ||
./psalm.phar --set-baseline=.github/psalm/psalm.baseline.xml --no-progress | ||
|
||
- name: Copy baseline | ||
run: | | ||
cp base/.github/psalm/psalm.baseline.xml pr/.github/psalm/psalm.baseline.xml | ||
|
||
- name: Install dependencies for PR | ||
run: | | ||
cd pr | ||
echo "::group::modify composer.json" | ||
sed -i -re 's/"replace": \{/"replace": \{"symfony\/phpunit-bridge": "self.version",/' composer.json | ||
composer require --no-update phpunit/phpunit php-http/discovery psr/event-dispatcher | ||
echo "::endgroup::" | ||
echo "::group::composer update" | ||
composer update --no-progress --ansi | ||
echo "::endgroup::" | ||
|
||
- name: Cache Psalm | ||
uses: actions/cache@v2 | ||
with: | ||
path: pr/.github/psalm/cache/ | ||
key: psalm-${{ github.base_ref }} | ||
restore-keys: psalm- | ||
|
||
- name: Psalm | ||
run: | | ||
cd pr | ||
./psalm.phar --version | ||
./psalm.phar --output-format=github --no-progress |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0"?> | ||
<psalm | ||
errorLevel="5" | ||
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" | ||
cacheDirectory="./.github/psalm/cache/" | ||
errorBaseline=".github/psalm/psalm.baseline.xml" | ||
> | ||
<projectFiles> | ||
<directory name="src" /> | ||
<ignoreFiles> | ||
<directory name="src/Symfony/*/*/Tests" /> | ||
<directory name="src/Symfony/*/*/*/Tests" /> | ||
<directory name="src/Symfony/*/*/*/*/Tests" /> | ||
<directory name="vendor" /> | ||
</ignoreFiles> | ||
</projectFiles> | ||
</psalm> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.