I have written about Psalm here. Here, I share my workflow for running Psalm in Github Actions:
name: Psalm
on:
push:
paths:
- '**.php'
- 'psalm.xml.dist'
jobs:
psalm:
name: psalm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: none
- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: vendor
key: composer-${{ hashFiles('composer.lock') }}
- name: Run composer install
run: composer install -n --prefer-dist
- name: Run psalm
run: ./vendor/bin/psalm --output-format=github
Let's Discuss What's Happening Above
I start by specifying a name for the job. In this case, "Psalm".
name: Psalm
I, then, go on to describe when I want the job to run. I only want it to run when there is a new version of a php file or the psalm config file.
on:
push:
paths:
- '**.php'
- 'psalm.xml'
Then, I go on to describe fully the actual job that needs to run. First, I specify the environment the job is going to run on. Then, I check out the code in the virtual machine.
jobs:
psalm:
name: psalm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
That is followed by setting up PHP
(using a third party action) and Composer
:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: none
- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: vendor
key: composer-${{ hashFiles('composer.lock') }}
- name: Run composer install
run: composer install -n --prefer-dist
Then, the job is finally executed:
- name: Run psalm
run: ./vendor/bin/psalm --output-format=github
And, that's that!
This post first appeared here
Top comments (0)