-
Notifications
You must be signed in to change notification settings - Fork 17
244 lines (215 loc) · 7.17 KB
/
rust.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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Rust
on:
push:
branches:
- master
- debug
pull_request:
branches:
- "**"
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: "1"
RUSTFLAGS: "-D warnings"
LLVM_CONFIG_PATH: llvm-config-10
RUST_STABLE_TOOLCHAIN: "1.65"
RUST_NIGHTLY_TOOLCHAIN: "nightly-2023-07-12"
jobs:
required:
needs:
- test
- fmt
runs-on: ubuntu-20.04
steps:
- name: Check results
run: |
[[ ${{ needs.test.result }} == 'success' ]] || exit 1;
[[ ${{ needs.fmt.result }} == 'success' ]] || exit 1;
test:
name: Test
strategy:
fail-fast: false
matrix:
os:
- ubuntu-20.04
- macos-12
version:
# Many composer dependencies need PHP 7.2+
- php: "7.2"
swoole: "4.6.7"
enable_zend_observer: "Off"
- php: "7.3"
swoole: "4.7.1"
enable_zend_observer: "Off"
- php: "7.4"
swoole: "4.8.10"
enable_zend_observer: "Off"
- php: "8.0"
swoole: "5.0.0"
enable_zend_observer: "Off"
- php: "8.0"
swoole: "5.0.0"
enable_zend_observer: "On"
- php: "8.1"
swoole: "5.0.0"
enable_zend_observer: "Off"
- php: "8.1"
swoole: "5.0.0"
enable_zend_observer: "On"
- php: "8.2"
swoole: "5.0.0"
enable_zend_observer: "Off"
- php: "8.2"
swoole: "5.0.0"
enable_zend_observer: "On"
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: "recursive"
- name: Install libclang and protobuf for Linux
if: matrix.os == 'ubuntu-20.04'
run: sudo apt-get install -y llvm-10-dev libclang-10-dev protobuf-compiler
- name: Install protobuf for Macos
if: matrix.os == 'macos-12'
run: brew install protobuf
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.version.php }}
tools: php-config, composer:v2
extensions: >
bcmath, calendar, ctype, dom, exif, gettext, iconv, intl, json, mbstring,
mysqli, mysqlnd, opcache, pdo, pdo_mysql, phar, posix, readline, redis,
memcached, swoole-${{ matrix.version.swoole }}, xml, xmlreader, xmlwriter,
yaml, zip, mongodb
- name: Setup php-fpm for Linux
if: matrix.os == 'ubuntu-20.04'
run: |
sudo apt-get install -y php${{ matrix.version.php }}-fpm
sudo ln -sf /usr/sbin/php-fpm${{ matrix.version.php }} /usr/sbin/php-fpm
- name: PHP version
run: |
which php ; php --version ; php -m
which php-fpm ; php-fpm --version ; php-fpm -m
php-config || true
php -r 'echo "Swoole version: " . phpversion("swoole") . "\n";'
composer --version
[[ `php --version` == PHP\ ${{ matrix.version.php }}.* ]] || exit 1;
[[ `php-fpm --version` == PHP\ ${{ matrix.version.php }}.* ]] || exit 1;
[[ `php-config --version` == ${{ matrix.version.php }}.* ]] || exit 1;
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_STABLE_TOOLCHAIN }}
override: true
components: clippy
- name: Setup cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ matrix.os }}-test-${{ matrix.version.php }}-${{ hashFiles('**/Cargo.lock') }}
- name: Cargo clippy
uses: actions-rs/cargo@v1
with:
toolchain: ${{ env.RUST_STABLE_TOOLCHAIN }}
command: clippy
args: --release --workspace
- name: Cargo build
uses: actions-rs/cargo@v1
with:
toolchain: ${{ env.RUST_STABLE_TOOLCHAIN }}
command: build
args: --release --workspace
- name: Composer install
run: composer install --working-dir=tests/php
# Build mixture for cargo test.
- name: Docker compose
if: matrix.os == 'ubuntu-20.04'
run: docker compose up -d
# Build mixture for cargo test.
- name: Vagrant up for docker compose
if: matrix.os == 'macos-12'
run: vagrant up
# Try cargo test.
- name: Cargo test
id: cargo-test-step
uses: actions-rs/cargo@v1
with:
toolchain: ${{ env.RUST_STABLE_TOOLCHAIN }}
command: test
args: --release --workspace
env:
ENABLE_ZEND_OBSERVER: ${{ matrix.version.enable_zend_observer }}
continue-on-error: true
# Rebuild the mixture when cargo test failed.
- name: Docker compose restart
if: matrix.os == 'ubuntu-20.04' && steps.cargo-test-step.outcome != 'success'
run: docker compose restart
# Rebuild the mixture when cargo test failed.
- name: Vagrant reload for docker compose
if: matrix.os == 'macos-12' && steps.cargo-test-step.outcome != 'success'
run: vagrant reload
# Delay before retry.
- name: Delay
if: steps.cargo-test-step.outcome != 'success'
run: sleep 20
# Retry cargo test.
- name: Cargo test
if: steps.cargo-test-step.outcome != 'success'
uses: actions-rs/cargo@v1
with:
toolchain: ${{ env.RUST_STABLE_TOOLCHAIN }}
command: test
args: --release --workspace
env:
ENABLE_ZEND_OBSERVER: ${{ matrix.version.enable_zend_observer }}
- name: View logs
if: always()
run: |
cat /tmp/*.log
fmt:
name: Fmt
strategy:
fail-fast: false
matrix:
os:
- ubuntu-20.04
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: "recursive"
- name: Install Rust Nightly
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_NIGHTLY_TOOLCHAIN }}
override: true
components: rustfmt
- name: Cargo fmt
uses: actions-rs/cargo@v1
with:
toolchain: ${{ env.RUST_NIGHTLY_TOOLCHAIN }}
command: fmt
args: --all -- --check