]> git.lizzy.rs Git - rust.git/blob - .github/workflows/clippy_bors.yml
cb2041e4990548f15f3864ccc2c2df510ca03a31
[rust.git] / .github / workflows / clippy_bors.yml
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     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
24       with:
25         github_token: "${{ secrets.github_token }}"
26     - name: Checkout
27       uses: actions/checkout@v2.0.0
28       with:
29         ref: ${{ github.ref }}
30     - name: Check Changelog
31       run: |
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: ...'"
40           exit 1
41         elif [[ "$output" = "none" ]]; then
42           echo "WARNING: changelog is 'none'"
43         fi
44   base:
45     needs: changelog
46     strategy:
47       matrix:
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]
50         exclude:
51         - os: ubuntu-latest
52           host: x86_64-apple-darwin
53         - os: ubuntu-latest
54           host: x86_64-pc-windows-msvc
55         - os: macos-latest
56           host: x86_64-unknown-linux-gnu
57         - os: macos-latest
58           host: i686-unknown-linux-gnu
59         - os: macos-latest
60           host: x86_64-pc-windows-msvc
61         - os: windows-latest
62           host: x86_64-unknown-linux-gnu
63         - os: windows-latest
64           host: i686-unknown-linux-gnu
65         - os: windows-latest
66           host: x86_64-apple-darwin
67
68     runs-on: ${{ matrix.os }}
69
70     steps:
71     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
72       with:
73         github_token: "${{ secrets.github_token }}"
74     - name: Install dependencies (Linux-i686)
75       run: |
76         sudo dpkg --add-architecture i386
77         sudo apt-get update
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
82       with:
83         toolchain: nightly
84         target: ${{ matrix.host }}
85         profile: minimal
86     - name: Cache cargo dir
87       uses: actions/cache@v1
88       with:
89         path: ~/.cargo
90         key: ${{ runner.os }}-${{ matrix.host }}
91     - name: Checkout
92       uses: actions/checkout@v2.0.0
93     - name: Master Toolchain Setup
94       run: bash setup-toolchain.sh
95       env:
96         HOST_TOOLCHAIN: ${{ matrix.host }}
97       shell: bash
98
99     - name: Set LD_LIBRARY_PATH (Linux)
100       if: runner.os == 'Linux'
101       run: |
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'
106       run: |
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'
112       run: |
113         $sysroot = rustc --print sysroot
114         $env:PATH += ';' + $sysroot + '\bin'
115         echo "::set-env name=PATH::$env:PATH"
116     - name: Build
117       run: cargo build --features deny-warnings
118       shell: bash
119     - name: Test
120       run: cargo test --features deny-warnings
121       shell: bash
122     - name: Test clippy_lints
123       run: cargo test --features deny-warnings
124       shell: bash
125       working-directory: clippy_lints
126     - name: Test rustc_tools_util
127       run: cargo test --features deny-warnings
128       shell: bash
129       working-directory: rustc_tools_util
130     - name: Test clippy_dev
131       run: cargo test --features deny-warnings
132       shell: bash
133       working-directory: clippy_dev
134     - name: Test cargo-clippy
135       run: ../target/debug/cargo-clippy
136       shell: bash
137       working-directory: clippy_workspace_tests
138     - name: Test clippy-driver
139       run: |
140         (
141           set -ex
142           # Check sysroot handling
143           sysroot=$(./target/debug/clippy-driver --print sysroot)
144           test "$sysroot" = "$(rustc --print sysroot)"
145
146           if [[ ${{ runner.os }} == "Windows" ]]; then
147             desired_sysroot=C:/tmp
148           else
149             desired_sysroot=/tmp
150           fi
151           sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot)
152           test "$sysroot" = $desired_sysroot
153
154           sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot)
155           test "$sysroot" = $desired_sysroot
156
157           # Make sure this isn't set - clippy-driver should cope without it
158           unset CARGO_MANIFEST_DIR
159
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
165
166           # TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR
167         )
168       shell: bash
169
170     - name: Run cargo-cache --autoclean
171       run: |
172         cargo install cargo-cache --debug
173         /usr/bin/find ~/.cargo/bin ! -type d -exec strip {} \;
174         cargo cache --autoclean
175       shell: bash
176   integration:
177     needs: changelog
178     strategy:
179       fail-fast: false
180       max-parallel: 6
181       matrix:
182         integration:
183         - 'rust-lang/cargo'
184         - 'rust-lang/rls'
185         - 'rust-lang/chalk'
186         - 'rust-lang/rustfmt'
187         - 'Marwes/combine'
188         - 'Geal/nom'
189         - 'rust-lang/stdarch'
190         - 'serde-rs/serde'
191         - 'chronotope/chrono'
192         - 'hyperium/hyper'
193         - 'rust-random/rand'
194         - 'rust-lang/futures-rs'
195         - 'rust-itertools/itertools'
196         - 'rust-lang-nursery/failure'
197         - 'rust-lang/log'
198
199     runs-on: ubuntu-latest
200
201     steps:
202     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
203       with:
204         github_token: "${{ secrets.github_token }}"
205     - name: rust-toolchain
206       uses: actions-rs/toolchain@v1.0.3
207       with:
208         toolchain: nightly
209         target: x86_64-unknown-linux-gnu
210         profile: minimal
211     - name: Cache cargo dir
212       uses: actions/cache@v1
213       with:
214         path: ~/.cargo
215         key: ${{ runner.os }}-x86_64-unknown-linux-gnu
216     - name: Checkout
217       uses: actions/checkout@v2.0.0
218     - name: Master Toolchain Setup
219       run: bash setup-toolchain.sh
220
221     - name: Build
222       run: cargo build --features integration
223     - name: Test ${{ matrix.integration }}
224       run: cargo test --test integration --features integration
225       env:
226         INTEGRATION: ${{ matrix.integration }}
227
228     - name: Run cargo-cache --autoclean
229       run: |
230         cargo install cargo-cache --debug
231         find ~/.cargo/bin ! -type d -exec strip {} \;
232         cargo cache --autoclean