-
Notifications
You must be signed in to change notification settings - Fork 297
223 lines (184 loc) · 6.3 KB
/
ci.yml
File metadata and controls
223 lines (184 loc) · 6.3 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
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
name: ci
on:
push:
branches: [master]
pull_request:
jobs:
test:
strategy:
matrix:
include:
- runner: ubuntu-latest
os: Linux
arch: x86_64
clang-version: 18
- runner: ubuntu-22.04
os: Linux
arch: x86_64
clang-version: 15
- runner: macos-15
os: macOS
arch: aarch64
clang-version: 22
- runner: macos-15
os: macOS
arch: aarch64
clang-version: 17
fail-fast: false
name: "test (${{ matrix.runner }}: ${{ matrix.os }} ${{ matrix.arch}}, Clang ${{ matrix.clang-version }})"
runs-on: ${{ matrix.runner }}
env:
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
- name: Install Python Packages
run: |
uv venv
uv pip install -r ./scripts/requirements.txt
# rust-cache very carefully caches toolchains and target directories,
# based on the job and toolchain and other factors. See
# https://github.com/Swatinem/rust-cache#cache-details for what gets
# cached, what gets used as part of the key, and what additional handling
# happens to make the cache reliable and smaller.
- uses: Swatinem/rust-cache@v2
with:
cache-workspace-crates: true
# Add the runner name to the cache key because we have
# multiple Linux runners with different versions of the
# system libraries and we do not want to mix them up.
key: "${{ matrix.runner }}"
# Run after `rust-cache` so that this is cached.
- name: Install Rust toolchains
run: |
rustup toolchain install nightly-2022-11-03 \
--profile minimal --component rustfmt,rustc-dev
rustup toolchain install nightly-2023-04-15 \
--profile minimal --component rustfmt
rustup toolchain install nightly-2026-03-03 \
--profile minimal --component rustfmt
- uses: taiki-e/install-action@nextest
- name: cargo fmt --check
run: |
export RUSTFLAGS="$RUSTFLAGS -D warnings"
export RUSTDOCFLAGS="-D warnings"
cargo fmt --check
- name: Install packages (Ubuntu)
if: runner.os == 'Linux'
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: |
clang
clang-tools
cmake
curl
git
gperf
libbrotli-dev
libclang-${{ matrix.clang-version }}-dev
libgcrypt20
libreadline-dev
libidn2-dev
libldap2-dev
libncurses5-dev
libnghttp2-dev
libpcre3-dev
libpsl-dev
librtmp-dev
libssl-dev
libtool
libz3-dev
llvm
llvm-dev
luarocks
ninja-build
pkg-config
rcs
strace
unzip
zlib1g-dev
- name: Install packages (macOS)
if: runner.os == 'macOS'
run: |
# `cmake` needed, but should be already installed.
# `bash` needed b/c macOS ships with bash 3, which doesn't support arrays properly.
brew install -q ninja gpg llvm@${{ matrix.clang-version }} bash z3
echo "Z3_SYS_Z3_HEADER=/opt/homebrew/include/z3.h" >> $GITHUB_ENV
# It's important that we keep `RUSTFLAGS` consistent between different steps
# so that we don't have to rebuild everything.
echo "RUSTFLAGS=-Clink-arg=-L/opt/homebrew/lib -Clink-arg=-Wl,-rpath,/opt/homebrew/lib" >> $GITHUB_ENV
- name: cargo build --release
run: |
export RUSTFLAGS="$RUSTFLAGS -D warnings"
export RUSTDOCFLAGS="-D warnings"
# Don't build with `--all-features` as `--all-features` includes `--features llvm-static`,
# which we don't want to test here (see https://github.com/immunant/c2rust/issues/500).
cargo build --release
- name: cargo nextest run --release --workspace
run: |
export RUSTFLAGS="$RUSTFLAGS -D warnings"
export RUSTDOCFLAGS="-D warnings"
cargo nextest run --release --workspace --no-fail-fast
- name: Test translator
run: |
# `test_translator.py` compiles translated code,
# which has tons of warnings.
# `RUSTFLAGS="-D warnings"` would be inherited by that,
# causing tons of errors, so don't set that.
# `test_translator.py` does not rebuild,
# so changing `RUSTFLAGS` will not trigger a full rebuild.
./scripts/test_translator.py tests/unit
check-postprocess:
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
defaults:
run:
working-directory: c2rust-postprocess
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
- run: uv sync
- run: uv run ruff format --check
- run: uv run ruff check
- run: uv run ty check
- uses: Swatinem/rust-cache@v2
- name: Build tools/split_rust
run: cargo build --release
working-directory: tools/split_rust
- name: Build tools/merge_rust
run: cargo build --release
working-directory: tools/merge_rust
- name: Install packages
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: |
bear
- run: uv run pytest -v
tools:
runs-on: ubuntu-latest
strategy:
matrix:
crate:
- merge_rust
# - related_decls
- rust_util
- split_ffi_entry_points
- split_rust
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-D warnings"
RUSTDOCFLAGS: "-D warnings"
defaults:
run:
working-directory: tools/${{ matrix.crate }}
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
workspaces: tools/${{ matrix.crate }}
- uses: taiki-e/install-action@nextest
- run: cargo fmt --check
- run: cargo build --release
- run: cargo nextest run --release --no-tests warn --no-fail-fast
- run: cargo doc --document-private-items --no-deps