-
Notifications
You must be signed in to change notification settings - Fork 1
189 lines (186 loc) · 6.92 KB
/
ci.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
name: CI
on:
push:
branches:
- master
pull_request:
types:
- opened
- reopened
- edited
- synchronize
- labeled
- assigned
- unlabeled
- unlocked
- review_requested
- review_request_removed
- unassigned
env:
php_extensions: 'apcu, bcmath, ctype, curl, dom, iconv, intl, json, mbstring, opcache, openssl, pdo, pdo_pgsql, pcntl, pcov, posix, redis, session, simplexml, sockets, tokenizer, xml, xmlwriter, zip, xdebug'
key: cache-v0.1
DB_USER: 'postgres'
DB_NAME: 'postgres'
DB_PASSWORD: 'postgres'
DB_HOST: '127.0.0.1'
jobs:
lint:
runs-on: '${{ matrix.operating_system }}'
timeout-minutes: 20
strategy:
matrix:
operating_system: [ubuntu-latest]
php_versions: ['8.3']
fail-fast: false
env:
PHP_CS_FIXER_FUTURE_MODE: '0'
name: 'Linter PHP'
steps:
- name: 'Checkout'
uses: actions/checkout@v2
- name: 'Setup cache environment'
id: cache-env
uses: shivammathur/cache-extensions@v1
with:
php-version: '${{ matrix.php_versions }}'
extensions: '${{ env.php_extensions }}'
key: '${{ env.key }}'
- name: 'Cache extensions'
uses: actions/cache@v1
with:
path: '${{ steps.cache-env.outputs.dir }}'
key: '${{ steps.cache-env.outputs.key }}'
restore-keys: '${{ steps.cache-env.outputs.key }}'
- name: 'Setup PHP'
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php_versions }}
extensions: '${{ env.php_extensions }}'
ini-values: memory_limit=-1
tools: pecl, composer
coverage: none
- name: 'Setup problem matchers for PHP (aka PHP error logs)'
run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"'
- name: 'Setup problem matchers for PHPUnit'
run: 'echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"'
- name: 'Install PHP dependencies with Composer'
run: COMPOSER_MEMORY_LIMIT=-1 composer install --prefer-dist --no-progress --no-suggest --optimize-autoloader
working-directory: './'
- name: 'Linting PHP source files'
run: 'composer lint'
test:
strategy:
fail-fast: false
matrix:
coverage: [true]
experimental: [false]
operating_system: [ubuntu-latest]
postgres: ['11', '12', '13', '14', '15']
laravel: ['^11.0']
php_versions: ['8.3']
include:
- operating_system: ubuntu-latest
postgres: '16'
php_versions: '8.4'
laravel: '^11.0'
experimental: true
coverage: false
runs-on: '${{ matrix.operating_system }}'
services:
postgres:
image: 'postgres:${{ matrix.postgres }}'
env:
POSTGRES_USER: ${{ env.DB_USER }}
POSTGRES_PASSWORD: ${{ env.DB_PASSWORD }}
POSTGRES_DB: ${{ env.DB_NAME }}
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
name: 'Testing / Laravel ${{ matrix.laravel }} / PHP ${{ matrix.php_versions }} / Postgres ${{ matrix.postgres }}'
needs:
- lint
steps:
- name: 'Checkout'
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: 'Install postgres client'
run: |
sudo apt-get update -y
sudo apt-get install -y libpq-dev postgresql-client
- name: 'Setup cache environment'
id: cache-env
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php_versions }}
extensions: ${{ env.php_extensions }}
key: '${{ env.key }}'
- name: 'Cache extensions'
uses: actions/cache@v1
with:
path: '${{ steps.cache-env.outputs.dir }}'
key: '${{ steps.cache-env.outputs.key }}'
restore-keys: '${{ steps.cache-env.outputs.key }}'
- name: 'Setup PHP'
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php_versions }}
extensions: ${{ env.php_extensions }}
ini-values: 'pcov.directory=src, date.timezone=UTC, upload_max_filesize=20M, post_max_size=20M, memory_limit=512M, short_open_tag=Off, xdebug.mode="develop,coverage"'
coverage: xdebug
tools: 'phpunit'
- name: 'Install PHP dependencies with Composer'
continue-on-error: ${{ matrix.experimental }}
run: |
composer require "laravel/framework=${{ matrix.laravel }}" --no-update
COMPOSER_MEMORY_LIMIT=-1 composer install --prefer-dist --no-progress --no-suggest --optimize-autoloader
working-directory: './'
- name: 'Run Unit Tests with PHPUnit'
continue-on-error: ${{ matrix.experimental }}
run: |
cd app
sed -e "s/\${USERNAME}/${{ env.DB_USER }}/" \
-e "s/\${PASSWORD}/${{ env.DB_PASSWORD }}/" \
-e "s/\${DATABASE}/${{ env.DB_NAME }}/" \
-e "s/\${HOST}/${{ env.DB_HOST }}/" \
.env.sample > .env
sed -e "s/\${LARAVEL_VERSION}/${{ matrix.laravel }}/" \
-e "s/\${PHP_VERSION}/${{ matrix.php_versions }}/" \
composer.json.sample > composer.json
composer create-project --prefer-dist laravel/laravel:${{ matrix.laravel }} release
rm -rf release/database/migrations
rm release/.env
rm -rf release/tests
cp -rf database/new_migrations release/database/migrations
cp .env release/.env
cd ../
sed -e "s/\${USERNAME}/${{ env.DB_USER }}/" \
-e "s/\${PASSWORD}/${{ env.DB_PASSWORD }}/" \
-e "s/\${DATABASE}/${{ env.DB_NAME }}/" \
-e "s/\${HOST}/${{ env.DB_HOST }}/" \
phpunit.xml.dist > phpunit.xml
./vendor/bin/phpunit -c phpunit.xml --migrate-configuration
if [[ ${{ matrix.coverage }} == true ]]; then
./vendor/bin/phpunit --stderr --coverage-clover build/logs/clover.xml --coverage-text
else
./vendor/bin/phpunit --stderr
fi
working-directory: './'
- name: 'Upload coverage results to Coveralls'
if: ${{ !matrix.experimental && matrix.coverage }}
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_PARALLEL: true
COVERALLS_FLAG_NAME: php-${{ matrix.php_versions }}-laravel-${{ matrix.laravel }}-postgres-${{ matrix.postgres }}
run: ./vendor/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v
coverage:
needs: test
runs-on: ubuntu-latest
name: "Code coverage"
steps:
- name: 'Coveralls Finished'
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true