-
Notifications
You must be signed in to change notification settings - Fork 186
151 lines (131 loc) · 5.19 KB
/
nopanic.yaml
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
# This CI config checks that getrandom's backend implementation
# do not contain potential panics.
#
# It is unclear how to implement a no-panic check for esp_idf, fuchsia,
# vxworks, hermit, and solid backends, so we do not check them here,
# but they still should be panic-free. We do not check wasm_js backend
# since glue code generated by wasm-bindgen contains potential panics,
# so resulting WASM files inevitably contain potential panics for any
# code which non-trivially interacts with the JS enviroment.
name: No panic
on:
push:
branches: master
pull_request:
branches: master
permissions:
contents: read
defaults:
run:
working-directory: nopanic_check
env:
RUSTFLAGS: "-Dwarnings"
jobs:
linux:
name: Linux
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: wasm32-wasip1, wasm32-wasip2
- uses: Swatinem/rust-cache@v2
- name: Build (linux_android_with_fallback.rs)
run: cargo build --release
- name: Check (linux_android_with_fallback.rs)
run: (exit $( grep -c panic target/release/libgetrandom_wrapper.so ))
- name: Build (linux_android.rs)
env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="linux_getrandom"
run: cargo build --release
- name: Check (linux_android.rs)
run: (exit $( grep -c panic target/release/libgetrandom_wrapper.so ))
- name: Build (linux_raw.rs)
env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="linux_raw"
run: cargo build --release
- name: Check (linux_raw.rs)
run: (exit $( grep -c panic target/release/libgetrandom_wrapper.so ))
- name: Build (rdrand.rs)
env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="rdrand"
run: cargo build --release
- name: Check (rdrand.rs)
run: (exit $( grep -c panic target/release/libgetrandom_wrapper.so ))
- name: Build (custom.rs)
env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="custom"
run: cargo build --release
- name: Check (custom.rs)
run: (exit $( grep -c panic target/release/libgetrandom_wrapper.so ))
- name: Build (wasi.rs, preview 1)
run: cargo build --release --target wasm32-wasip1
- name: Check (wasi.rs, preview 1)
run: (exit $( grep -c panic target/wasm32-wasip1/release/getrandom_wrapper.wasm ))
- name: Build (wasi.rs, preview 2)
run: cargo build --release --target wasm32-wasip2
- name: Check (wasi.rs, preview 2)
run: (exit $( grep -c panic target/wasm32-wasip2/release/getrandom_wrapper.wasm ))
cross:
name: Cross
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rust-src
targets: aarch64-unknown-linux-gnu,x86_64-unknown-netbsd,x86_64-unknown-freebsd,x86_64-pc-solaris
- uses: Swatinem/rust-cache@v2
# TODO: use pre-compiled cross after a new (post-0.2.5) release
- name: Install cross
env:
# Allow compiler warnings during cross installation
RUSTFLAGS:
run: cargo install cross --force --git https://github.com/cross-rs/cross
- name: Build (rndr.rs)
env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="rndr"
run: cross build --release --target=aarch64-unknown-linux-gnu
- name: Check (rndr.rs)
run: (exit $( grep -c panic target/aarch64-unknown-linux-gnu/release/libgetrandom_wrapper.so ))
- name: Build (getrandom.rs)
run: cross build --release --target=x86_64-unknown-freebsd
- name: Check (getrandom.rs)
run: (exit $( grep -c panic target/x86_64-unknown-freebsd/release/libgetrandom_wrapper.so ))
- name: Build (netbsd.rs)
run: cross build --release --target=x86_64-unknown-netbsd
- name: Check (netbsd.rs)
run: (exit $( grep -c panic target/x86_64-unknown-netbsd/release/libgetrandom_wrapper.so ))
- name: Build (solaris.rs)
run: cross build --release --target=x86_64-pc-solaris
- name: Check (solaris.rs)
run: (exit $( grep -c panic target/x86_64-pc-solaris/release/libgetrandom_wrapper.so ))
macos:
name: macOS
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: aarch64-apple-ios
- uses: Swatinem/rust-cache@v2
# We do not need the grep check since linker fails
# if `panic_nonexistent` can not be eliminated
- name: Build (getentropy.rs)
run: cargo build --release --target=aarch64-apple-darwin
- name: Build (apple-other.rs)
run: cargo build --release --target=aarch64-apple-ios
windows:
name: Windows
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-10-14
components: rust-src
- run: cargo build --release
- run: cargo build --release --target=x86_64-win7-windows-msvc -Zbuild-std="std,panic_abort"