forked from allysonsilva/conference-talks-management
-
Notifications
You must be signed in to change notification settings - Fork 0
232 lines (189 loc) · 7.08 KB
/
ci-workflow.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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: Continuous Integration APP Laravel
# Trigger the workflow on push or pull request
# on: [push, pull_request]
on:
push:
branches:
- master
- 'releases/**' # Push events to branches matching refs/heads/releases/10
tags:
- v1 # Push events to v1 tag
- v1.* # Push events to v1.0, v1.1, and v1.9 tags
# file paths to consider in the event. Optional; defaults to all.
paths:
- 'tests/**'
pull_request:
types: [opened, synchronize, reopened]
branches:
- master
release:
types:
- created
- published
jobs:
php-tests:
name: Run Laravel(${{ matrix.laravel }}) | PHP-${{ matrix.php }} | OS(${{ matrix.os }})
runs-on: ${{ matrix.os }}
env:
DB_DATABASE: app
DB_USERNAME: root
DB_PASSWORD: password
# CACHE_DRIVER: redis
# QUEUE_CONNECTION: redis
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: app
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
redis:
image: redis:5
ports:
- 6379/tcp
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: true
max-parallel: 2
matrix:
php: [7.4]
laravel: [6.*, 5.8.*, 5.7.*]
os: [ubuntu-latest]
# exclude:
# - laravel: 5.7.*
# php: 7.4
steps:
- name: Checkout Code
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Setup PHP, with Composer and Extensions
uses: shivammathur/setup-php@v1
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, fileinfo, zip, pcntl, pdo, sqlite, pdo_sqlite, pdo_mysql, bcmath, soap, intl, gd, exif, iconv, imagick, redis, ds
coverage: xdebug
- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache Composer Dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install Dependencies && Prepare Laravel Application
run: composer run-script setup-init --ansi
# - name: Run Migration
# run: php artisan migrate -v
# env:
# DB_PORT: ${{ job.services.mysql.ports['3306'] }}
# REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
- name: Run PHPUnit Tests
if: success()
# @see https://phpunit.readthedocs.io/en/8.5/code-coverage-analysis.html#speeding-up-code-coverage-with-xdebug
run: composer run-script --ansi tests
# phpdbg -qrr ./vendor/bin/paratest --runner WrapperRunner --colors --testsuite Unit
# ./vendor/bin/phpunit --dump-xdebug-filter build/xdebug-filter.php
# ./vendor/bin/phpunit --prepend build/xdebug-filter.php --order-by=defects --coverage-text --colors=auto --testsuite Feature
env:
APP_ENV: testing
# DB_PORT: ${{ job.services.mysql.ports['3306'] }}
# REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
# - name: Send Slack Notification
# uses: 8398a7/action-slack@v2
# if: failure()
# with:
# status: ${{ job.status }}
# author_name: ${{ github.actor }}
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Upload Artifacts
# uses: actions/upload-artifact@master
# if: failure()
# with:
# name: Logs
# path: ./storage/logs
php-coding-standard:
name: Coding Standard
runs-on: ubuntu-latest
needs: [php-tests]
steps:
- name: Checkout Code
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: '7.4'
extensions: curl, libxml, mbstring, fileinfo, pcntl, pdo, sqlite, pdo_sqlite, pdo_mysql, bcmath, intl, redis, ds
# tools: phpcs:3.*, phpmd:@stable, phpstan
coverage: none
- name: Install Dependencies (PHP vendors)
run: |
composer install --no-interaction --no-suggest --prefer-dist --optimize-autoloader
- name: Prepare Laravel Application
run: |
php -r "file_exists('.env') || copy('.env.example', '.env');"
php artisan key:generate --ansi
- name: Remove the Cached Bootstrap Files
run: php artisan optimize:clear
- name: Run PHPStan - PHP Static Analysis Tool
run: ./vendor/bin/phpstan analyse --error-format=table --memory-limit=1G
- name: Run PHPCS - CodeSniffer - Coding Standards
run: ./vendor/bin/phpcs --tab-width=4 --encoding=utf-8 -d memory_limit=128M --report=full --report-width=auto
- name: Run PHPMD - PHP Mess Detector
run: ./vendor/bin/phpmd app ansi phpmd.xml --suffixes php
- name: Run PHPCPD - PHP Copy/Paste Detector
run: ./vendor/bin/phpcpd --fuzzy --no-interaction --ansi --progress --min-lines=5 --min-tokens=70 app
# js-tests:
# name: Run Tests (JS)
# runs-on: ubuntu-18.04
# strategy:
# matrix:
# node_version: [10, 12]
# steps:
# - name: Checkout Repository
# uses: actions/checkout@v2
# - name: Use Node.js ${{ matrix.node_version }}
# uses: actions/setup-node@v1
# with:
# version: ${{ matrix.node_version }}
# - name: npm install, build, and test
# run: |
# npm install
# npm run build --if-present
# npm test
# - name: Archive Code Coverage Results
# uses: actions/upload-artifact@v1
# if: failure()
# with:
# name: code-coverage-report
# path: output/test/code-coverage.html
# - name: Archive Production Artifacts
# uses: actions/upload-artifact@v1
# with:
# name: dist
# path: dist
# build-docker:
# name: Docker Image CI
# runs-on: ubuntu-latest
# needs: [php-tests, php-coding-standard]
# # if: github.ref == 'refs/heads/master'
# steps:
# - uses: actions/checkout@v2
# - name: Login to DockerHub Registry
# run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
# - name: Get The Version
# id: vars
# run: echo ::set-output name=tag::$(echo ${GITHUB_REF:10})
# - name: Build The Tagged Docker Image
# run: docker build . --file Dockerfile --tag ${{ secrets.DOCKERHUB_REPOSITORY }}:${{steps.vars.outputs.tag}}
# - name: Push The Tagged Docker image
# run: docker push ${{ secrets.DOCKERHUB_REPOSITORY }}:${{steps.vars.outputs.tag}}