|
| 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 | +
|
| 38 | + - name: Determine composer cache directory |
| 39 | + id: composer-cache |
| 40 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 41 | + |
| 42 | + - name: Cache composer dependencies |
| 43 | + uses: actions/cache@v2 |
| 44 | + with: |
| 45 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 46 | + key: composer-${{ github.base_ref }} |
| 47 | + restore-keys: composer- |
| 48 | + |
| 49 | + - name: Install Psalm |
| 50 | + run: | |
| 51 | + composer require psalm/phar |
| 52 | + cp ./vendor/bin/psalm.phar base/psalm.phar |
| 53 | + cp ./vendor/bin/psalm.phar pr/psalm.phar |
| 54 | +
|
| 55 | + - name: Install dependencies for base |
| 56 | + run: | |
| 57 | + cd base |
| 58 | + echo "::group::modify composer.json" |
| 59 | + sed -i -re 's/"replace": \{/"replace": \{"symfony\/phpunit-bridge": "self.version",/' composer.json |
| 60 | + composer require --no-update phpunit/phpunit php-http/discovery psr/event-dispatcher |
| 61 | + echo "::endgroup::" |
| 62 | + echo "::group::composer update" |
| 63 | + composer update --no-progress --ansi |
| 64 | + echo "::endgroup::" |
| 65 | +
|
| 66 | + - name: Generate Psalm baseline |
| 67 | + run: | |
| 68 | + cd base |
| 69 | + ./psalm.phar --set-baseline=.github/psalm/psalm.baseline.xml --no-progress |
| 70 | +
|
| 71 | + - name: Copy baseline |
| 72 | + run: | |
| 73 | + cp base/.github/psalm/psalm.baseline.xml pr/.github/psalm/psalm.baseline.xml |
| 74 | +
|
| 75 | + - name: Install dependencies for PR |
| 76 | + run: | |
| 77 | + cd pr |
| 78 | + echo "::group::modify composer.json" |
| 79 | + sed -i -re 's/"replace": \{/"replace": \{"symfony\/phpunit-bridge": "self.version",/' composer.json |
| 80 | + composer require --no-update phpunit/phpunit php-http/discovery psr/event-dispatcher |
| 81 | + echo "::endgroup::" |
| 82 | + echo "::group::composer update" |
| 83 | + composer update --no-progress --ansi |
| 84 | + echo "::endgroup::" |
| 85 | +
|
| 86 | + - name: Cache Psalm |
| 87 | + uses: actions/cache@v2 |
| 88 | + with: |
| 89 | + path: pr/.github/psalm/cache/ |
| 90 | + key: psalm-${{ github.base_ref }} |
| 91 | + restore-keys: psalm- |
| 92 | + |
| 93 | + - name: Psalm |
| 94 | + run: | |
| 95 | + cd pr |
| 96 | + ./psalm.phar --version |
| 97 | + ./psalm.phar --output-format=github --no-progress |
0 commit comments