1 name: Clippy Test (bors)
6 # Don't run Clippy tests, when only textfiles were modified
15 CARGO_TARGET_DIR: '${{ github.workspace }}/target'
20 runs-on: ubuntu-latest
24 uses: actions/checkout@v2.0.0
26 ref: ${{ github.ref }}
27 - name: Check Changelog
29 MESSAGE=$(git log --format=%B -n 1)
30 PR=$(echo "$MESSAGE" | grep -o "#[0-9]*" | head -1 | sed -e 's/^#//')
31 output=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$PR" | \
32 python -c "import sys, json; print(json.load(sys.stdin)['body'])" | \
33 grep "^changelog: " | \
34 sed "s/changelog: //g")
35 if [[ -z "$output" ]]; then
36 echo "ERROR: PR body must contain 'changelog: ...'"
38 elif [[ "$output" = "none" ]]; then
39 echo "WARNING: changelog is 'none'"
45 os: [ubuntu-latest, windows-latest, macos-latest]
46 host: [x86_64-unknown-linux-gnu, i686-unknown-linux-gnu, x86_64-apple-darwin, x86_64-pc-windows-msvc]
49 host: x86_64-apple-darwin
51 host: x86_64-pc-windows-msvc
53 host: x86_64-unknown-linux-gnu
55 host: i686-unknown-linux-gnu
57 host: x86_64-pc-windows-msvc
59 host: x86_64-unknown-linux-gnu
61 host: i686-unknown-linux-gnu
63 host: x86_64-apple-darwin
65 runs-on: ${{ matrix.os }}
68 - name: Install dependencies (Linux-i686)
70 sudo dpkg --add-architecture i386
72 sudo apt-get install gcc-multilib libssl-dev:i386 libgit2-dev:i386
73 if: matrix.host == 'i686-unknown-linux-gnu'
74 - name: rust-toolchain
75 uses: actions-rs/toolchain@v1.0.3
78 target: ${{ matrix.host }}
80 - name: Cache cargo dir
81 uses: actions/cache@v1
84 key: ${{ runner.os }}-${{ matrix.host }}
86 uses: actions/checkout@v2.0.0
87 - name: Master Toolchain Setup
88 run: bash setup-toolchain.sh
90 HOST_TOOLCHAIN: ${{ matrix.host }}
93 - name: Set LD_LIBRARY_PATH (Linux)
94 if: runner.os == 'Linux'
96 SYSROOT=$(rustc --print sysroot)
97 echo "::set-env name=LD_LIBRARY_PATH::${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}"
98 - name: Link rustc dylib (MacOS)
99 if: runner.os == 'macOS'
101 SYSROOT=$(rustc --print sysroot)
102 sudo mkdir -p /usr/local/lib
103 sudo find "${SYSROOT}/lib" -maxdepth 1 -name '*dylib' -exec ln -s {} /usr/local/lib \;
104 - name: Set PATH (Windows)
105 if: runner.os == 'Windows'
107 $sysroot = rustc --print sysroot
108 $env:PATH += ';' + $sysroot + '\bin'
109 echo "::set-env name=PATH::$env:PATH"
111 run: cargo build --features deny-warnings
114 run: cargo test --features deny-warnings
116 - name: Test clippy_lints
117 run: cargo test --features deny-warnings
119 working-directory: clippy_lints
120 - name: Test rustc_tools_util
121 run: cargo test --features deny-warnings
123 working-directory: rustc_tools_util
124 - name: Test clippy_dev
125 run: cargo test --features deny-warnings
127 working-directory: clippy_dev
128 - name: Test cargo-clippy
129 run: ../target/debug/cargo-clippy
131 working-directory: clippy_workspace_tests
132 - name: Test clippy-driver
136 # Check sysroot handling
137 sysroot=$(./target/debug/clippy-driver --print sysroot)
138 test "$sysroot" = "$(rustc --print sysroot)"
140 if [[ ${{ runner.os }} == "Windows" ]]; then
141 desired_sysroot=C:/tmp
145 sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot)
146 test "$sysroot" = $desired_sysroot
148 sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot)
149 test "$sysroot" = $desired_sysroot
151 # Make sure this isn't set - clippy-driver should cope without it
152 unset CARGO_MANIFEST_DIR
154 # Run a lint and make sure it produces the expected output. It's also expected to exit with code 1
155 # FIXME: How to match the clippy invocation in compile-test.rs?
156 ./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr && exit 1
157 sed -e 's,tests/ui,$DIR,' -e '/= help/d' cstring.stderr > normalized.stderr
158 diff normalized.stderr tests/ui/cstring.stderr
160 # TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR
164 - name: Run cargo-cache --autoclean
166 cargo install cargo-cache --debug
167 /usr/bin/find ~/.cargo/bin ! -type d -exec strip {} \;
168 cargo cache --autoclean