-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (156 loc) · 5.19 KB
/
php.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
name: Test
on:
push:
permissions:
contents: read
jobs:
installPhp:
name: Install PHP
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
- name: Validate composer.json and composer.lock
run: composer validate --strict --no-check-all
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.json') }}
- name: Install PHP dependencies
run: composer install --prefer-dist --no-progress --no-ansi
if: steps.composer-cache.outputs.cache-hit != 'true'
# installNode:
# name: Install Node
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - name: Cache NPM packages
# id: npm-cache
# uses: actions/cache@v3
# with:
# path: node_modules
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-node-
# - name: Install Node dependencies
# run: npm ci
# if: steps.npm-cache.outputs.cache-hit != 'true'
# - name: Cache asset build
# id: asset-cache
# uses: actions/cache@v3
# with:
# path: public/build/
# key: ${{ runner.os }}-assets-${{ hashFiles('resources/css/**/*') }}-${{ hashFiles('resources/js/**/*') }}
# restore-keys: |
# ${{ runner.os }}-assets-
# - name: Build front-end dependencies
# if: steps.asset-cache.outputs.cache-hit != 'true'
# run: npm run build
lintPint:
name: Run Pint
runs-on: ubuntu-latest
# if: github.ref != 'refs/heads/staging' && github.ref != 'refs/heads/main'
needs:
- installPhp
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
- name: Restore Composer cache
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Run Pint
run: vendor/bin/pint --test
lintPhpstan:
name: Run PHPStan
runs-on: ubuntu-latest
# if: github.ref != 'refs/heads/staging' && github.ref != 'refs/heads/main'
needs:
- installPhp
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
- name: Restore Composer cache
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Run PHPStan
run: ./vendor/bin/phpstan analyse || true # make PHPStan look successful until we are closer to 100% passing
test:
name: Run Pest
runs-on: ubuntu-latest
# if: github.ref != 'refs/heads/staging' && github.ref != 'refs/heads/main'
env:
CRAFT_APP_ID: CraftCMS--f8120b60-e9a7-4d6f-8742-ba92ba9cede7
CRAFT_SECURITY_KEY: kVN4WuWyA4EyrKnm65dkZeHXBDjqlJ_P
CRAFT_DB_DRIVER: mysql
CRAFT_DB_SERVER: 127.0.0.1
CRAFT_DB_PORT: 3306
CRAFT_DB_DATABASE: keystone
CRAFT_DB_USER: root
CRAFT_DB_PASSWORD: root
CRAFT_DB_SCHEMA: public
CRAFT_DB_TABLE_PREFIX: craft_
CRAFT_DEV_MODE: true
PRIMARY_SITE_URL: http://localhost:8080/
services:
mysql:
image: mysql
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: keystone
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping --silent"
--health-interval 10s
--health-timeout 5s
--health-retries 5
needs:
- installPhp
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
- name: Restore Composer cache
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
- name: Setup
run: ./bin/post-clone.sh
- name: Remove Craft DB from .env
run: sed -i '/CRAFT_DB/d' .env
- name: Copy project config
run: cp -R tests/fixtures/project/ config/project/
- name: Cache initial DB
id: database-cache
uses: actions/cache@v3
with:
path: seed.sql
key: ${{ runner.os }}-seed-${{ hashFiles('config/project/project.yaml', 'src/migrations/*.php') }}
- name: Install Craft
if: steps.database-cache.outputs.cache-hit != 'true'
run: |
php craft install --username=admin [email protected] --password=secret --siteName=Keystone --siteUrl=http://localhost:8080 --language=en-US
mysqldump -h 127.0.0.1 -u root -proot keystone > seed.sql
- name: Restore database
if: steps.database-cache.outputs.cache-hit == 'true'
run: |
mysql -h 127.0.0.1 -u root -proot keystone < seed.sql
php craft plugin/install keystone
php craft project-config/apply
- name: Install plugins
run: ./bin/post-install.sh
- name: Run test suite
run: ./vendor/bin/pest -vvv