|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: master |
| 6 | + pull_request: |
| 7 | + branches: master |
| 8 | + schedule: |
| 9 | + - cron: "0 12 * * 1" |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + |
| 14 | +env: |
| 15 | + CARGO_INCREMENTAL: 0 |
| 16 | + RUSTFLAGS: "-Dwarnings" |
| 17 | + |
| 18 | +jobs: |
| 19 | + macos: |
| 20 | + name: Apple Other |
| 21 | + # visionOS requires Xcode 15.2+, which is only available on the arm64 runners. |
| 22 | + runs-on: macos-14 |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + - uses: dtolnay/rust-toolchain@nightly |
| 26 | + with: |
| 27 | + targets: aarch64-apple-darwin, aarch64-apple-ios |
| 28 | + components: rust-src |
| 29 | + - uses: Swatinem/rust-cache@v2 |
| 30 | + - run: cargo test --no-run --target=aarch64-apple-darwin --features=std |
| 31 | + - run: cargo test --no-run --target=aarch64-apple-ios --features=std |
| 32 | + - run: cargo test --no-run --target=aarch64-apple-tvos -Zbuild-std --features=std |
| 33 | + - run: cargo test --no-run --target=aarch64-apple-watchos -Zbuild-std --features=std |
| 34 | + # visionOS requires Xcode 15.2+, GitHub Actions defaults to an older version. |
| 35 | + - run: sudo xcode-select -switch /Applications/Xcode_15.2.app |
| 36 | + # std is broken on visionOS right now |
| 37 | + #- run: cargo test --no-run --target=aarch64-apple-visionos -Zbuild-std --features=std |
| 38 | + |
| 39 | + cross: |
| 40 | + name: Cross |
| 41 | + runs-on: ubuntu-24.04 |
| 42 | + strategy: |
| 43 | + matrix: |
| 44 | + target: [ |
| 45 | + # This target is currently broken: |
| 46 | + # https://github.com/rust-random/getrandom/actions/runs/12949235456/job/36119544880 |
| 47 | + # sparcv9-sun-solaris, |
| 48 | + x86_64-unknown-illumos, |
| 49 | + ] |
| 50 | + steps: |
| 51 | + - uses: actions/checkout@v4 |
| 52 | + - name: Install precompiled cross |
| 53 | + run: | |
| 54 | + VERSION=v0.2.5 |
| 55 | + URL=https://github.com/cross-rs/cross/releases/download/${VERSION}/cross-x86_64-unknown-linux-gnu.tar.gz |
| 56 | + wget -O - $URL | tar -xz -C ~/.cargo/bin |
| 57 | + cross --version |
| 58 | + - name: Build Tests |
| 59 | + run: cross test --no-run --target=${{ matrix.target }} --features=std |
| 60 | + |
| 61 | + tier2: |
| 62 | + name: Tier 2 |
| 63 | + runs-on: ubuntu-24.04 |
| 64 | + strategy: |
| 65 | + matrix: |
| 66 | + target: [ |
| 67 | + aarch64-linux-android, |
| 68 | + x86_64-unknown-fuchsia, |
| 69 | + x86_64-unknown-redox, |
| 70 | + x86_64-fortanix-unknown-sgx, |
| 71 | + ] |
| 72 | + steps: |
| 73 | + - uses: actions/checkout@v4 |
| 74 | + - uses: dtolnay/rust-toolchain@stable |
| 75 | + with: |
| 76 | + targets: ${{ matrix.target }} |
| 77 | + - uses: Swatinem/rust-cache@v2 |
| 78 | + - name: Build |
| 79 | + run: cargo build --target=${{ matrix.target }} --features=std |
| 80 | + |
| 81 | + tier3: |
| 82 | + name: Tier 3 |
| 83 | + runs-on: ubuntu-24.04 |
| 84 | + strategy: |
| 85 | + matrix: |
| 86 | + target: [ |
| 87 | + aarch64-kmc-solid_asp3, |
| 88 | + aarch64-unknown-nto-qnx710, |
| 89 | + armv6k-nintendo-3ds, |
| 90 | + armv7-sony-vita-newlibeabihf, |
| 91 | + i686-unknown-hurd-gnu, |
| 92 | + riscv32imc-esp-espidf, |
| 93 | + x86_64-unknown-hermit, |
| 94 | + x86_64-wrs-vxworks, |
| 95 | + x86_64-unknown-dragonfly, |
| 96 | + x86_64-unknown-haiku, |
| 97 | + ] |
| 98 | + steps: |
| 99 | + - uses: actions/checkout@v4 |
| 100 | + - uses: dtolnay/rust-toolchain@nightly # Required to build libcore |
| 101 | + with: |
| 102 | + components: rust-src |
| 103 | + - uses: Swatinem/rust-cache@v2 |
| 104 | + - run: cargo build -Z build-std=core --target=${{ matrix.target }} |
| 105 | + |
| 106 | + # Ubuntu does not support running x32 binaries: |
| 107 | + # https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1994516/comments/21 |
| 108 | + linux-x32: |
| 109 | + name: Linux x32 |
| 110 | + runs-on: ubuntu-24.04 |
| 111 | + strategy: |
| 112 | + matrix: |
| 113 | + target: [x86_64-unknown-linux-gnux32] |
| 114 | + steps: |
| 115 | + - uses: actions/checkout@v4 |
| 116 | + - uses: dtolnay/rust-toolchain@stable |
| 117 | + with: |
| 118 | + targets: ${{ matrix.target }} |
| 119 | + - name: Install libc and libgcc |
| 120 | + run: | |
| 121 | + sudo apt-get update |
| 122 | + sudo apt-get install --no-install-recommends libc6-dev-x32 libx32gcc-11-dev |
| 123 | + - uses: Swatinem/rust-cache@v2 |
| 124 | + - run: cargo build --target=${{ matrix.target }} --features=std |
| 125 | + - env: |
| 126 | + RUSTFLAGS: -Dwarnings --cfg getrandom_backend="linux_getrandom" |
| 127 | + run: cargo build --target=${{ matrix.target }} --features=std |
| 128 | + - env: |
| 129 | + RUSTFLAGS: -Dwarnings --cfg getrandom_test_linux_fallback |
| 130 | + run: cargo build --features=std |
| 131 | + - env: |
| 132 | + RUSTFLAGS: -Dwarnings --cfg getrandom_backend="rdrand" |
| 133 | + run: cargo build --features=std |
| 134 | + |
| 135 | + web: |
| 136 | + name: ${{ matrix.target.description }} ${{ matrix.feature.description }} ${{ matrix.atomic.description }} |
| 137 | + runs-on: ubuntu-24.04 |
| 138 | + env: |
| 139 | + RUSTFLAGS: --cfg getrandom_backend="wasm_js" ${{ matrix.atomic.flags }} |
| 140 | + strategy: |
| 141 | + fail-fast: false |
| 142 | + matrix: |
| 143 | + target: [ |
| 144 | + { description: Web, target: wasm32-unknown-unknown }, |
| 145 | + { description: WasmV1, target: wasm32v1-none }, |
| 146 | + ] |
| 147 | + feature: [ |
| 148 | + { description: no_std, feature: "--features wasm_js", build-std: "core,alloc", std: false }, |
| 149 | + { feature: "--features wasm_js,std", build-std: "panic_abort,std", std: true }, |
| 150 | + ] |
| 151 | + atomic: [ |
| 152 | + { flags: "" }, |
| 153 | + { description: with Atomics, flags: "-Ctarget-feature=+atomics,bulk-memory" }, |
| 154 | + ] |
| 155 | + exclude: |
| 156 | + - target: { target: wasm32v1-none } |
| 157 | + feature: { std: true } |
| 158 | + steps: |
| 159 | + - uses: actions/checkout@v4 |
| 160 | + - uses: dtolnay/rust-toolchain@master |
| 161 | + with: |
| 162 | + targets: ${{ matrix.target.target }} |
| 163 | + toolchain: nightly-2024-10-24 |
| 164 | + components: rust-src |
| 165 | + - uses: Swatinem/rust-cache@v2 |
| 166 | + - name: Build |
| 167 | + run: cargo build --target ${{ matrix.target.target }} ${{ matrix.feature.feature }} -Zbuild-std=${{ matrix.feature.build-std }} |
| 168 | + |
| 169 | + rdrand-uefi: |
| 170 | + name: RDRAND UEFI |
| 171 | + runs-on: ubuntu-24.04 |
| 172 | + strategy: |
| 173 | + matrix: |
| 174 | + target: [ |
| 175 | + x86_64-unknown-uefi, |
| 176 | + i686-unknown-uefi, |
| 177 | + ] |
| 178 | + steps: |
| 179 | + - uses: actions/checkout@v4 |
| 180 | + - uses: dtolnay/rust-toolchain@nightly # Required to build libcore |
| 181 | + with: |
| 182 | + components: rust-src |
| 183 | + - uses: Swatinem/rust-cache@v2 |
| 184 | + - env: |
| 185 | + RUSTFLAGS: -Dwarnings --cfg getrandom_backend="rdrand" |
| 186 | + run: cargo build -Z build-std=core --target=${{ matrix.target }} |
| 187 | + - env: |
| 188 | + RUSTFLAGS: -Dwarnings --cfg getrandom_backend="rdrand" |
| 189 | + run: cargo build -Z build-std=std --target=${{ matrix.target }} --features std |
| 190 | + |
| 191 | + rndr: |
| 192 | + name: RNDR |
| 193 | + runs-on: ubuntu-24.04 |
| 194 | + steps: |
| 195 | + - uses: actions/checkout@v4 |
| 196 | + - uses: dtolnay/rust-toolchain@master |
| 197 | + with: |
| 198 | + toolchain: stable |
| 199 | + targets: aarch64-unknown-linux-gnu, aarch64-apple-darwin |
| 200 | + - uses: Swatinem/rust-cache@v2 |
| 201 | + - name: RNDR enabled at compile time (Linux) |
| 202 | + env: |
| 203 | + RUSTFLAGS: -Dwarnings --cfg getrandom_backend="rndr" -C target-feature=+rand |
| 204 | + run: cargo build --target=aarch64-unknown-linux-gnu |
| 205 | + - name: Runtime RNDR detection without std (Linux) |
| 206 | + env: |
| 207 | + RUSTFLAGS: -Dwarnings --cfg getrandom_backend="rndr" |
| 208 | + run: cargo build --target=aarch64-unknown-linux-gnu |
| 209 | + - name: Runtime RNDR detection with std (macOS) |
| 210 | + env: |
| 211 | + RUSTFLAGS: -Dwarnings --cfg getrandom_backend="rndr" |
| 212 | + run: cargo build --target=aarch64-unknown-linux-gnu --features std |
| 213 | + |
| 214 | + no-atomics: |
| 215 | + name: No Atomics |
| 216 | + runs-on: ubuntu-24.04 |
| 217 | + steps: |
| 218 | + - uses: actions/checkout@v4 |
| 219 | + - uses: dtolnay/rust-toolchain@stable |
| 220 | + with: |
| 221 | + targets: riscv32i-unknown-none-elf |
| 222 | + - uses: Swatinem/rust-cache@v2 |
| 223 | + - env: |
| 224 | + RUSTFLAGS: -Dwarnings --cfg getrandom_backend="custom" |
| 225 | + run: cargo build --target riscv32i-unknown-none-elf |
0 commit comments