fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1name: CI 2 3on: 4 - push 5 - pull_request 6 7jobs: 8 rustfmt: 9 runs-on: ubuntu-latest 10 timeout-minutes: 10 11 12 steps: 13 - uses: actions/checkout@v3 14 15 - name: Avoid installing rustc-dev 16 run: | 17 sed -i 's/components.*/components = ["rustfmt"]/' rust-toolchain 18 echo 'profile = "minimal"' >> rust-toolchain 19 rustfmt -v 20 21 - name: Rustfmt 22 run: | 23 cargo fmt --check 24 rustfmt --check build_system/main.rs 25 rustfmt --check example/* 26 27 28 test: 29 runs-on: ${{ matrix.os }} 30 timeout-minutes: 60 31 32 defaults: 33 run: 34 shell: bash 35 36 strategy: 37 fail-fast: false 38 matrix: 39 include: 40 - os: ubuntu-latest 41 env: 42 TARGET_TRIPLE: x86_64-unknown-linux-gnu 43 - os: macos-latest 44 env: 45 TARGET_TRIPLE: x86_64-apple-darwin 46 # cross-compile from Linux to Windows using mingw 47 - os: ubuntu-latest 48 env: 49 TARGET_TRIPLE: x86_64-pc-windows-gnu 50 - os: ubuntu-latest 51 env: 52 TARGET_TRIPLE: aarch64-unknown-linux-gnu 53 # s390x requires QEMU 6.1 or greater, we could build it from source, but ubuntu 22.04 comes with 6.2 by default 54 - os: ubuntu-latest 55 env: 56 TARGET_TRIPLE: s390x-unknown-linux-gnu 57 - os: windows-latest 58 env: 59 TARGET_TRIPLE: x86_64-pc-windows-msvc 60 - os: windows-latest 61 env: 62 TARGET_TRIPLE: x86_64-pc-windows-gnu 63 64 steps: 65 - uses: actions/checkout@v3 66 67 - name: Cache cargo target dir 68 uses: actions/cache@v3 69 with: 70 path: build/cg_clif 71 key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }} 72 73 - name: Set MinGW as the default toolchain 74 if: matrix.os == 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu' 75 run: rustup set default-host x86_64-pc-windows-gnu 76 77 - name: Install MinGW toolchain and wine 78 if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu' 79 run: | 80 sudo apt-get update 81 sudo apt-get install -y gcc-mingw-w64-x86-64 wine-stable 82 83 - name: Install AArch64 toolchain and qemu 84 if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'aarch64-unknown-linux-gnu' 85 run: | 86 sudo apt-get update 87 sudo apt-get install -y gcc-aarch64-linux-gnu qemu-user 88 89 - name: Install s390x toolchain and qemu 90 if: matrix.env.TARGET_TRIPLE == 's390x-unknown-linux-gnu' 91 run: | 92 sudo apt-get update 93 sudo apt-get install -y gcc-s390x-linux-gnu qemu-user 94 95 - name: Prepare dependencies 96 run: ./y.sh prepare 97 98 - name: Build 99 run: ./y.sh build --sysroot none 100 101 - name: Test 102 env: 103 TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }} 104 run: ./y.sh test 105 106 - name: Install LLVM standard library 107 run: rustup target add ${{ matrix.env.TARGET_TRIPLE }} 108 109 # This is roughly config rust-lang/rust uses for testing 110 - name: Test with LLVM sysroot 111 # Skip native x86_64-pc-windows-gnu. It is way too slow and cross-compiled 112 # x86_64-pc-windows-gnu covers at least part of the tests. 113 if: matrix.os != 'windows-latest' || matrix.env.TARGET_TRIPLE != 'x86_64-pc-windows-gnu' 114 env: 115 TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }} 116 run: ./y.sh test --sysroot llvm --no-unstable-features 117 118 119 # This job doesn't use cg_clif in any way. It checks that all cg_clif tests work with cg_llvm too. 120 test_llvm: 121 runs-on: ubuntu-latest 122 timeout-minutes: 60 123 124 defaults: 125 run: 126 shell: bash 127 128 steps: 129 - uses: actions/checkout@v3 130 131 - name: Prepare dependencies 132 run: ./y.sh prepare 133 134 - name: Disable JIT tests 135 run: | 136 sed -i 's/jit./#jit./' config.txt 137 138 - name: Test 139 env: 140 TARGET_TRIPLE: x86_64-unknown-linux-gnu 141 run: ./y.sh test --use-backend llvm 142 143 bench: 144 runs-on: ubuntu-latest 145 timeout-minutes: 60 146 147 defaults: 148 run: 149 shell: bash 150 151 steps: 152 - uses: actions/checkout@v3 153 154 - name: Cache cargo target dir 155 uses: actions/cache@v3 156 with: 157 path: build/cg_clif 158 key: ${{ runner.os }}-x86_64-unknown-linux-gnu-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }} 159 160 - name: Cache cargo bin dir 161 uses: actions/cache@v3 162 with: 163 path: ~/.cargo/bin 164 key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-bin-dir-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }} 165 166 - name: Install hyperfine 167 run: cargo install hyperfine || true 168 169 - name: Prepare dependencies 170 run: ./y.sh prepare 171 172 - name: Build 173 run: CI_OPT=1 ./y.sh build --sysroot none 174 175 - name: Benchmark 176 run: CI_OPT=1 ./y.sh bench 177 178 179 dist: 180 runs-on: ${{ matrix.os }} 181 timeout-minutes: 60 182 183 defaults: 184 run: 185 shell: bash 186 187 strategy: 188 fail-fast: false 189 matrix: 190 include: 191 # FIXME update at some point in the future once most distros use a newer glibc 192 - os: ubuntu-20.04 193 env: 194 TARGET_TRIPLE: x86_64-unknown-linux-gnu 195 - os: macos-latest 196 env: 197 TARGET_TRIPLE: x86_64-apple-darwin 198 # cross-compile from Linux to Windows using mingw 199 - os: ubuntu-latest 200 env: 201 TARGET_TRIPLE: x86_64-pc-windows-gnu 202 - os: windows-latest 203 env: 204 TARGET_TRIPLE: x86_64-pc-windows-msvc 205 - os: windows-latest 206 env: 207 TARGET_TRIPLE: x86_64-pc-windows-gnu 208 209 steps: 210 - uses: actions/checkout@v3 211 212 - name: Cache cargo target dir 213 uses: actions/cache@v3 214 with: 215 path: build/cg_clif 216 key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-dist-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }} 217 218 - name: Set MinGW as the default toolchain 219 if: matrix.os == 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu' 220 run: rustup set default-host x86_64-pc-windows-gnu 221 222 - name: Install MinGW toolchain and wine 223 if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu' 224 run: | 225 sudo apt-get update 226 sudo apt-get install -y gcc-mingw-w64-x86-64 wine-stable 227 228 - name: Prepare dependencies 229 run: ./y.sh prepare 230 231 - name: Build backend 232 run: CI_OPT=1 ./y.sh build --sysroot none 233 234 - name: Build sysroot 235 run: CI_OPT=1 ./y.sh build 236 237 - name: Package prebuilt cg_clif 238 run: tar cvfJ cg_clif.tar.xz dist 239 240 - name: Upload prebuilt cg_clif 241 if: matrix.os == 'windows-latest' || matrix.env.TARGET_TRIPLE != 'x86_64-pc-windows-gnu' 242 uses: actions/upload-artifact@v3 243 with: 244 name: cg_clif-${{ matrix.env.TARGET_TRIPLE }} 245 path: cg_clif.tar.xz 246 247 - name: Upload prebuilt cg_clif (cross compile) 248 if: matrix.os != 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu' 249 uses: actions/upload-artifact@v3 250 with: 251 name: cg_clif-${{ runner.os }}-cross-x86_64-mingw 252 path: cg_clif.tar.xz 253 254 release: 255 runs-on: ubuntu-latest 256 timeout-minutes: 10 257 if: ${{ github.ref == 'refs/heads/master' }} 258 needs: [rustfmt, test, bench, dist] 259 260 concurrency: 261 group: release-dev 262 cancel-in-progress: true 263 264 steps: 265 - uses: actions/checkout@v3 266 267 - name: Download all built artifacts 268 uses: actions/download-artifact@v3 269 with: 270 path: artifacts/ 271 272 - run: | 273 ls -R artifacts/ 274 mkdir release/ 275 pushd artifacts/ 276 for dir in *; do 277 mv $dir/cg_clif.tar.xz ../release/$dir.tar.xz 278 rmdir $dir/ # verify $dir is empty 279 done 280 popd 281 rmdir artifacts/ # verify all artifacts are represented in release/ 282 ls -R release/ 283 284 - run: npm install --production 285 working-directory: .github/actions/github-release 286 287 - name: Publish Release 288 uses: ./.github/actions/github-release 289 with: 290 files: "release/*" 291 token: ${{ github.token }} 292 continue-on-error: true