-
Notifications
You must be signed in to change notification settings - Fork 57
182 lines (151 loc) · 4.43 KB
/
test.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
name: Tests
on:
push:
branches:
- '*'
- '**'
tags-ignore:
- v*
pull_request:
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
- name: Install PHP dependencies
uses: ramsey/composer-install@v2
- name: 'Lint PHP'
run: composer lint -- --test
test:
name: PHP ${{ matrix.php }} / Composer ${{ matrix.composer }}
needs: lint
runs-on: ubuntu-latest
concurrency:
group: core-test-${{ github.ref }}
cancel-in-progress: true
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
php: ['8.2']
composer: ['v2']
experimental: [false]
steps:
- name: Checkout Code
uses: actions/checkout@v3
#
# ENVIRONMENT DEPENDENCIES SETUP
#
- name: Configure PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:${{ matrix.composer }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
# Start MySQL and Create Databases
- name: Create Databases
run: |
sudo systemctl start mysql.service
mysql -e 'CREATE DATABASE IF NOT EXISTS core;' -h127.0.0.1 -uroot -proot
mysql -e 'CREATE DATABASE IF NOT EXISTS core_testing;' -h127.0.0.1 -uroot -proot
mysql -e 'CREATE DATABASE IF NOT EXISTS cts;' -h127.0.0.1 -uroot -proot
#
# COMPOSER DEPENDENICES
#
# Add GitHub Auth to Composer
- name: Add Composer GitHub Token
run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
# Restore Caches
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Restore Composer Cache
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Restore Vendor From Cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }}
# Install
- name: Install Composer Dependencies
run: |
composer install --no-interaction
php artisan package:discover
#
# NODE BUILD
#
# Restore Caches
- name: Get Node Cache Directory
id: node-cache-dir-path
run: echo "::set-output name=dir::$(node cache dir)"
- name: Restore Node Cache
uses: actions/cache@v3
id: node-cache
with:
path: ${{ steps.node-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
# Install node_modules
- name: Install Core assets
run: npm ci
# Run Webpack
- name: Compile Core assets
run: npm run build
#
# APPLICATION SETUP
#
# Environment Configuration
- name: Create Environment File
run: mv .env.ci .env
# Publish Packages
- name: Publish Horizon
run: php artisan horizon:publish
- name: Publish Telescope
run: php artisan telescope:publish
# Run Database Migration
- name: Migrate & Seed Database
run: php artisan migrate && php artisan cts:migrate:fresh
# Cache Setup
- name: Cache Routes
run: php artisan route:cache
- name: Cache Config
run: php artisan config:cache
# Start Application
- name: Serve Application
run: php artisan serve -q &
#
# RUN TESTING SUITE
#
# Run Tests
- name: Execute PHPUnit Tests
run: vendor/bin/phpunit
trigger-deploy:
name: Trigger Deploy
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
#
# RELEASE (main only)
#
- name: Trigger deploy workflow
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.PAT }}
event-type: deploy-trigger