-
Notifications
You must be signed in to change notification settings - Fork 1
184 lines (154 loc) · 4.46 KB
/
Copy pathapi_code_check.yml
File metadata and controls
184 lines (154 loc) · 4.46 KB
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
name: API code check
on:
pull_request:
paths:
- 'api/**'
permissions:
pull-requests: write
contents: read
jobs:
install-deps:
name: Install Composer Dependencies
runs-on: ubuntu-latest
env:
WITH_DOCKER: 0
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: |
~/.composer/cache
api/vendor
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.5
- name: Install dependencies
run: composer install --no-progress --prefer-dist
working-directory: api
stan:
name: PHP Static Analysis
runs-on: ubuntu-latest
needs: install-deps
env:
WITH_DOCKER: 0
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: |
~/.composer/cache
api/vendor
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.5
- name: Run static analysis
run: make stan
phpunit:
name: PHP tests
runs-on: ubuntu-latest
needs: install-deps
env:
WITH_DOCKER: 0
DATABASE_URL: mysql://root:root@127.0.0.1:3306/app?serverVersion=10.4.34-MariaDB&charset=utf8mb4
services:
mariadb:
image: mariadb:10.4
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: app
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: |
~/.composer/cache
api/vendor
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.5
coverage: pcov
- name: Download artifact
id: download-artifact
uses: dawidd6/action-download-artifact@v18
if: github.event_name == 'pull_request'
with:
workflow: api_tests_metrics.yml
name: phpunit-baseline
branch: main
path: .
- name: Setup tests environment
run: make setup-tests
- name: Run tests
id: tests
run: |
./resources/generate_tests_result.php ./baseline.json 2>&1 | tee result.log
EXITCODE=${PIPESTATUS[0]}
echo "output<<EOF" >> $GITHUB_OUTPUT
cat result.log >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
if [ $EXITCODE -ne 0 ]; then
echo "test failed with exit code $EXITCODE"
cat result.log
exit $EXITCODE
fi
- name: Find Comment
uses: peter-evans/find-comment@v4
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: "## 🧪 PHPUnit Report"
- name: Comment json-verify result on PR
if: steps.verify.outcome != 'success'
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
## 🧪 PHPUnit Report
${{ steps.tests.outputs.output }}
replay:
name: PHP replay test
runs-on: ubuntu-latest
needs: install-deps
env:
WITH_DOCKER: 0
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: |
~/.composer/cache
api/vendor
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.5
- name: Run Replays
run: make tests-replay