-
Notifications
You must be signed in to change notification settings - Fork 6
195 lines (177 loc) · 8.54 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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
name: CI
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop, master ]
workflow_dispatch:
env:
TARGET_PHP: 8.1
TARGET_MYSQL: 8
DB_HOST: mysql-8
DB_PORT: 3306
DB_USERNAME: cmfive_test
DB_PASSWORD: cmfive_test
DB_DATABASE: cmfive_test
jobs:
# Lint
php-codesniffer74:
name: PHP CS 7.4
runs-on: ubuntu-22.04
steps:
- name: Get phpcs
run: wget https://raw.githubusercontent.com/2pisoftware/cmfive-boilerplate/master/phpcs.xml
- name: Codesniffer
uses: pipeline-components/[email protected]
with:
options: -s -p --colors --extensions=php --runtime-set testVersion 7.4
php-codesniffer80:
name: PHP CS 8.0
runs-on: ubuntu-22.04
steps:
- name: Get phpcs
run: wget https://raw.githubusercontent.com/2pisoftware/cmfive-boilerplate/master/phpcs.xml
- name: Codesniffer
uses: pipeline-components/[email protected]
with:
options: -s -p --colors --extensions=php --runtime-set testVersion 8.0
php-codesniffer81:
name: PHP CS 8.1
runs-on: ubuntu-22.04
steps:
- name: Get phpcs
run: wget https://raw.githubusercontent.com/2pisoftware/cmfive-boilerplate/master/phpcs.xml
- name: Codesniffer
uses: pipeline-components/[email protected]
with:
options: -s -p --colors --extensions=php --runtime-set testVersion 8.1
# Test
run_test:
# Checkout Boilerplate
name: Unit/Acceptance tests
runs-on: ubuntu-22.04
needs: [ php-codesniffer74, php-codesniffer80, php-codesniffer81 ]
steps:
- uses: actions/checkout@v3
with:
repository: '2pisoftware/cmfive-boilerplate'
ref: 'master'
# Pre-requisites Prepare Cmfive Environment
- name: Setup cmfive Test Environment
run: |
cp .codepipeline/test_agent/configs/test_agent-config.php config.php
docker-compose -f test_agent-compose.yml up --build -d
sleep 5
docker ps
docker exec -t nginx-php8.1 bash -c "chmod -R 777 ./*"
docker exec -t nginx-php8.1 bash -c "rm -rf ./system && ln -s ./composer/vendor/2pisoftware/cmfive-core/system ./system"
echo CoreInstall
docker exec -t nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php install core ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} 8.1"
echo DBCreate
docker exec -t mysql-8 bash -c "mysql -h 127.0.0.1 -u'root' -p'root' --execute \"CREATE DATABASE cmfive_test; CREATE USER cmfive_test@'%' IDENTIFIED BY 'cmfive_test'; GRANT ALL PRIVILEGES ON cmfive_test.* TO cmfive_test@'%'; GRANT PROCESS ON *.* TO cmfive_test@'%'; FLUSH PRIVILEGES;\""
docker exec -t nginx-php8.1 bash -c "chmod -R 777 cache/ storage/ uploads/"
docker start seleniumDrv;
docker ps
- name: Inject configs into cmfive Test Environment
run: |
echo "Inheriting test_agent config from PIPELINE"
echo 'Config::append("tests", ["testrunner" => "ENABLED"]);' >> config.php
- name: Prepare cmfive Test Backend
run: |
docker exec nginx-php8.1 bash -c "cd ./test/ && sh ./.install/install.sh && chmod -R 777 /var/www/html/test/Codeception/tests"
- name: Apply cmfive Test Config to Core install
run: |
echo SeedingCmfive
docker exec nginx-php8.1 bash -c "cat config.php"
# docker exec -t nginx-php8.1 bash -c "php cmfive.php install core ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
docker exec -t nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php seed encryption"
docker exec -t nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php install migrations"
docker exec -t nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php seed admin admin admin [email protected] admin admin"
docker exec -t nginx-php8.1 bash -c "chmod -R 777 cache/ storage/ uploads/"
- name: Prepare cmfive Test DB
run: |
docker exec -t nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php testDB setup; exit \$?";
# Build new layout
- uses: actions/setup-node@v3
with:
node-version: 14
- name: Build new designs
run: |
docker exec -t nginx-php8.1 bash -c "chmod -R 777 system/templates/base"
cd system/templates/base
npm i
npm run prod
# Run Unit Tests
- name: "Run unit tests"
run: |
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests unit all; exit \$?"
if [ $? -gt 0 ]; then
echo "Admin module tests failed"
fi
# Run Acceptance Tests
- name: "Confirm Codeception setup"
run: |
docker exec nginx-php8.1 bash -c "ls -lah -R /var/www/html/test/Codeception/tests && cat /var/www/html/test/Codeception/*.yml && cat /var/www/html/test/Codeception/tests/*.yml"
- name: "Run admin module tests"
run: |
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module admin silent; exit \$?"
if [ $? -gt 0 ]; then
echo "Admin module tests failed"
fi
- name: "Run channels module tests"
run: |
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module channels silent; exit \$?"
if [ $? -gt 0 ]; then
echo "Channels module tests failed"
fi
- name: "Run form module tests"
run: |
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module form silent; exit \$?"
if [ $? -gt 0 ]; then
echo "Form module tests failed"
fi
# - name: "Run inbox module tests"
# run: |
# docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module inbox silent; exit \$?"
# if [ $? -gt 0 ]; then
# echo "Inbox module tests failed"
# fi
- name: "Run report module tests"
run: |
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module report silent; exit \$?"
if [ $? -gt 0 ]; then
echo "Report module tests failed"
fi
- name: "Run tag module tests"
run: |
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module tag silent; exit \$?"
if [ $? -gt 0 ]; then
echo "Tag module tests failed"
fi
- name: "Run task module tests"
run: |
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module task silent; exit \$?"
if [ $? -gt 0 ]; then
echo "Task module tests failed"
fi
- name: "Run timelog module tests"
run: |
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module timelog silent; exit \$?"
if [ $? -gt 0 ]; then
echo "Timelog module tests failed"
fi
- name: Stop containers
# the containers should be stopped regardless of
# the test result
if: always()
run: docker-compose down
# Store Test Results
- name: Test results
if: ${{ failure() }} || ${{ success() }}
uses: actions/upload-artifact@v3
with:
name: test-output
path: |
test/Codeception/tests/_output/
storage/log/
retention-days: 5