Skip to content

Commit aa3abaf

Browse files
committed
Add Clippy Test (bors) to GHA
1 parent 5f15a9b commit aa3abaf

File tree

1 file changed

+146
-0
lines changed

1 file changed

+146
-0
lines changed

.github/workflows/clippy_bors.yml

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: Clippy Test (bors)
2+
3+
on:
4+
push:
5+
branches: [auto, try]
6+
# Don't run Clippy 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+
base:
20+
strategy:
21+
matrix:
22+
os: [ubuntu-latest, windows-latest, macos-latest]
23+
host: [x86_64-unknown-linux-gnu, i686-unknown-linux-gnu, x86_64-apple-darwin, x86_64-pc-windows-msvc]
24+
exclude:
25+
- os: ubuntu-latest
26+
host: x86_64-apple-darwin
27+
- os: ubuntu-latest
28+
host: x86_64-pc-windows-msvc
29+
- os: macos-latest
30+
host: x86_64-unknown-linux-gnu
31+
- os: macos-latest
32+
host: i686-unknown-linux-gnu
33+
- os: macos-latest
34+
host: x86_64-pc-windows-msvc
35+
- os: windows-latest
36+
host: x86_64-unknown-linux-gnu
37+
- os: windows-latest
38+
host: i686-unknown-linux-gnu
39+
- os: windows-latest
40+
host: x86_64-apple-darwin
41+
42+
runs-on: ${{ matrix.os }}
43+
44+
steps:
45+
- name: Install dependencies (Linux-i686)
46+
run: |
47+
sudo dpkg --add-architecture i386
48+
sudo apt-get update
49+
sudo apt-get install gcc-multilib libssl-dev:i386 libgit2-dev:i386
50+
if: matrix.host == 'i686-unknown-linux-gnu'
51+
- name: rust-toolchain
52+
uses: actions-rs/[email protected]
53+
with:
54+
toolchain: nightly
55+
target: ${{ matrix.host }}
56+
profile: minimal
57+
- name: Cache cargo dir
58+
uses: actions/cache@v1
59+
with:
60+
path: ~/.cargo
61+
key: ${{ runner.os }}-${{ matrix.host }}
62+
- name: Checkout
63+
uses: actions/[email protected]
64+
- name: Master Toolchain Setup
65+
run: bash setup-toolchain.sh
66+
env:
67+
HOST_TOOLCHAIN: ${{ matrix.host }}
68+
shell: bash
69+
70+
- name: Set LD_LIBRARY_PATH (Linux)
71+
if: runner.os == 'Linux'
72+
run: |
73+
SYSROOT=$(rustc --print sysroot)
74+
echo "::set-env name=LD_LIBRARY_PATH::${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}"
75+
- name: Link rustc dylib (MacOS)
76+
if: runner.os == 'macOS'
77+
run: |
78+
SYSROOT=$(rustc --print sysroot)
79+
sudo mkdir -p /usr/local/lib
80+
sudo find "${SYSROOT}/lib" -maxdepth 1 -name '*dylib' -exec ln -s {} /usr/local/lib \;
81+
- name: Set PATH (Windows)
82+
if: runner.os == 'Windows'
83+
run: |
84+
$sysroot = rustc --print sysroot
85+
$env:PATH += ';' + $sysroot + '\bin'
86+
echo "::set-env name=PATH::$env:PATH"
87+
- name: Build
88+
run: cargo build --features deny-warnings
89+
shell: bash
90+
- name: Test
91+
run: cargo test --features deny-warnings
92+
shell: bash
93+
- name: Test clippy_lints
94+
run: cargo test --features deny-warnings
95+
shell: bash
96+
working-directory: clippy_lints
97+
- name: Test rustc_tools_util
98+
run: cargo test --features deny-warnings
99+
shell: bash
100+
working-directory: rustc_tools_util
101+
- name: Test clippy_dev
102+
run: cargo test --features deny-warnings
103+
shell: bash
104+
working-directory: clippy_dev
105+
- name: Test cargo-clippy
106+
run: ../target/debug/cargo-clippy
107+
shell: bash
108+
working-directory: clippy_workspace_tests
109+
- name: Test clippy-driver
110+
run: |
111+
(
112+
set -ex
113+
# Check sysroot handling
114+
sysroot=$(./target/debug/clippy-driver --print sysroot)
115+
test "$sysroot" = "$(rustc --print sysroot)"
116+
117+
if [[ ${{ runner.os }} == "Windows" ]]; then
118+
desired_sysroot=C:/tmp
119+
else
120+
desired_sysroot=/tmp
121+
fi
122+
sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot)
123+
test "$sysroot" = $desired_sysroot
124+
125+
sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot)
126+
test "$sysroot" = $desired_sysroot
127+
128+
# Make sure this isn't set - clippy-driver should cope without it
129+
unset CARGO_MANIFEST_DIR
130+
131+
# Run a lint and make sure it produces the expected output. It's also expected to exit with code 1
132+
# FIXME: How to match the clippy invocation in compile-test.rs?
133+
./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr && exit 1
134+
sed -e 's,tests/ui,$DIR,' -e '/= help/d' cstring.stderr > normalized.stderr
135+
diff normalized.stderr tests/ui/cstring.stderr
136+
137+
# TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR
138+
)
139+
shell: bash
140+
141+
- name: Run cargo-cache --autoclean
142+
run: |
143+
cargo install cargo-cache --debug
144+
/usr/bin/find ~/.cargo/bin ! -type d -exec strip {} \;
145+
cargo cache --autoclean
146+
shell: bash

0 commit comments

Comments
 (0)