forked from VKCOM/kphp
-
Notifications
You must be signed in to change notification settings - Fork 0
219 lines (182 loc) · 9.21 KB
/
Build.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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
name: build
on:
pull_request:
branches:
- master
env:
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: true
HOMEBREW_NO_INSTALL_FROM_API: ""
kphp_root_dir: /home/kitten/kphp
kphp_polyfills_dir: /home/kitten/kphp/kphp-polyfills
kphp_build_dir: /home/kitten/kphp/build
session_php_script: /home/kitten/kphp/docs/test_session_gc.php
kphp_snippets_dir: /home/kitten/kphp/kphp-snippets
kphp_snippets_jobs_dir: /home/kitten/kphp/kphp-snippets/JobWorkers
jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- os: buster
compiler: g++
cpp: 17
asan: off
ubsan: off
light_runtime: off
- os: focal
compiler: clang++
cpp: 17
asan: off
ubsan: on
light_runtime: off
- os: focal
compiler: g++-10
cpp: 20
asan: on
ubsan: off
light_runtime: off
- os: jammy
compiler: g++
cpp: 20
asan: on
ubsan: off
light_runtime: off
# - os: focal
# compiler: g++-11
# cpp: 20
# asan: off
# ubsan: off
# light_runtime: on
# - os: focal
# compiler: clang++-18
# cpp: 20
# asan: off
# ubsan: off
# light_runtime: on
name: "${{matrix.os}}/${{matrix.compiler}}/c++${{matrix.cpp}}/asan=${{matrix.asan}}/ubsan=${{matrix.ubsan}}/light_runtime=${{matrix.light_runtime}}"
steps:
- uses: actions/checkout@v3
- name: Get stippets repo
uses: actions/checkout@v3
with:
repository: 'VKCOM/kphp-snippets'
path: 'kphp-snippets'
- name: Get polyfills repo
uses: actions/checkout@v3
with:
repository: 'VKCOM/kphp-polyfills'
path: 'kphp-polyfills'
- name: Cache docker image
uses: actions/cache@v3
id: docker-image-cache
with:
path: /tmp/docker-save-${{matrix.os}}
key: docker-save-${{matrix.os}}-${{ hashFiles('.github/workflows/Dockerfile.*', 'tests/python/requirements.txt') }}
- name: Build and save docker image
if: steps.docker-image-cache.outputs.cache-hit != 'true'
run: |
docker build -f $GITHUB_WORKSPACE/.github/workflows/Dockerfile.${{matrix.os}} $GITHUB_WORKSPACE -t kphp-build-img-${{matrix.os}} --cache-from=type=local,src=kphp-build-img-${{matrix.os}}-cache
docker tag kphp-build-img-${{matrix.os}} kphp-build-img-${{matrix.os}}-cache && mkdir -p /tmp/docker-save-${{matrix.os}} && docker save kphp-build-img-${{matrix.os}}-cache -o /tmp/docker-save-${{matrix.os}}/kphp-build-env-${{matrix.os}}.tar && ls -lh /tmp/docker-save-${{matrix.os}}
- name: Load docker image from cache
if: steps.docker-image-cache.outputs.cache-hit == 'true'
run: docker load --input /tmp/docker-save-${{matrix.os}}/kphp-build-env-${{matrix.os}}.tar
- name: Start docker container
run: |
docker run -dt --name kphp-build-container-${{matrix.os}} kphp-build-img-${{matrix.os}}-cache
docker cp $GITHUB_WORKSPACE/. kphp-build-container-${{matrix.os}}:${{env.kphp_root_dir}}
- name: Add git safe directory
run: docker exec kphp-build-container-${{matrix.os}} bash -c
"git config --global --add safe.directory ${{env.kphp_root_dir}}"
- name: Check formatting in light runtime folder
if: ${{ matrix.os == 'focal' && matrix.light_runtime == 'on' }}
run: docker exec kphp-build-container-${{matrix.os}} bash -c
"find ${{env.kphp_root_dir}}/runtime-light/ -iname '*.h' -o -iname '*.cpp' | xargs clang-format-18 --dry-run -Werror"
- name: Build all
run: docker exec kphp-build-container-${{matrix.os}} bash -c
"cmake -DCMAKE_CXX_COMPILER=${{matrix.compiler}} -DCMAKE_CXX_STANDARD=${{matrix.cpp}} -DCOMPILE_RUNTIME_LIGHT=${{matrix.light_runtime}} -DADDRESS_SANITIZER=${{matrix.asan}} -DUNDEFINED_SANITIZER=${{matrix.ubsan}} -DPDO_DRIVER_MYSQL=ON -DPDO_DRIVER_PGSQL=ON -DPDO_LIBS_STATIC_LINKING=ON -S ${{env.kphp_root_dir}} -B ${{env.kphp_build_dir}} && make -C ${{env.kphp_build_dir}} -j$(nproc) all"
# - name: Run unit tests
# run: docker exec kphp-build-container-${{matrix.os}} bash -c
# "make -C ${{env.kphp_build_dir}} -j$(nproc) test"
# - name: Compile dummy PHP script
# if: matrix.light_runtime == 'off'
# run: docker exec kphp-build-container-${{matrix.os}} bash -c
# "cd ${{env.kphp_build_dir}} && echo 'hello world' > demo.php && ${{env.kphp_root_dir}}/objs/bin/kphp2cpp --cxx ${{matrix.compiler}} demo.php && kphp_out/server -o --user kitten"
# - name: Compile dummy PHP script
# if: matrix.light_runtime == 'on'
# run: docker exec kphp-build-container-${{matrix.os}} bash -c
# "cd ${{env.kphp_build_dir}} && echo "${{matrix.light_runtime}}" && echo 'hello world' > demo.php && ${{env.kphp_root_dir}}/objs/bin/kphp2cpp --mode k2-component --cxx ${{matrix.compiler}} demo.php"
# - name: Polyfills composer install
# run: docker exec kphp-build-container-${{matrix.os}} bash -c
# "composer install -d ${{env.kphp_polyfills_dir}}"
# - name: Run python tests
# if: matrix.light_runtime == 'off'
# id: python_tests
# continue-on-error: true
# run: docker exec kphp-build-container-${{matrix.os}} bash -c
# "chown -R kitten /home && su kitten -c 'GITHUB_ACTIONS=1 KPHP_TESTS_POLYFILLS_REPO=${{env.kphp_polyfills_dir}} KPHP_CXX=${{matrix.compiler}} python3.7 -m pytest --tb=native -n$(nproc) ${{env.kphp_root_dir}}/tests/python/'"
# - name: Prepare python tests artifacts
# if: ${{ (steps.python_tests.outcome == 'failure') && matrix.light_runtime == 'off' }}
# run: docker cp kphp-build-container-${{matrix.os}}:${{env.kphp_root_dir}}/tests/python/_tmp/ ${{runner.temp}} &&
# rm -rf ${{runner.temp}}/_tmp/*/working_dir
# - name: Upload python tests artifacts
# uses: actions/upload-artifact@v3
# if: ${{ (steps.python_tests.outcome == 'failure') && matrix.light_runtime == 'off' }}
# with:
# path: ${{runner.temp}}/_tmp/
# - name: Fail pipeline if python tests failed
# if: ${{ (steps.python_tests.outcome == 'failure') && matrix.light_runtime == 'off' }}
# run: exit 1
- name: Copy the session_test file
run: docker exec kphp-build-container-${{matrix.os}} bash -c
"cp ${{env.session_php_script}} ${{env.kphp_snippets_dir}}/JobWorkers/"
- name: Compile the session_test project
run: docker exec kphp-build-container-${{matrix.os}} bash -c
"cd ${{env.kphp_snippets_dir}}/JobWorkers/ && ${{env.kphp_root_dir}}/objs/bin/kphp2cpp --cxx ${{matrix.compiler}} -I .. -M server test_session_gc.php"
- name: Start the server
run: docker exec kphp-build-container-${{matrix.os}} bash -c
"cd ${{env.kphp_snippets_dir}}/JobWorkers/ && ./kphp_out/server -f 2 --http-port 8080 --job-workers-ratio 0.5 --sql-port 5555 --user kitten &> log.txt &"
- name: Install curl
run: docker exec kphp-build-container-${{matrix.os}} bash -c
"apt update && apt install curl"
- name: Send a request to the server
run: docker exec kphp-build-container-${{matrix.os}} bash -c
"curl 'http://localhost:8080'"
- name: Read logs
run: docker exec kphp-build-container-${{matrix.os}} bash -c
"cd ${{env.kphp_snippets_dir}}/JobWorkers/ && tail -f log.txt"
# build-macos:
# runs-on: ${{matrix.os}}-12
# strategy:
# matrix:
# include:
# - os: macos
# compiler: clang++
# cpp: 17
# name: "${{matrix.os}}/${{matrix.compiler}}/c++${{matrix.cpp}}"
# steps:
# - uses: actions/checkout@v3
# # because of https://github.com/orgs/Homebrew/discussions/4612
# - name: Check Environment
# run: |
# export HOMEBREW_NO_INSTALL_FROM_API=0
# brew untap --force homebrew/cask
# - name: Setup Environment
# run: |
# brew tap shivammathur/php
# brew update
# brew install re2c cmake coreutils openssl libiconv re2 pcre yaml-cpp zstd googletest shivammathur/php/php@7.4
# brew link --overwrite --force shivammathur/php/php@7.4
# /usr/local/Frameworks/Python.framework/Versions/3.12/bin/python3.12 -m pip install --upgrade pip --break-system-packages && /usr/local/Frameworks/Python.framework/Versions/3.12/bin/pip3 install --break-system-packages jsonschema
# - name: Run cmake
# run: cmake -DCMAKE_CXX_COMPILER=${{matrix.compiler}} -DCMAKE_CXX_STANDARD=${{matrix.cpp}} -DDOWNLOAD_MISSING_LIBRARIES=On -S $GITHUB_WORKSPACE -B ${{runner.workspace}}/build
# - name: Build all
# run: make -C ${{runner.workspace}}/build -j$(nproc) all
# - name: Run unit tests
# run: make -C ${{runner.workspace}}/build -j$(nproc) test
# - name: Compile dummy PHP script
# working-directory: ${{runner.workspace}}/build
# run: |
# echo 'hello world' > demo.php
# $GITHUB_WORKSPACE/objs/bin/kphp2cpp --cxx ${{matrix.compiler}} demo.php
# kphp_out/server -o