-
Notifications
You must be signed in to change notification settings - Fork 145
240 lines (227 loc) · 8.07 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
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
name: CI
on:
push:
branches: [main]
pull_request:
schedule: [cron: "40 1 * * *"]
workflow_dispatch:
env:
RUST_BACKTRACE: short
# CI builds don't benefit very much from this and it has bugs
CARGO_INCREMENTAL: 0
# We can't use a debugger in CI, and this makes builds faster and the cache
# smaller. (TODO: use -Cdebuginfo=0 if it doesn't make backtraces useless)
RUSTFLAGS: -Cdebuginfo=1
CARGO_TERM_COLOR: always
jobs:
test:
name: Test ${{matrix.name || format('Rust {0}', matrix.rust)}}
runs-on: ${{matrix.os || 'ubuntu'}}-latest
strategy:
fail-fast: false
matrix:
include:
- rust: nightly
- rust: beta
- rust: stable
- name: macOS
rust: nightly
os: macos
# Windows GNU disabled due to https://github.com/google/autocxx/issues/1134
# - name: Windows (gnu)
# rust: nightly-x86_64-pc-windows-gnu
# os: windows
- name: Windows (msvc)
rust: nightly-x86_64-pc-windows-msvc
os: windows
flags: /EHsc
env:
CXXFLAGS: ${{matrix.flags}}
RUSTFLAGS: --cfg deny_warnings -Dwarnings
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{matrix.rust}}
components: rustfmt
# The `{ sharedKey: ... }` allows different actions to share the cache.
- uses: Swatinem/rust-cache@v1
with: { sharedKey: fullBuild }
# For operating systems that have it packaged, install creduce
- name: Install creduce (Linux)
if: matrix.os == ''
run: sudo apt-get install creduce
- name: Install creduce (MacOS)
if: matrix.os == 'macOS'
run: brew install creduce
- name: Set LIBCLANG_PATH (Windows)
# Windows github action doesn't set the path for clang, so set it
# See https://github.com/rust-lang/rust-bindgen/issues/1797
if: matrix.os == 'windows'
run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV
- name: Exclude failing targets and tests
# no creduce on Windows, so exclude tests needing creduce there
run: |
echo RUSTFLAGS=$RUSTFLAGS >> $GITHUB_ENV
echo exclude=${{runner.os == 'Windows' && '--exclude autocxx-reduce --exclude autocxx-gen' || ''}} >> "$GITHUB_OUTPUT"
env:
# non-linux failures https://github.com/google/autocxx/issues/819
# beta failing tests https://github.com/google/autocxx/issues/818
RUSTFLAGS: ${{matrix.name == 'Windows (msvc)' && '--cfg skip_windows_msvc_failing_tests' || ''}} ${{matrix.name == 'Windows (gnu)' && '--cfg skip_windows_gnu_failing_tests' || ''}}
id: testsuite
shell: bash
- run: cargo test --workspace ${{steps.testsuite.outputs.exclude}}
examples:
name: Examples ${{matrix.name || format('Rust {0}', matrix.rust)}}
runs-on: ${{matrix.os || 'ubuntu'}}-latest
strategy:
fail-fast: false
matrix:
include:
- rust: nightly
- rust: beta
- rust: stable
- name: macOS
rust: nightly
os: macos
- name: Windows (gnu)
rust: nightly-x86_64-pc-windows-gnu
os: windows
- name: Windows (msvc)
rust: nightly-x86_64-pc-windows-msvc
os: windows
flags: /EHsc
env:
CXXFLAGS: ${{matrix.flags}}
RUSTFLAGS: --cfg deny_warnings -Dwarnings
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{matrix.rust}}
components: rustfmt
- uses: Swatinem/rust-cache@v1
with: { sharedKey: fullBuild }
- name: Set LIBCLANG_PATH (Windows)
# Windows github action doesn't set the path for clang, so set it
# See https://github.com/rust-lang/rust-bindgen/issues/1797
if: matrix.os == 'windows'
run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV
- name: Build s2 example
working-directory: ./examples/s2
# s2 doesn't link on Windows
if: matrix.os != 'windows'
run: cargo build
- name: Build steam example
working-directory: ./examples/steam-mini
run: cargo build
- name: Build subclass example
working-directory: ./examples/subclass
run: cargo build
- name: Build pod example
working-directory: ./examples/pod
run: cargo build
- name: Build chromium render-frame-host example
working-directory: ./examples/chromium-fake-render-frame-host
# chromium-fake-render-frame-host doesn't link on Windows
if: matrix.os != 'windows'
run: cargo build
- name: Build non-trivial-type-on-stack example
working-directory: ./examples/non-trivial-type-on-stack
run: cargo build
- name: Build reference-wrappers example
working-directory: ./examples/reference-wrappers
if: matrix.rust == 'nightly'
run: cargo build
- name: Build cpp_calling_rust example
working-directory: ./examples/cpp_calling_rust
run: cargo build
- name: Build llvm example
working-directory: ./examples/llvm
# llvm example needs to install LLVM 13 headers via apt-get.
if: matrix.os == ''
run: sudo apt-get install llvm-13-dev && cargo build
sanitizer:
name: Address Sanitizer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Need nightly rust.
- uses: hecrj/setup-rust-action@v1
with:
rust-version: nightly
components: rust-src
- uses: Swatinem/rust-cache@v1
- name: Tests with asan
env:
AUTOCXX_ASAN: 1
RUSTFLAGS: -Zsanitizer=address -Cdebuginfo=0
RUSTDOCFLAGS: -Zsanitizer=address
ASAN_OPTIONS: "detect_stack_use_after_return=1:detect_leaks=0"
# Work around https://github.com/rust-lang/rust/issues/59125 by
# disabling backtraces. In an ideal world we'd probably suppress the
# leak sanitization, but we don't care about backtraces here, so long
# as the other tests have them.
RUST_BACKTRACE: "0"
run: cargo -Z build-std test --workspace --target x86_64-unknown-linux-gnu
force-wrapper-generation:
name: Test forcing wrapper generation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1
- name: Tests generating all possible shims
env:
AUTOCXX_FORCE_WRAPPER_GENERATION: 1
run: cargo test --workspace
# Clippy check
clippy:
name: Clippy
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v2
- uses: hecrj/setup-rust-action@v1
with:
components: clippy
- uses: Swatinem/rust-cache@v1
- run: cargo clippy --workspace --tests -- -Dclippy::all
# Mention outdated dependencies
outdated:
name: Outdated
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v2
- uses: dtolnay/install@cargo-outdated
- run: cargo outdated -R -w
# Check rustfmt is good
fmt:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: hecrj/setup-rust-action@v1
with:
components: rustfmt
- run: cargo fmt --all -- --check
# Detect cases where documentation links don't resolve and such.
doc:
name: Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: hecrj/setup-rust-action@v1
- uses: Swatinem/rust-cache@v1
with: { sharedKey: fullBuild }
- run: |
for package in $(cargo metadata --no-deps --format-version=1 | jq -r '.packages[] | .name'); do
cargo rustdoc --color always -p "$package" -- -D warnings
done
env: { RUSTDOCFLAGS: -Dwarnings }