]> git.lizzy.rs Git - rust.git/blob - .github/workflows/clippy_bors.yml
ci: partly clean build artifacts to work around "Found multiple rlibs for crate ...
[rust.git] / .github / workflows / clippy_bors.yml
1 name: Clippy Test (bors)
2
3 on:
4   push:
5     branches:
6       - auto
7       - try
8
9 env:
10   RUST_BACKTRACE: 1
11   CARGO_TARGET_DIR: '${{ github.workspace }}/target'
12   NO_FMT_TEST: 1
13
14 defaults:
15   run:
16     shell: bash
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.3.3
28       with:
29         ref: ${{ github.ref }}
30
31     # Run
32     - name: Check Changelog
33       run: |
34         MESSAGE=$(git log --format=%B -n 1)
35         PR=$(echo "$MESSAGE" | grep -o "#[0-9]*" | head -1 | sed -e 's/^#//')
36         output=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$PR" | \
37           python -c "import sys, json; print(json.load(sys.stdin)['body'])" | \
38           grep "^changelog: " | \
39           sed "s/changelog: //g")
40         if [[ -z "$output" ]]; then
41           echo "ERROR: PR body must contain 'changelog: ...'"
42           exit 1
43         elif [[ "$output" = "none" ]]; then
44           echo "WARNING: changelog is 'none'"
45         fi
46       env:
47         PYTHONIOENCODING: 'utf-8'
48   base:
49     needs: changelog
50     strategy:
51       matrix:
52         os: [ubuntu-latest, windows-latest, macos-latest]
53         host: [x86_64-unknown-linux-gnu, i686-unknown-linux-gnu, x86_64-apple-darwin, x86_64-pc-windows-msvc]
54         exclude:
55         - os: ubuntu-latest
56           host: x86_64-apple-darwin
57         - os: ubuntu-latest
58           host: x86_64-pc-windows-msvc
59         - os: macos-latest
60           host: x86_64-unknown-linux-gnu
61         - os: macos-latest
62           host: i686-unknown-linux-gnu
63         - os: macos-latest
64           host: x86_64-pc-windows-msvc
65         - os: windows-latest
66           host: x86_64-unknown-linux-gnu
67         - os: windows-latest
68           host: i686-unknown-linux-gnu
69         - os: windows-latest
70           host: x86_64-apple-darwin
71
72     runs-on: ${{ matrix.os }}
73
74     steps:
75     # Setup
76     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
77       with:
78         github_token: "${{ secrets.github_token }}"
79
80     - name: Install dependencies (Linux-i686)
81       run: |
82         sudo dpkg --add-architecture i386
83         sudo apt-get update
84         sudo apt-get install gcc-multilib libssl-dev:i386 libgit2-dev:i386
85       if: matrix.host == 'i686-unknown-linux-gnu'
86
87     - name: rust-toolchain
88       uses: actions-rs/toolchain@v1.0.6
89       with:
90         toolchain: nightly
91         target: ${{ matrix.host }}
92         profile: minimal
93
94     - name: Checkout
95       uses: actions/checkout@v2.3.3
96
97     - name: Run cargo update
98       run: cargo update
99
100     - name: Cache cargo dir
101       uses: actions/cache@v2
102       with:
103         path: ~/.cargo
104         key: ${{ runner.os }}-${{ matrix.host }}-${{ hashFiles('Cargo.lock') }}
105         restore-keys: |
106           ${{ runner.os }}-${{ matrix.host }}
107
108     - name: Master Toolchain Setup
109       run: bash setup-toolchain.sh
110       env:
111         HOST_TOOLCHAIN: ${{ matrix.host }}
112
113     # Run
114     - name: Set LD_LIBRARY_PATH (Linux)
115       if: runner.os == 'Linux'
116       run: |
117         SYSROOT=$(rustc --print sysroot)
118         echo "LD_LIBRARY_PATH=${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}" >> $GITHUB_ENV
119     - name: Link rustc dylib (MacOS)
120       if: runner.os == 'macOS'
121       run: |
122         SYSROOT=$(rustc --print sysroot)
123         sudo mkdir -p /usr/local/lib
124         sudo find "${SYSROOT}/lib" -maxdepth 1 -name '*dylib' -exec ln -s {} /usr/local/lib \;
125     - name: Set PATH (Windows)
126       if: runner.os == 'Windows'
127       run: |
128         SYSROOT=$(rustc --print sysroot)
129         echo "$SYSROOT/bin" >> $GITHUB_PATH
130
131     - name: Build
132       run: cargo build --features deny-warnings
133
134     # compiletest would panic due to "Found multiple rlibs for crate `clippy_lints`"
135     - name: clean rlibs
136       run: rm -f ./target/debug/deps/libclippy_lints*
137
138     - name: Build with internal lints
139       run: cargo build --features deny-warnings,internal-lints
140
141     - name: Test with internal lints
142       run: cargo test --features deny-warnings,internal-lints
143
144     - name: Test clippy_lints with internal lints
145       run: cargo test --features deny-warnings,internal-lints
146       working-directory: clippy_lints
147
148     - name: Test rustc_tools_util
149       run: cargo test --features deny-warnings
150       working-directory: rustc_tools_util
151
152     - name: Test clippy_dev
153       run: cargo test --features deny-warnings
154       working-directory: clippy_dev
155
156     - name: Test cargo-clippy
157       run: ../target/debug/cargo-clippy
158       working-directory: clippy_workspace_tests
159
160     - name: Test clippy-driver
161       run: bash .github/driver.sh
162       env:
163         OS: ${{ runner.os }}
164
165     # Cleanup
166     - name: Run cargo-cache --autoclean
167       run: |
168         cargo +nightly install cargo-cache --no-default-features --features ci-autoclean cargo-cache
169         cargo cache
170
171   integration_build:
172     needs: changelog
173     runs-on: ubuntu-latest
174
175     steps:
176     # Setup
177     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
178       with:
179         github_token: "${{ secrets.github_token }}"
180
181     - name: rust-toolchain
182       uses: actions-rs/toolchain@v1.0.6
183       with:
184         toolchain: nightly
185         target: x86_64-unknown-linux-gnu
186         profile: minimal
187
188     - name: Checkout
189       uses: actions/checkout@v2.3.3
190
191     - name: Run cargo update
192       run: cargo update
193
194     - name: Cache cargo dir
195       uses: actions/cache@v2
196       with:
197         path: ~/.cargo
198         key: ${{ runner.os }}-x86_64-unknown-linux-gnu-${{ hashFiles('Cargo.lock') }}
199         restore-keys: |
200           ${{ runner.os }}-x86_64-unknown-linux-gnu
201
202     - name: Master Toolchain Setup
203       run: bash setup-toolchain.sh
204
205     # Run
206     - name: Build Integration Test
207       run: cargo test --test integration --features integration --no-run
208
209     # Upload
210     - name: Extract Binaries
211       run: |
212         DIR=$CARGO_TARGET_DIR/debug
213         rm $DIR/deps/integration-*.d
214         mv $DIR/deps/integration-* $DIR/integration
215         find $DIR ! -executable -o -type d ! -path $DIR | xargs rm -rf
216         rm -rf $CARGO_TARGET_DIR/release
217
218     - name: Upload Binaries
219       uses: actions/upload-artifact@v1
220       with:
221         name: target
222         path: target
223
224     # Cleanup
225     - name: Run cargo-cache --autoclean
226       run: |
227         cargo +nightly install cargo-cache --no-default-features --features ci-autoclean cargo-cache
228         cargo cache
229   integration:
230     needs: integration_build
231     strategy:
232       fail-fast: false
233       max-parallel: 6
234       matrix:
235         integration:
236         - 'rust-lang/cargo'
237         # FIXME: re-enable once fmt_macros is renamed in RLS
238         # - 'rust-lang/rls'
239         - 'rust-lang/chalk'
240         - 'rust-lang/rustfmt'
241         - 'Marwes/combine'
242         - 'Geal/nom'
243         - 'rust-lang/stdarch'
244         - 'serde-rs/serde'
245         # FIXME: chrono currently cannot be compiled with `--all-targets`
246         # - 'chronotope/chrono'
247         - 'hyperium/hyper'
248         - 'rust-random/rand'
249         - 'rust-lang/futures-rs'
250         - 'rust-itertools/itertools'
251         - 'rust-lang-nursery/failure'
252         - 'rust-lang/log'
253
254     runs-on: ubuntu-latest
255
256     steps:
257     # Setup
258     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
259       with:
260         github_token: "${{ secrets.github_token }}"
261
262     - name: rust-toolchain
263       uses: actions-rs/toolchain@v1.0.6
264       with:
265         toolchain: nightly
266         target: x86_64-unknown-linux-gnu
267         profile: minimal
268
269     - name: Checkout
270       uses: actions/checkout@v2.3.3
271
272     - name: Run cargo update
273       run: cargo update
274
275     - name: Cache cargo dir
276       uses: actions/cache@v2
277       with:
278         path: ~/.cargo
279         key: ${{ runner.os }}-x86_64-unknown-linux-gnu-${{ hashFiles('Cargo.lock') }}
280         restore-keys: |
281           ${{ runner.os }}-x86_64-unknown-linux-gnu
282
283     - name: Master Toolchain Setup
284       run: bash setup-toolchain.sh
285
286     # Download
287     - name: Download target dir
288       uses: actions/download-artifact@v1
289       with:
290         name: target
291         path: target
292
293     - name: Make Binaries Executable
294       run: chmod +x $CARGO_TARGET_DIR/debug/*
295
296     # Run
297     - name: Test ${{ matrix.integration }}
298       run: $CARGO_TARGET_DIR/debug/integration
299       env:
300         INTEGRATION: ${{ matrix.integration }}
301         RUSTUP_TOOLCHAIN: master
302
303     # Cleanup
304     - name: Run cargo-cache --autoclean
305       run: |
306         cargo +nightly install cargo-cache --no-default-features --features ci-autoclean cargo-cache
307         cargo cache
308
309   # These jobs doesn't actually test anything, but they're only used to tell
310   # bors the build completed, as there is no practical way to detect when a
311   # workflow is successful listening to webhooks only.
312   #
313   # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
314
315   end-success:
316     name: bors test finished
317     if: github.event.pusher.name == 'bors' && success()
318     runs-on: ubuntu-latest
319     needs: [changelog, base, integration_build, integration]
320
321     steps:
322       - name: Mark the job as successful
323         run: exit 0
324
325   end-failure:
326     name: bors test finished
327     if: github.event.pusher.name == 'bors' && (failure() || cancelled())
328     runs-on: ubuntu-latest
329     needs: [changelog, base, integration_build, integration]
330
331     steps:
332       - name: Mark the job as a failure
333         run: exit 1