Skip to content

Commit fe3eb81

Browse files
committed
Add build and static actions to github workflows
1 parent 534ca0d commit fe3eb81

File tree

2 files changed

+142
-0
lines changed

2 files changed

+142
-0
lines changed

.github/workflows/build.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
on:
2+
- pull_request
3+
- push
4+
5+
name: build
6+
7+
jobs:
8+
tests:
9+
name: PHP ${{ matrix.php-version }}-${{ matrix.os }}
10+
11+
runs-on: ${{ matrix.os }}
12+
13+
env:
14+
extensions: curl, mbstring, dom
15+
key: cache-v1
16+
17+
strategy:
18+
matrix:
19+
os:
20+
- ubuntu-latest
21+
- windows-latest
22+
23+
php-version:
24+
- "7.4"
25+
- "8.0"
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v2
30+
31+
- name: Setup cache environment
32+
id: cache-env
33+
uses: shivammathur/cache-extensions@v1
34+
with:
35+
php-version: ${{ matrix.php-version }}
36+
extensions: ${{ env.extensions }}
37+
key: ${{ env.key }}
38+
39+
- name: Cache extensions
40+
uses: actions/cache@v2
41+
with:
42+
path: ${{ steps.cache-env.outputs.dir }}
43+
key: ${{ steps.cache-env.outputs.key }}
44+
restore-keys: ${{ steps.cache-env.outputs.key }}
45+
46+
- name: Setup PHP
47+
uses: shivammathur/setup-php@v2
48+
with:
49+
php-version: ${{ matrix.php-version }}
50+
extensions: ${{ env.extensions }}
51+
ini-values: date.timezone='UTC'
52+
coverage: pcov
53+
54+
- name: Determine composer cache directory on Linux
55+
if: matrix.os == 'ubuntu-latest'
56+
run: echo "::set-env name=COMPOSER_CACHE_DIR::$(composer config cache-dir)"
57+
58+
- name: Determine composer cache directory on Windows
59+
if: matrix.os == 'windows-latest'
60+
run: ECHO "::set-env name=COMPOSER_CACHE_DIR::~\AppData\Local\Composer"
61+
62+
- name: Cache dependencies installed with composer
63+
uses: actions/cache@v1
64+
with:
65+
path: ${{ env.COMPOSER_CACHE_DIR }}
66+
key: php-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
67+
restore-keys: php-${{ matrix.php-version }}-composer-
68+
69+
- name: Install dependencies with composer php 7.4
70+
if: matrix.php-version == '7.4'
71+
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader
72+
73+
- name: Install dependencies with composer php 8.0
74+
if: matrix.php-version == '8.0'
75+
run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader
76+
77+
- name: PHPUnit run with coverage on Linux PHP 7.4
78+
if: matrix.os == 'ubuntu-latest' && matrix.php-version == '7.4'
79+
run: vendor/bin/phpunit --coverage-clover=coverage.clover
80+
81+
- name: PHPUnit run without coverage on Linux PHP 8.0
82+
if: matrix.os == 'ubuntu-latest' && matrix.php-version == '8.0'
83+
run: vendor/bin/phpunit
84+
85+
- name: PHPUnit run without coverage on Windows
86+
if: matrix.os == 'windows-latest'
87+
run: vendor/bin/phpunit
88+
89+
- name: Code coverage scrutinizer on Linux PHP 7.4
90+
if: matrix.os == 'ubuntu-latest' && matrix.php-version == '7.4'
91+
run: |
92+
wget https://scrutinizer-ci.com/ocular.phar
93+
php ocular.phar code-coverage:upload --format=php-clover coverage.clover

.github/workflows/static.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
on:
2+
- pull_request
3+
- push
4+
5+
name: static
6+
7+
jobs:
8+
mutation:
9+
name: PHP ${{ matrix.php-version }}-${{ matrix.os }}
10+
11+
runs-on: ${{ matrix.os }}
12+
13+
strategy:
14+
matrix:
15+
os:
16+
- ubuntu-latest
17+
18+
php-version:
19+
- "7.4"
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v2
24+
25+
- name: Install PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: ${{ matrix.php-version }}
29+
ini-values: memory_limit=-1
30+
tools: composer:v2
31+
32+
- name: Determine composer cache directory
33+
run: echo "::set-env name=COMPOSER_CACHE_DIR::$(composer config cache-dir)"
34+
35+
- name: Cache dependencies installed with composer
36+
uses: actions/cache@v2
37+
with:
38+
path: ${{ env.COMPOSER_CACHE_DIR }}
39+
key: php${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
40+
restore-keys: php-${{ matrix.php-version }}-composer-
41+
42+
- name: Install dependencies with composer
43+
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader
44+
45+
- name: PHPCS check
46+
run: vendor/bin/phpcs
47+
48+
- name: Psalm static analysis
49+
run: vendor/bin/psalm --no-progress

0 commit comments

Comments
 (0)