-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (124 loc) · 3.6 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
name: Test
on:
push:
branches:
- "*"
- "**"
tags-ignore:
- v*
pull_request:
jobs:
test:
name: PHP
runs-on: ubuntu-latest
concurrency:
group: nexus-test-${{ github.ref }}
cancel-in-progress: true
strategy:
matrix:
php: ["8.1"]
steps:
- name: Checkout Code
uses: actions/checkout@v2
#
# ENVIRONMENT DEPENDENCIES SETUP
#
- name: Configure PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Setup Yarn
uses: actions/setup-node@v1
with:
node-version: "12"
# Start MySQL and Create Databases
- name: Create Databases
run: |
sudo systemctl start mysql.service
mysql -e 'CREATE DATABASE IF NOT EXISTS nexus;' -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@v1
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@v1
with:
path: vendor
key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }}
# Install
- name: Install Composer Dependencies
run: composer install --prefer-dist --no-interaction --optimize-autoloader --no-suggest
#
# YARN DEPENDENCIES
#
# Restore Caches
- name: Get Yarn Cache Directory
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Restore Yarn Cache
uses: actions/cache@v1
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# Install
- name: Install assets
run: yarn
- name: Compile assets
run: yarn run prod
- name: Set Environment Variables
uses: allenevans/[email protected]
with:
APP_ENV: testing
APP_KEY: base64:wx/g4ayECKlSzOYSguRFoCrsd+KSbAyEiy0J8zWxxyU=
APP_URL: http://127.0.0.1
CACHE_DRIVER: array
DB_HOST: localhost
DB_PORT: 3306
DB_USERNAME: root
DB_PASSWORD: root
DB_DATABASE: nexus
# Run Database Migration
- name: Migrate Database
run: php artisan migrate
# Cache Setup
- name: Cache Routes
run: php artisan route:cache
- name: Clear Config Cache
run: php artisan config:clear
# Start Application
- name: Serve Application
run: php artisan serve -q &
# Run Tests
- name: Execute Tests
run: php artisan test
trigger-deploy:
name: Trigger Deployment
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
#
# DEPLOY (main only)
#
- name: Trigger Deploy workflow
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.PAT }}
event-type: deploy-trigger