Skip to content

Commit 7072aec

Browse files
authored
Merge pull request #4 from yokai-php/factorize-actions
Factorized github actions install steps
2 parents c7896ca + 5526707 commit 7072aec

File tree

2 files changed

+45
-66
lines changed

2 files changed

+45
-66
lines changed

.github/actions/install/action.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Prepare env & install dependencies
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
php-version:
7+
required: true
8+
type: string
9+
coverage-mode:
10+
required: false
11+
type: string
12+
default: 'none'
13+
secrets:
14+
token:
15+
required: true
16+
17+
runs:
18+
using: "composite"
19+
steps:
20+
- name: "Setup PHP"
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
coverage: ${{ inputs.coverage-mode }}
24+
php-version: ${{ inputs.php-version }}
25+
- name: "Install dependencies with composer"
26+
shell: bash
27+
run: |
28+
composer update --no-interaction --no-progress --no-suggest

.github/workflows/tests.yml

Lines changed: 17 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -10,110 +10,61 @@ jobs:
1010
phpunit:
1111
name: "PHPUnit"
1212
runs-on: ubuntu-latest
13-
1413
strategy:
1514
matrix:
1615
include:
17-
- php-version: 8.0
18-
- php-version: 8.2
19-
16+
- php-version: '8.0'
17+
- php-version: '8.2'
2018
steps:
2119
- name: "Checkout"
22-
uses: actions/checkout@v2
23-
24-
- name: "Setup PHP"
25-
uses: shivammathur/setup-php@v2
20+
uses: actions/checkout@v3
21+
- name: "Setup env & install dependencies"
22+
uses: ./.github/actions/install
2623
with:
27-
coverage: none
2824
php-version: ${{ matrix.php-version }}
29-
30-
- name: "Install dependencies with composer"
31-
run: |
32-
composer update --no-interaction --no-progress --no-suggest
33-
3425
- name: "Run tests with phpunit/phpunit"
3526
run: vendor/bin/phpunit
3627

3728
phpstan:
3829
name: "PhpStan"
3930
runs-on: ubuntu-latest
40-
41-
strategy:
42-
matrix:
43-
include:
44-
- php-version: 8.2
45-
4631
steps:
4732
- name: "Checkout"
48-
uses: actions/checkout@v2
49-
50-
- name: "Setup PHP"
51-
uses: shivammathur/setup-php@v2
33+
uses: actions/checkout@v3
34+
- name: "Setup env & install dependencies"
35+
uses: ./.github/actions/install
5236
with:
53-
coverage: none
54-
php-version: ${{ matrix.php-version }}
55-
56-
- name: "Install dependencies with composer"
57-
run: |
58-
composer update --no-interaction --no-progress --no-suggest
59-
37+
php-version: '8.2'
6038
- name: "Run static analyzis with phpstan/phpstan"
6139
run: vendor/bin/phpstan analyze
6240

6341
checkstyke:
6442
name: "Checkstyle"
6543
runs-on: ubuntu-latest
66-
67-
strategy:
68-
matrix:
69-
include:
70-
- php-version: 8.2
71-
7244
steps:
7345
- name: "Checkout"
74-
uses: actions/checkout@v2
75-
76-
- name: "Setup PHP"
77-
uses: shivammathur/setup-php@v2
46+
uses: actions/checkout@v3
47+
- name: "Setup env & install dependencies"
48+
uses: ./.github/actions/install
7849
with:
79-
coverage: none
80-
php-version: ${{ matrix.php-version }}
81-
82-
- name: "Install dependencies with composer"
83-
run: |
84-
composer update --no-interaction --no-progress --no-suggest
85-
50+
php-version: '8.2'
8651
- name: "Run checkstyle with squizlabs/php_codesniffer"
8752
run: vendor/bin/phpcs
8853

8954
codecov:
9055
name: "Code coverage"
9156
runs-on: ubuntu-latest
92-
93-
strategy:
94-
matrix:
95-
include:
96-
- php-version: 8.2
97-
9857
steps:
9958
- name: "Checkout"
100-
uses: actions/checkout@v2
101-
102-
- name: "Setup PHP"
103-
uses: shivammathur/setup-php@v2
59+
uses: actions/checkout@v3
60+
- name: "Setup env & install dependencies"
61+
uses: ./.github/actions/install
10462
with:
105-
coverage: xdebug
106-
php-version: ${{ matrix.php-version }}
107-
108-
- name: "Install dependencies with composer"
109-
run: |
110-
composer update --no-interaction --no-progress --no-suggest
111-
63+
php-version: '8.2'
11264
- name: "Run tests with phpunit/phpunit"
11365
env:
11466
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
11567
run: |
11668
vendor/bin/phpunit --coverage-clover coverage.xml
117-
11869
- name: "Upload coverage to Codecov"
11970
uses: codecov/codecov-action@v1

0 commit comments

Comments
 (0)