1name: CI 2 3on: 4 merge_group: 5 pull_request: 6 branches: 7 - libc-0.2 8 9env: 10 CARGO_TERM_VERBOSE: true 11 LIBC_CI: 1 12 13defaults: 14 run: 15 shell: bash 16 17jobs: 18 style_check: 19 name: Style check 20 runs-on: ubuntu-24.04 21 timeout-minutes: 10 22 steps: 23 - uses: actions/checkout@v4 24 - name: Setup Rust toolchain 25 run: ./ci/install-rust.sh 26 - name: Check style 27 run: ./ci/style.sh 28 29 # This runs `cargo build --target ...` for all T1 and T2 targets` 30 verify_build: 31 name: Verify build 32 strategy: 33 matrix: 34 toolchain: [stable, nightly, 1.63.0] 35 os: [ubuntu-24.04, macos-14, windows-2022] 36 include: 37 - toolchain: beta 38 os: ubuntu-24.04 39 runs-on: ${{ matrix.os }} 40 timeout-minutes: 25 41 env: 42 TOOLCHAIN: ${{ matrix.toolchain }} 43 steps: 44 - uses: actions/checkout@v4 45 - name: Setup Rust toolchain 46 run: ./ci/install-rust.sh 47 48 # FIXME(ci): These `du` statements are temporary for debugging cache 49 - name: Target size before restoring cache 50 run: du -sh target | sort -k 2 || true 51 - uses: Swatinem/rust-cache@v2 52 with: 53 key: ${{ matrix.os }}-${{ matrix.toolchain }} 54 - name: Target size after restoring cache 55 run: du -sh target | sort -k 2 || true 56 57 - name: Execute build.sh 58 run: ./ci/verify-build.sh 59 - name: Target size after job completion 60 run: du -sh target | sort -k 2 61 62 test_tier1: 63 name: Test tier1 64 strategy: 65 matrix: 66 include: 67 - target: i686-unknown-linux-gnu 68 docker: true 69 os: ubuntu-24.04 70 - target: x86_64-unknown-linux-gnu 71 docker: true 72 os: ubuntu-24.04 73 - target: aarch64-apple-darwin 74 os: macos-14 75 - target: x86_64-pc-windows-gnu 76 os: windows-2022 77 env: 78 ARCH_BITS: 64 79 ARCH: x86_64 80 - target: x86_64-pc-windows-msvc 81 os: windows-2022 82 # FIXME: It currently causes segfaults. 83 #- target: i686-pc-windows-gnu 84 # env: 85 # ARCH_BITS: 32 86 # ARCH: i686 87 - target: i686-pc-windows-msvc 88 os: windows-2022 89 runs-on: ${{ matrix.os }} 90 timeout-minutes: 25 91 env: 92 TARGET: ${{ matrix.target }} 93 steps: 94 - uses: actions/checkout@v4 95 - name: Setup Rust toolchain 96 run: ./ci/install-rust.sh 97 - uses: Swatinem/rust-cache@v2 98 with: 99 key: ${{ matrix.target }} 100 101 - name: Run natively 102 if: "!matrix.docker" 103 run: ./ci/run.sh ${{ matrix.target }} 104 - name: Run in Docker 105 if: "matrix.docker" 106 run: ./ci/run-docker.sh ${{ matrix.target }} 107 108 - name: Create CI artifacts 109 if: always() 110 run: ./ci/create-artifacts.py 111 - uses: actions/upload-artifact@v4 112 with: 113 name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }} 114 path: ${{ env.ARCHIVE_PATH }} 115 retention-days: 5 116 117 test_tier2: 118 name: Test tier2 119 needs: [test_tier1, style_check] 120 runs-on: ubuntu-24.04 121 strategy: 122 fail-fast: true 123 max-parallel: 12 124 matrix: 125 target: 126 # FIXME(sparc): this takes much longer to run than any other job, put 127 # it first to make sure it gets a head start. 128 - sparc64-unknown-linux-gnu 129 - aarch64-linux-android 130 - aarch64-unknown-linux-gnu 131 - aarch64-unknown-linux-musl 132 - arm-linux-androideabi 133 - arm-unknown-linux-gnueabihf 134 - arm-unknown-linux-musleabihf 135 - i686-linux-android 136 - i686-unknown-linux-musl 137 - loongarch64-unknown-linux-gnu 138 - loongarch64-unknown-linux-musl 139 - powerpc-unknown-linux-gnu 140 - powerpc64-unknown-linux-gnu 141 - powerpc64le-unknown-linux-gnu 142 - riscv64gc-unknown-linux-gnu 143 - s390x-unknown-linux-gnu 144 - wasm32-unknown-emscripten 145 - wasm32-wasip1 146 - wasm32-wasip2 147 - x86_64-linux-android 148 # FIXME: Exec format error (os error 8) 149 # - x86_64-unknown-linux-gnux32 150 - x86_64-unknown-linux-musl 151 # FIXME: It seems some items in `src/unix/mod.rs` 152 # aren't defined on redox actually. 153 # - x86_64-unknown-redox 154 timeout-minutes: 25 155 env: 156 TARGET: ${{ matrix.target }} 157 steps: 158 - uses: actions/checkout@v4 159 - name: Setup Rust toolchain 160 run: ./ci/install-rust.sh 161 - uses: Swatinem/rust-cache@v2 162 with: 163 key: ${{ matrix.target }} 164 165 - name: Execute run-docker.sh 166 run: ./ci/run-docker.sh ${{ matrix.target }} 167 168 - name: Create CI artifacts 169 if: always() 170 run: ./ci/create-artifacts.py 171 - uses: actions/upload-artifact@v4 172 with: 173 name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }} 174 path: ${{ env.ARCHIVE_PATH }} 175 retention-days: 5 176 177 test_tier2_vm: 178 name: Test tier2 VM 179 needs: [test_tier1, style_check] 180 runs-on: ubuntu-latest 181 strategy: 182 fail-fast: true 183 matrix: 184 target: 185 - x86_64-pc-solaris 186 timeout-minutes: 25 187 steps: 188 - uses: actions/checkout@v4 189 - name: test on Solaris 190 uses: vmactions/solaris-vm@v1 191 with: 192 release: "11.4-gcc" 193 usesh: true 194 mem: 4096 195 copyback: false 196 prepare: | 197 set -x 198 source <(curl -s https://raw.githubusercontent.com/psumbera/solaris-rust/refs/heads/main/sh.rust-web-install) 199 rustc --version 200 uname -a 201 run: | 202 export PATH=$HOME/.rust_solaris/bin:$PATH 203 ./ci/run.sh ${{ matrix.target }} 204 205 check_cfg: 206 name: "Check #[cfg]s" 207 runs-on: ubuntu-24.04 208 env: 209 TOOLCHAIN: nightly 210 timeout-minutes: 10 211 steps: 212 - uses: actions/checkout@v4 213 - name: Setup Rust toolchain 214 run: ./ci/install-rust.sh 215 - name: Build with check-cfg 216 run: LIBC_CHECK_CFG=1 cargo build -Z unstable-options -Z check-cfg 217 218 # One job that "summarizes" the success state of this pipeline. This can then be added to branch 219 # protection, rather than having to add each job separately. 220 success: 221 name: success 222 runs-on: ubuntu-24.04 223 needs: 224 - style_check 225 - test_tier1 226 - test_tier2 227 - test_tier2_vm 228 - verify_build 229 # Github branch protection is exceedingly silly and treats "jobs skipped because a dependency 230 # failed" as success. So we have to do some contortions to ensure the job fails if any of its 231 # dependencies fails. 232 if: always() # make sure this is never "skipped" 233 steps: 234 # Manually check the status of all dependencies. `if: failure()` does not work. 235 - name: check if any dependency failed 236 run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}' 237