-
-
Notifications
You must be signed in to change notification settings - Fork 90
190 lines (170 loc) · 6.34 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: build
on:
push:
branches:
- master
- '*.*'
pull_request: null
schedule:
- cron: '0 0 * * *'
jobs:
security:
name: Security
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php: ['8.3'] # Note: This workflow requires only the LATEST version of PHP
os: [ubuntu-latest]
steps:
# General Steps
- name: Set Git To Use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v3
- name: Configure environment
run: |
export COMPOSER_ROOT_VERSION=$(/usr/bin/jq --null-input --raw-output 'first(inputs["extra"]["branch-alias"])[]' composer.json)
echo COMPOSER_ROOT_VERSION=$COMPOSER_ROOT_VERSION >> $GITHUB_ENV
# Install PHP Dependencies
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Validate Composer
run: composer validate
- name: Get Composer Cache Directory
# Docs: <https://github.com/actions/cache/blob/master/examples.md#php---composer>
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Restore Composer Cache
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-
- name: Install Dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --prefer-dist --no-interaction --no-progress
# Execution
- name: Security Advisories
run: composer require --dev roave/security-advisories:dev-latest
static-analysis:
name: Psalm and Rector
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php: ['8.3'] # Note: This workflow requires only the LATEST version of PHP
os: [ubuntu-latest]
steps:
# General Steps
- name: Set Git To Use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v3
- name: Configure environment
run: |
export COMPOSER_ROOT_VERSION=$(/usr/bin/jq --null-input --raw-output 'first(inputs["extra"]["branch-alias"])[]' composer.json)
echo COMPOSER_ROOT_VERSION=$COMPOSER_ROOT_VERSION >> $GITHUB_ENV
# Install PHP Dependencies
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Validate Composer
run: composer validate
- name: Get Composer Cache Directory
# Docs: <https://github.com/actions/cache/blob/master/examples.md#php---composer>
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Restore Composer Cache
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-
- name: Install Dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --prefer-dist --no-interaction --no-progress
# Execution
- name: Static Analysis
run: |
vendor/bin/psalm --no-cache --shepherd --stats --output-format=checkstyle --php-version=${{ matrix.php }}
vendor/bin/rector --dry-run --clear-cache
#
# Execute unit tests on all valid PHP versions.
#
test:
name: Build (${{matrix.php}}, ${{ matrix.os }}, ${{ matrix.stability }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php: ['8.1', '8.2', '8.3']
os: [ubuntu-latest]
stability: [prefer-lowest, prefer-stable]
steps:
# General Steps
- name: Set Git To Use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v3
- name: Configure environment
run: |
export COMPOSER_ROOT_VERSION=$(/usr/bin/jq --null-input --raw-output 'first(inputs["extra"]["branch-alias"])[]' composer.json)
echo COMPOSER_ROOT_VERSION=$COMPOSER_ROOT_VERSION >> $GITHUB_ENV
# Install PHP Dependencies
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
# PHP Extras
extensions: pdo, pdo_mysql, pdo_sqlite, sockets
coverage: pcov
tools: pecl
ini-values: "memory_limit=-1"
- name: Validate Composer
run: composer validate
- name: Get Composer Cache Directory
# Docs: <https://github.com/actions/cache/blob/master/examples.md#php---composer>
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Restore Composer Cache
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-
- name: Install Dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
# Execution
- name: Execute Tests
run: vendor/bin/phpunit --coverage-clover=coverage.clover
- name: Upload Coverage To Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.clover
fail_ci_if_error: false
- name: Upload coverage to Scrutinizer
continue-on-error: true # if is fork
uses: sudo-bot/action-scrutinizer@latest
with:
cli-args: "--format=php-clover coverage.clover"