-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (99 loc) · 3.58 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
# GitHub Actions workflow for Continuos Integration tests
name: CI
on: [push, pull_request]
env:
COMPOSER_ARGS: '--no-interaction --no-progress --prefer-dist --optimize-autoloader'
DB_NAME: p3_db_test
DB_USER: p3_db_user
DB_PASS: secret123
jobs:
build-and-test:
strategy:
fail-fast: false
matrix:
operating-systems: [ubuntu-latest]
php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0']
composer-deps: ['lowest', 'latest']
runs-on: ${{ matrix.operating-systems }}
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_HOST: '172.*.*.*' # grant root access inside docker network
MYSQL_ROOT_PASSWORD: secret123
MYSQL_HOST: localhost # The default host name used by the mysql command-line client.
MYSQL_DATABASE: ${{ env.DB_NAME }}
MYSQL_USER: ${{ env.DB_USER }}
MYSQL_PASSWORD: ${{ env.DB_PASS }}
MYSQL_AUTHENTICATION_PLUGIN: mysql_native_password
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres:
image: postgres:9-alpine
env:
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
POSTGRES_DB: ${{ env.DB_NAME }}
POSTGRES_USER: ${{ env.DB_USER }}
POSTGRES_PASSWORD: ${{ env.DB_PASS }}
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout the repository
uses: actions/checkout@v2
# Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
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@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install Composer dependencies
id: composer-install
run: composer install ${{ env.COMPOSER_ARGS }}
- name: Update Composer dependencies to lowest stable
id: composer-update-lowest
if: ${{ matrix.composer-deps == 'lowest' }}
run: composer update ${{ env.COMPOSER_ARGS }} --prefer-lowest --prefer-stable
- name: Update Composer dependencies to latest
id: composer-update-latest
if: ${{ matrix.composer-deps == 'latest' }}
run: composer update ${{ env.COMPOSER_ARGS }}
- name: Code Style check (phpcs)
id: phpcs
run: composer cs
- name: Static Analysis (phpstan)
id: phpstan
run: composer stan
# - name: Test MySQL connection
# run: mysql --host=localhost --protocol=TCP --port=3306 --user=p3_db_user --password=secret123 -e "SHOW DATABASES"
- name: Test (phpunit)
id: phpunit
env:
TEST_P3_DB_MYSQL: true
TEST_P3_DB_MYSQL_HOST: 127.0.0.1
TEST_P3_DB_MYSQL_PORT: 3306
TEST_P3_DB_MYSQL_DBNAME: ${{ env.DB_NAME }}
TEST_P3_DB_MYSQL_CHARSET: utf8
TEST_P3_DB_MYSQL_USERNAME: ${{ env.DB_USER }}
TEST_P3_DB_MYSQL_PASSWD: ${{ env.DB_PASS }}
run: composer test