forked from dbus2/zbus
-
Notifications
You must be signed in to change notification settings - Fork 0
242 lines (227 loc) · 8.58 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
name: Lint, Build and Test
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
fmt:
runs-on: ubuntu-latest
env:
RUSTFLAGS: -D warnings
RUST_BACKTRACE: full
RUST_LOG: trace
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
# We use some nightly fmt options.
toolchain: nightly
components: rustfmt
targets: x86_64-apple-darwin, x86_64-unknown-freebsd, x86_64-unknown-netbsd x86_64-pc-windows-gnu
- uses: Swatinem/rust-cache@v2
- name: Check formatting
run: |
cargo --locked fmt -- --check
cargo --locked check --target x86_64-apple-darwin
cargo --locked check --target x86_64-unknown-freebsd
cargo --locked check --target x86_64-unknown-netbsd
cargo --locked check --target x86_64-pc-windows-gnu
clippy:
runs-on: ubuntu-latest
env:
RUSTFLAGS: -D warnings
RUST_BACKTRACE: full
RUST_LOG: trace
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: clippy
targets: x86_64-apple-darwin, x86_64-unknown-freebsd, x86_64-unknown-netbsd x86_64-pc-windows-gnu
- uses: Swatinem/rust-cache@v2
- name: Catch common mistakes and unwrap calls
run: |
cargo --locked clippy
cargo --locked clippy --target x86_64-apple-darwin
cargo --locked clippy --target x86_64-unknown-freebsd
cargo --locked clippy --target x86_64-unknown-netbsd
cargo --locked clippy --target x86_64-pc-windows-gnu
linux_test:
runs-on: ubuntu-latest
needs: [fmt, clippy]
strategy:
matrix:
# Test in both debug and release mode
env:
- PROFILE: dev
- PROFILE: release
env:
RUSTFLAGS: -D warnings
RUST_BACKTRACE: full
RUST_LOG: trace
PROFILE: ${{ matrix.env.PROFILE }}
steps:
- uses: actions/checkout@v4
- name: Setup
run: |
sudo mkdir -p /run/user/$UID |
sed -e s/UID/$UID/ -e s/PATH/path/ CI/dbus-session.conf > /tmp/dbus-session.conf
sed -e s/UID/$UID/ -e s/PATH/abstract/ CI/dbus-session.conf > /tmp/dbus-session-abstract.conf
sudo apt-get install -y dbus
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Build and Test
run: |
dbus-run-session --config-file /tmp/dbus-session-abstract.conf -- cargo --locked test --profile "$PROFILE" --verbose -- basic_connection
# All features except tokio.
dbus-run-session --config-file /tmp/dbus-session.conf -- \
cargo --locked test --profile "$PROFILE" --verbose --features uuid,url,time,chrono,option-as-array,vsock,bus-impl \
-- --skip fdpass_systemd
# Test tokio support.
dbus-run-session --config-file /tmp/dbus-session.conf -- \
cargo --locked test --profile "$PROFILE" --verbose --tests -p zbus --no-default-features \
--features tokio-vsock -- --skip fdpass_systemd
dbus-run-session --config-file /tmp/dbus-session.conf -- \
cargo --locked test --profile "$PROFILE" --verbose --doc --no-default-features connection::Connection::executor
# zvariant only with ostree tests (which implicitly enables `gvariant` feature too).
cargo --locked t -p zvariant --features ostree-tests
windows_test:
runs-on: windows-latest
needs: [fmt, clippy]
env:
RUSTFLAGS: -D warnings
RUST_BACKTRACE: full
RUST_LOG: trace
PKG_CONFIG: C:\bin\pkg-config.exe
PKG_CONFIG_PATH: C:\lib\pkgconfig
steps:
- uses: actions/checkout@v4
- name: Cache Dependencies
id: cache-deps
uses: actions/cache@v4
with:
path: |
c:/share/*dbus*
c:/lib/libexpat.lib
c:/bin/libexpat.dll
c:/bin/xmlwf.exe
c:/bin/*dbus*
c:/lib/*dbus*
c:/bin/*pkg-config*
c:/var/lib/*dbus*
c:/lib/*glib*
c:/lib/*gio*
c:/lib/*gobject*
c:/lib/*gmodule*
c:/lib/*gthread*
c:/lib/*gspawn*
c:/lib/*gresource*
c:/lib/*pcre*
c:/lib/*z*
c:/lib/*ffi*
c:/lib/*intl*
c:/lib/*pkgconfig*
c:/bin/*glib*
c:/bin/*gio*
c:/bin/*gobject*
c:/bin/*gmodule*
c:/bin/*gthread*
c:/bin/*gspawn*
c:/bin/*gresource*
c:/bin/*pcre*
c:/bin/*z*
c:/bin/*ffi*
c:/bin/*intl*
key: ${{ runner.os }}-cache
- name: Install Meson and Ninja
if: steps.cache-deps.outputs.cache-hit != 'true'
run: pip3 install meson ninja
- name: Install pkg-config
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
git clone --branch meson-glib-subproject --depth 1 https://gitlab.freedesktop.org/tpm/pkg-config.git
cd pkg-config
meson build -Dprefix=C:\ --buildtype release
ninja -C build
ninja -C build install
- name: Setup MSVC Environment
if: steps.cache-deps.outputs.cache-hit != 'true'
uses: ilammy/msvc-dev-cmd@v1
- name: Build & Install GLib
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
(New-Object System.Net.WebClient).DownloadString('https://wrapdb.mesonbuild.com/v2/pcre_8.37-2/get_patch') >$null
(New-Object System.Net.WebClient).DownloadString('https://zlib.net/fossils/') >$null
git clone --depth 1 --branch 2.74.1 https://gitlab.gnome.org/GNOME/glib.git \glib
cd -Path \glib
meson setup builddir
meson compile -C builddir
meson install --no-rebuild -C builddir
- name: Build & Install libexpat
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
# Upstream expat doesn't ship devel? let's build it then...
git clone --depth 1 --branch R_2_4_2 https://github.com/libexpat/libexpat \libexpat
cd -Path \libexpat\expat
cmake --install-prefix c:/ -G "Visual Studio 17 2022" -A x64 .
cmake --build . --config Release
cmake --install . --config Release
- name: Build & Install dbus daemon
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
git clone --depth 1 https://gitlab.freedesktop.org/dbus/dbus.git \dbus
cd -Path \dbus
cmake --install-prefix c:/ -DCMAKE_PREFIX_PATH=C:/ -DDBUS_ENABLE_XML_DOCS=OFF -DDBUS_ENABLE_DOXYGEN_DOCS=OFF -G "NMake Makefiles" .
nmake
nmake install
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Test
run: |
$env:PATH += ";C:\bin"
Start-Process dbus-daemon.exe '--config-file=CI/win32-session.conf --address=autolaunch:'
cargo --locked test
# tokio feature
cargo --locked test --no-default-features --features tokio
# zvariant only with ostree tests (which implicitly enables `gvariant` feature too).
cargo --locked t -p zvariant --features ostree-tests
zvariant_fuzz:
runs-on: ubuntu-latest
env:
RUSTFLAGS: -D warnings
RUST_BACKTRACE: full
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
- uses: Swatinem/rust-cache@v2
- name: Fuzz zvariant
run: |
cargo --locked install cargo-fuzz
cargo --locked fuzz run --fuzz-dir zvariant/fuzz dbus -- -max_total_time=30 -max_len=100M
cargo --locked fuzz run --fuzz-dir zvariant/fuzz --features gvariant gvariant -- -max_total_time=30 -max_len=100M
doc_build:
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: -D warnings
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Check zvariant documentation build
run: cargo --locked doc --all-features -p zvariant
- name: Check zbus_names documentation build
run: cargo --locked doc --all-features -p zbus_names
- name: Check zbus documentation build
run: cargo --locked doc --all-features -p zbus
- name: Check zbus_xml documentation build
run: cargo --locked doc --all-features -p zbus_xml