-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (79 loc) · 2.84 KB
/
build.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
name: Tests Pipeline
on: [push, pull_request]
env:
PHPUNIT_FLAGS: "--filter=Api --stop-on-failure"
jobs:
laravel:
name: Tests Pipeline (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: 'secret'
MYSQL_DATABASE: 'boilerplate'
MYSQL_USER: 'user'
MYSQL_PASSWORD: 'secret'
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
strategy:
fail-fast: false
matrix:
php-versions: ['8.2']
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, dom, fileinfo, mysql
coverage: none
- name: Start mysql service
run: sudo /etc/init.d/mysql start
- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install -q --no-progress --prefer-dist --optimize-autoloader
- name: Prepare Environment
run: |
cp .env.example .env
sed -i "s/3306/${{ job.services.mysql.ports['3306'] }}/g" .env
sed -i "s/DB_PASSWORD=/DB_PASSWORD=secret/g" .env
- name: Clear config cache
run: php artisan config:clear
- name: Generate key
run: php artisan key:generate -q -n
- name: Migrate & Seed Database
run: php artisan migrate --seed --force
- name: Change Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Install javascript packages
run: npm install --quiet --no-progress
- name: Build javascript packages
run: npm run build
- name: Run Laravel Server
run: php artisan serve --port=3000 --no-reload &
- name: curl to localhost
run: curl localhost:3000 &
- name: Run Tests
run: php artisan test ${{ env.PHPUNIT_FLAGS }}