Skip to content

Commit 47d69e6

Browse files
authored
Merge pull request #56 from cakephp/github-actions
Move CI to GitHub Actions
2 parents 3d2be22 + 890cfbf commit 47d69e6

5 files changed

Lines changed: 116 additions & 1 deletion

File tree

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
.editorconfig export-ignore
88
.travis.yml export-ignore
99
phpunit.xml.dist export-ignore
10+
phpcs.xml.dist export-ignore
11+
.github export-ignore

.github/workflows/ci.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
name: CI
3+
4+
on:
5+
push:
6+
branches:
7+
- master
8+
pull_request:
9+
branches:
10+
- '*'
11+
12+
jobs:
13+
testsuite-linux:
14+
runs-on: ubuntu-18.04
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
php-version: ['5.6', '7.4', '8.0']
19+
prefer-lowest: ['']
20+
include:
21+
- php-version: '5.6'
22+
prefer-lowest: 'prefer-lowest'
23+
24+
steps:
25+
- uses: actions/checkout@v1
26+
with:
27+
fetch-depth: 1
28+
29+
- name: Setup PHP
30+
uses: shivammathur/setup-php@v2
31+
with:
32+
coverage: none
33+
php-version: ${{ matrix.php-version }}
34+
extensions: mbstring, intl
35+
36+
- name: Get composer cache directory
37+
id: composer-cache
38+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
39+
40+
- name: Get date part for cache key
41+
id: key-date
42+
run: echo "::set-output name=date::$(date +'%Y-%m')"
43+
44+
- name: Cache composer dependencies
45+
uses: actions/cache@v1
46+
with:
47+
path: ${{ steps.composer-cache.outputs.dir }}
48+
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}
49+
50+
- name: Composer install
51+
run: |
52+
if [[ ${{ matrix.php-version }} == '8.0' ]]; then
53+
composer install --ignore-platform-reqs
54+
elif ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
55+
composer update --prefer-lowest --prefer-stable
56+
else
57+
composer install
58+
fi
59+
60+
- name: Run PHPUnit
61+
run: |
62+
if [[ ${{ matrix.php-version }} == '5.6' ]]; then
63+
vendor/bin/phpunit tests/php56/
64+
else
65+
vendor/bin/phpunit
66+
fi
67+
68+
cs-stan:
69+
name: Coding Standard & Static Analysis
70+
runs-on: ubuntu-18.04
71+
72+
steps:
73+
- uses: actions/checkout@v1
74+
with:
75+
fetch-depth: 1
76+
77+
- name: Setup PHP
78+
uses: shivammathur/setup-php@v2
79+
with:
80+
php-version: '7.4'
81+
extensions: mbstring, intl
82+
coverage: none
83+
tools: psalm:~4.1.0
84+
85+
- name: Composer Install
86+
run: composer install
87+
88+
- name: Run phpcs
89+
run: vendor/bin/phpcs -p src/ tests/
90+
91+
- name: Run psalm
92+
run: psalm --output-format=github

phpcs.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="CakePHP PluginInstaller">
3+
<config name="installed_paths" value="../../cakephp/cakephp-codesniffer" />
4+
5+
<rule ref="CakePHP" />
6+
</ruleset>

psalm.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
>
9+
<projectFiles>
10+
<directory name="src" />
11+
<ignoreFiles>
12+
<directory name="vendor" />
13+
</ignoreFiles>
14+
</projectFiles>
15+
</psalm>

src/Plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,6 @@ public function getPrimaryNamespace(PackageInterface $package)
265265
);
266266
}
267267

268-
return trim($primaryNs, '\\');
268+
return trim((string)$primaryNs, '\\');
269269
}
270270
}

0 commit comments

Comments
 (0)