1 name: Clippy Test (bors)
6 # Don't run tests, when only textfiles were modified
15 CARGO_TARGET_DIR: '${{ github.workspace }}/target'
20 runs-on: ubuntu-latest
23 - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
25 github_token: "${{ secrets.github_token }}"
27 uses: actions/checkout@v2.0.0
29 ref: ${{ github.ref }}
30 - name: Check Changelog
32 MESSAGE=$(git log --format=%B -n 1)
33 PR=$(echo "$MESSAGE" | grep -o "#[0-9]*" | head -1 | sed -e 's/^#//')
34 output=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$PR" | \
35 python -c "import sys, json; print(json.load(sys.stdin)['body'])" | \
36 grep "^changelog: " | \
37 sed "s/changelog: //g")
38 if [[ -z "$output" ]]; then
39 echo "ERROR: PR body must contain 'changelog: ...'"
41 elif [[ "$output" = "none" ]]; then
42 echo "WARNING: changelog is 'none'"
48 os: [ubuntu-latest, windows-latest, macos-latest]
49 host: [x86_64-unknown-linux-gnu, i686-unknown-linux-gnu, x86_64-apple-darwin, x86_64-pc-windows-msvc]
52 host: x86_64-apple-darwin
54 host: x86_64-pc-windows-msvc
56 host: x86_64-unknown-linux-gnu
58 host: i686-unknown-linux-gnu
60 host: x86_64-pc-windows-msvc
62 host: x86_64-unknown-linux-gnu
64 host: i686-unknown-linux-gnu
66 host: x86_64-apple-darwin
68 runs-on: ${{ matrix.os }}
71 - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
73 github_token: "${{ secrets.github_token }}"
74 - name: Install dependencies (Linux-i686)
76 sudo dpkg --add-architecture i386
78 sudo apt-get install gcc-multilib libssl-dev:i386 libgit2-dev:i386
79 if: matrix.host == 'i686-unknown-linux-gnu'
80 - name: rust-toolchain
81 uses: actions-rs/toolchain@v1.0.3
84 target: ${{ matrix.host }}
86 - name: Cache cargo dir
87 uses: actions/cache@v1
90 key: ${{ runner.os }}-${{ matrix.host }}
92 uses: actions/checkout@v2.0.0
93 - name: Master Toolchain Setup
94 run: bash setup-toolchain.sh
96 HOST_TOOLCHAIN: ${{ matrix.host }}
99 - name: Set LD_LIBRARY_PATH (Linux)
100 if: runner.os == 'Linux'
102 SYSROOT=$(rustc --print sysroot)
103 echo "::set-env name=LD_LIBRARY_PATH::${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}"
104 - name: Link rustc dylib (MacOS)
105 if: runner.os == 'macOS'
107 SYSROOT=$(rustc --print sysroot)
108 sudo mkdir -p /usr/local/lib
109 sudo find "${SYSROOT}/lib" -maxdepth 1 -name '*dylib' -exec ln -s {} /usr/local/lib \;
110 - name: Set PATH (Windows)
111 if: runner.os == 'Windows'
113 $sysroot = rustc --print sysroot
114 $env:PATH += ';' + $sysroot + '\bin'
115 echo "::set-env name=PATH::$env:PATH"
117 run: cargo build --features deny-warnings
120 run: cargo test --features deny-warnings
122 - name: Test clippy_lints
123 run: cargo test --features deny-warnings
125 working-directory: clippy_lints
126 - name: Test rustc_tools_util
127 run: cargo test --features deny-warnings
129 working-directory: rustc_tools_util
130 - name: Test clippy_dev
131 run: cargo test --features deny-warnings
133 working-directory: clippy_dev
134 - name: Test cargo-clippy
135 run: ../target/debug/cargo-clippy
137 working-directory: clippy_workspace_tests
138 - name: Test clippy-driver
142 # Check sysroot handling
143 sysroot=$(./target/debug/clippy-driver --print sysroot)
144 test "$sysroot" = "$(rustc --print sysroot)"
146 if [[ ${{ runner.os }} == "Windows" ]]; then
147 desired_sysroot=C:/tmp
151 sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot)
152 test "$sysroot" = $desired_sysroot
154 sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot)
155 test "$sysroot" = $desired_sysroot
157 # Make sure this isn't set - clippy-driver should cope without it
158 unset CARGO_MANIFEST_DIR
160 # Run a lint and make sure it produces the expected output. It's also expected to exit with code 1
161 # FIXME: How to match the clippy invocation in compile-test.rs?
162 ./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr && exit 1
163 sed -e 's,tests/ui,$DIR,' -e '/= help/d' cstring.stderr > normalized.stderr
164 diff normalized.stderr tests/ui/cstring.stderr
166 # TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR
170 - name: Run cargo-cache --autoclean
172 cargo install cargo-cache --debug
173 /usr/bin/find ~/.cargo/bin ! -type d -exec strip {} \;
174 cargo cache --autoclean
186 - 'rust-lang/rustfmt'
189 - 'rust-lang/stdarch'
191 - 'chronotope/chrono'
194 - 'rust-lang/futures-rs'
195 - 'rust-itertools/itertools'
196 - 'rust-lang-nursery/failure'
199 runs-on: ubuntu-latest
202 - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
204 github_token: "${{ secrets.github_token }}"
205 - name: rust-toolchain
206 uses: actions-rs/toolchain@v1.0.3
209 target: x86_64-unknown-linux-gnu
211 - name: Cache cargo dir
212 uses: actions/cache@v1
215 key: ${{ runner.os }}-x86_64-unknown-linux-gnu
217 uses: actions/checkout@v2.0.0
218 - name: Master Toolchain Setup
219 run: bash setup-toolchain.sh
222 run: cargo build --features integration
223 - name: Test ${{ matrix.integration }}
224 run: cargo test --test integration --features integration
226 INTEGRATION: ${{ matrix.integration }}
228 - name: Run cargo-cache --autoclean
230 cargo install cargo-cache --debug
231 find ~/.cargo/bin ! -type d -exec strip {} \;
232 cargo cache --autoclean