|
| 1 | +name: Clippy Test (bors) |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [auto, try] |
| 6 | + # Don't run tests, when only textfiles were modified |
| 7 | + paths-ignore: |
| 8 | + - 'COPYRIGHT' |
| 9 | + - 'LICENSE-*' |
| 10 | + - '**.md' |
| 11 | + - '**.txt' |
| 12 | + |
| 13 | +env: |
| 14 | + RUST_BACKTRACE: 1 |
| 15 | + CARGO_TARGET_DIR: '${{ github.workspace }}/target' |
| 16 | + GHA_CI: 1 |
| 17 | + |
| 18 | +jobs: |
| 19 | + changelog: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Check Changelog |
| 24 | + run: | |
| 25 | + PR=$(echo "${{ github.ref }}" | grep -o "[0-9]*") |
| 26 | + output=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$PR" | \ |
| 27 | + python -c "import sys, json; print(json.load(sys.stdin)['body'])" | \ |
| 28 | + grep "^changelog: " | \ |
| 29 | + sed "s/changelog: //g") |
| 30 | + if [[ -z "$output" ]]; then |
| 31 | + echo "ERROR: PR body must contain 'changelog: ...'" |
| 32 | + exit 1 |
| 33 | + elif [[ "$output" = "none" ]]; then |
| 34 | + echo "WARNING: changelog is 'none'" |
| 35 | + fi |
| 36 | + base: |
| 37 | + needs: changelog |
| 38 | + strategy: |
| 39 | + matrix: |
| 40 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 41 | + host: [x86_64-unknown-linux-gnu, i686-unknown-linux-gnu, x86_64-apple-darwin, x86_64-pc-windows-msvc] |
| 42 | + exclude: |
| 43 | + - os: ubuntu-latest |
| 44 | + host: x86_64-apple-darwin |
| 45 | + - os: ubuntu-latest |
| 46 | + host: x86_64-pc-windows-msvc |
| 47 | + - os: macos-latest |
| 48 | + host: x86_64-unknown-linux-gnu |
| 49 | + - os: macos-latest |
| 50 | + host: i686-unknown-linux-gnu |
| 51 | + - os: macos-latest |
| 52 | + host: x86_64-pc-windows-msvc |
| 53 | + - os: windows-latest |
| 54 | + host: x86_64-unknown-linux-gnu |
| 55 | + - os: windows-latest |
| 56 | + host: i686-unknown-linux-gnu |
| 57 | + - os: windows-latest |
| 58 | + host: x86_64-apple-darwin |
| 59 | + |
| 60 | + runs-on: ${{ matrix.os }} |
| 61 | + |
| 62 | + steps: |
| 63 | + - name: Install dependencies (Linux-i686) |
| 64 | + run: | |
| 65 | + sudo dpkg --add-architecture i386 |
| 66 | + sudo apt-get update |
| 67 | + sudo apt-get install gcc-multilib libssl-dev:i386 libgit2-dev:i386 |
| 68 | + if: matrix.host == 'i686-unknown-linux-gnu' |
| 69 | + - name: rust-toolchain |
| 70 | + uses: actions-rs/[email protected] |
| 71 | + with: |
| 72 | + toolchain: nightly |
| 73 | + target: ${{ matrix.host }} |
| 74 | + profile: minimal |
| 75 | + - name: Cache cargo dir |
| 76 | + uses: actions/cache@v1 |
| 77 | + with: |
| 78 | + path: ~/.cargo |
| 79 | + key: ${{ runner.os }}-${{ matrix.host }} |
| 80 | + - name: Checkout |
| 81 | + |
| 82 | + - name: Master Toolchain Setup |
| 83 | + run: bash setup-toolchain.sh |
| 84 | + env: |
| 85 | + HOST_TOOLCHAIN: ${{ matrix.host }} |
| 86 | + shell: bash |
| 87 | + |
| 88 | + - name: Set LD_LIBRARY_PATH (Linux) |
| 89 | + if: runner.os == 'Linux' |
| 90 | + run: | |
| 91 | + SYSROOT=$(rustc --print sysroot) |
| 92 | + echo "::set-env name=LD_LIBRARY_PATH::${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}" |
| 93 | + - name: Link rustc dylib (MacOS) |
| 94 | + if: runner.os == 'macOS' |
| 95 | + run: | |
| 96 | + SYSROOT=$(rustc --print sysroot) |
| 97 | + sudo mkdir -p /usr/local/lib |
| 98 | + sudo find "${SYSROOT}/lib" -maxdepth 1 -name '*dylib' -exec ln -s {} /usr/local/lib \; |
| 99 | + - name: Set PATH (Windows) |
| 100 | + if: runner.os == 'Windows' |
| 101 | + run: | |
| 102 | + $sysroot = rustc --print sysroot |
| 103 | + $env:PATH += ';' + $sysroot + '\bin' |
| 104 | + echo "::set-env name=PATH::$env:PATH" |
| 105 | + - name: Build |
| 106 | + run: cargo build --features deny-warnings |
| 107 | + shell: bash |
| 108 | + - name: Test |
| 109 | + run: cargo test --features deny-warnings |
| 110 | + shell: bash |
| 111 | + - name: Test clippy_lints |
| 112 | + run: cargo test --features deny-warnings |
| 113 | + shell: bash |
| 114 | + working-directory: clippy_lints |
| 115 | + - name: Test rustc_tools_util |
| 116 | + run: cargo test --features deny-warnings |
| 117 | + shell: bash |
| 118 | + working-directory: rustc_tools_util |
| 119 | + - name: Test clippy_dev |
| 120 | + run: cargo test --features deny-warnings |
| 121 | + shell: bash |
| 122 | + working-directory: clippy_dev |
| 123 | + - name: Test cargo-clippy |
| 124 | + run: ../target/debug/cargo-clippy |
| 125 | + shell: bash |
| 126 | + working-directory: clippy_workspace_tests |
| 127 | + - name: Test clippy-driver |
| 128 | + run: | |
| 129 | + ( |
| 130 | + set -ex |
| 131 | + # Check sysroot handling |
| 132 | + sysroot=$(./target/debug/clippy-driver --print sysroot) |
| 133 | + test "$sysroot" = "$(rustc --print sysroot)" |
| 134 | +
|
| 135 | + if [[ ${{ runner.os }} == "Windows" ]]; then |
| 136 | + desired_sysroot=C:/tmp |
| 137 | + else |
| 138 | + desired_sysroot=/tmp |
| 139 | + fi |
| 140 | + sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot) |
| 141 | + test "$sysroot" = $desired_sysroot |
| 142 | +
|
| 143 | + sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot) |
| 144 | + test "$sysroot" = $desired_sysroot |
| 145 | +
|
| 146 | + # Make sure this isn't set - clippy-driver should cope without it |
| 147 | + unset CARGO_MANIFEST_DIR |
| 148 | +
|
| 149 | + # Run a lint and make sure it produces the expected output. It's also expected to exit with code 1 |
| 150 | + # FIXME: How to match the clippy invocation in compile-test.rs? |
| 151 | + ./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr && exit 1 |
| 152 | + sed -e 's,tests/ui,$DIR,' -e '/= help/d' cstring.stderr > normalized.stderr |
| 153 | + diff normalized.stderr tests/ui/cstring.stderr |
| 154 | +
|
| 155 | + # TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR |
| 156 | + ) |
| 157 | + shell: bash |
| 158 | + |
| 159 | + - name: Run cargo-cache --autoclean |
| 160 | + run: | |
| 161 | + cargo install cargo-cache --debug |
| 162 | + /usr/bin/find ~/.cargo/bin ! -type d -exec strip {} \; |
| 163 | + cargo cache --autoclean |
| 164 | + shell: bash |
| 165 | + integration: |
| 166 | + needs: changelog |
| 167 | + strategy: |
| 168 | + fail-fast: false |
| 169 | + matrix: |
| 170 | + integration: |
| 171 | + - 'rust-lang/rls' |
| 172 | + - 'rust-lang/cargo' |
| 173 | + - 'rust-lang/chalk' |
| 174 | + - 'Geal/nom' |
| 175 | + - 'rust-lang/rustfmt' |
| 176 | + - 'hyperium/hyper' |
| 177 | + - 'rust-itertools/itertools' |
| 178 | + - 'serde-rs/serde' |
| 179 | + - 'rust-lang/stdarch' |
| 180 | + - 'rust-random/rand' |
| 181 | + - 'rust-lang/futures-rs' |
| 182 | + - 'Marwes/combine' |
| 183 | + - 'rust-lang-nursery/failure' |
| 184 | + - 'rust-lang/log' |
| 185 | + - 'chronotope/chrono' |
| 186 | + |
| 187 | + runs-on: ubuntu-latest |
| 188 | + |
| 189 | + steps: |
| 190 | + - name: rust-toolchain |
| 191 | + uses: actions-rs/[email protected] |
| 192 | + with: |
| 193 | + toolchain: nightly |
| 194 | + target: x86_64-unknown-linux-gnu |
| 195 | + profile: minimal |
| 196 | + - name: Cache cargo dir |
| 197 | + uses: actions/cache@v1 |
| 198 | + with: |
| 199 | + path: ~/.cargo |
| 200 | + key: ${{ runner.os }}-x86_64-unknown-linux-gnu |
| 201 | + - name: Checkout |
| 202 | + |
| 203 | + - name: Master Toolchain Setup |
| 204 | + run: bash setup-toolchain.sh |
| 205 | + |
| 206 | + - name: Build |
| 207 | + run: cargo build --features integration |
| 208 | + - name: Test ${{ matrix.integration }} |
| 209 | + run: cargo test --test integration --features integration |
| 210 | + env: |
| 211 | + INTEGRATION: ${{ matrix.integration }} |
| 212 | + |
| 213 | + - name: Run cargo-cache --autoclean |
| 214 | + run: | |
| 215 | + cargo install cargo-cache --debug |
| 216 | + find ~/.cargo/bin ! -type d -exec strip {} \; |
| 217 | + cargo cache --autoclean |
0 commit comments