]> git.lizzy.rs Git - rust.git/blob - .github/workflows/clippy_bors.yml
Auto merge of #5479 - matthiaskrgr:readme_auto_fix, r=flip1995
[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 jobs:
15   changelog:
16     runs-on: ubuntu-latest
17
18     steps:
19     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
20       with:
21         github_token: "${{ secrets.github_token }}"
22     - name: Checkout
23       uses: actions/checkout@v2.0.0
24       with:
25         ref: ${{ github.ref }}
26
27     # Run
28     - name: Check Changelog
29       run: |
30         MESSAGE=$(git log --format=%B -n 1)
31         PR=$(echo "$MESSAGE" | grep -o "#[0-9]*" | head -1 | sed -e 's/^#//')
32         output=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$PR" | \
33           python -c "import sys, json; print(json.load(sys.stdin)['body'])" | \
34           grep "^changelog: " | \
35           sed "s/changelog: //g")
36         if [[ -z "$output" ]]; then
37           echo "ERROR: PR body must contain 'changelog: ...'"
38           exit 1
39         elif [[ "$output" = "none" ]]; then
40           echo "WARNING: changelog is 'none'"
41         fi
42       env:
43         PYTHONIOENCODING: 'utf-8'
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     # Setup
72     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
73       with:
74         github_token: "${{ secrets.github_token }}"
75
76     - name: Install dependencies (Linux-i686)
77       run: |
78         sudo dpkg --add-architecture i386
79         sudo apt-get update
80         # perform system upgrade to work around https://github.com/rust-lang/rust-clippy/issues/5477 , revert as soon as that is fixed
81         sudo apt-get -y upgrade
82         sudo apt-get install gcc-multilib libssl-dev:i386 libgit2-dev:i386
83       if: matrix.host == 'i686-unknown-linux-gnu'
84
85     - name: rust-toolchain
86       uses: actions-rs/toolchain@v1.0.3
87       with:
88         toolchain: nightly
89         target: ${{ matrix.host }}
90         profile: minimal
91
92     - name: Checkout
93       uses: actions/checkout@v2.0.0
94
95     - name: Run cargo update
96       run: cargo update
97
98     - name: Cache cargo dir
99       uses: actions/cache@v1
100       with:
101         path: ~/.cargo
102         key: ${{ runner.os }}-${{ matrix.host }}-${{ hashFiles('Cargo.lock') }}
103         restore-keys: |
104           ${{ runner.os }}-${{ matrix.host }}
105
106     - name: Master Toolchain Setup
107       run: bash setup-toolchain.sh
108       env:
109         HOST_TOOLCHAIN: ${{ matrix.host }}
110       shell: bash
111
112     # Run
113     - name: Set LD_LIBRARY_PATH (Linux)
114       if: runner.os == 'Linux'
115       run: |
116         SYSROOT=$(rustc --print sysroot)
117         echo "::set-env name=LD_LIBRARY_PATH::${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}"
118     - name: Link rustc dylib (MacOS)
119       if: runner.os == 'macOS'
120       run: |
121         SYSROOT=$(rustc --print sysroot)
122         sudo mkdir -p /usr/local/lib
123         sudo find "${SYSROOT}/lib" -maxdepth 1 -name '*dylib' -exec ln -s {} /usr/local/lib \;
124     - name: Set PATH (Windows)
125       if: runner.os == 'Windows'
126       run: |
127         $sysroot = rustc --print sysroot
128         $env:PATH += ';' + $sysroot + '\bin'
129         echo "::set-env name=PATH::$env:PATH"
130
131     - name: Build
132       run: cargo build --features deny-warnings
133       shell: bash
134
135     - name: Test
136       run: cargo test --features deny-warnings
137       shell: bash
138
139     - name: Test clippy_lints
140       run: cargo test --features deny-warnings
141       shell: bash
142       working-directory: clippy_lints
143
144     - name: Test rustc_tools_util
145       run: cargo test --features deny-warnings
146       shell: bash
147       working-directory: rustc_tools_util
148
149     - name: Test clippy_dev
150       run: cargo test --features deny-warnings
151       shell: bash
152       working-directory: clippy_dev
153
154     - name: Test cargo-clippy
155       run: ../target/debug/cargo-clippy
156       shell: bash
157       working-directory: clippy_workspace_tests
158
159     - name: Test clippy-driver
160       run: bash .github/driver.sh
161       shell: bash
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       shell: bash
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.3
183       with:
184         toolchain: nightly
185         target: x86_64-unknown-linux-gnu
186         profile: minimal
187
188     - name: Checkout
189       uses: actions/checkout@v2.0.0
190
191     - name: Run cargo update
192       run: cargo update
193
194     - name: Cache cargo dir
195       uses: actions/cache@v1
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         - 'rust-lang/rls'
238         - 'rust-lang/chalk'
239         - 'rust-lang/rustfmt'
240         - 'Marwes/combine'
241         - 'Geal/nom'
242         - 'rust-lang/stdarch'
243         - 'serde-rs/serde'
244         - 'chronotope/chrono'
245         - 'hyperium/hyper'
246         - 'rust-random/rand'
247         - 'rust-lang/futures-rs'
248         - 'rust-itertools/itertools'
249         - 'rust-lang-nursery/failure'
250         - 'rust-lang/log'
251
252     runs-on: ubuntu-latest
253
254     steps:
255     # Setup
256     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
257       with:
258         github_token: "${{ secrets.github_token }}"
259
260     - name: rust-toolchain
261       uses: actions-rs/toolchain@v1.0.3
262       with:
263         toolchain: nightly
264         target: x86_64-unknown-linux-gnu
265         profile: minimal
266
267     - name: Checkout
268       uses: actions/checkout@v2.0.0
269
270     - name: Run cargo update
271       run: cargo update
272
273     - name: Cache cargo dir
274       uses: actions/cache@v1
275       with:
276         path: ~/.cargo
277         key: ${{ runner.os }}-x86_64-unknown-linux-gnu-${{ hashFiles('Cargo.lock') }}
278         restore-keys: |
279           ${{ runner.os }}-x86_64-unknown-linux-gnu
280
281     - name: Master Toolchain Setup
282       run: bash setup-toolchain.sh
283
284     # Download
285     - name: Download target dir
286       uses: actions/download-artifact@v1
287       with:
288         name: target
289         path: target
290
291     - name: Make Binaries Executable
292       run: chmod +x $CARGO_TARGET_DIR/debug/*
293
294     # Run
295     - name: Test ${{ matrix.integration }}
296       run: $CARGO_TARGET_DIR/debug/integration
297       env:
298         INTEGRATION: ${{ matrix.integration }}
299         RUSTUP_TOOLCHAIN: master
300
301     # Cleanup
302     - name: Run cargo-cache --autoclean
303       run: |
304         cargo +nightly install cargo-cache --no-default-features --features ci-autoclean cargo-cache
305         cargo cache
306
307   # These jobs doesn't actually test anything, but they're only used to tell
308   # bors the build completed, as there is no practical way to detect when a
309   # workflow is successful listening to webhooks only.
310   #
311   # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
312
313   end-success:
314     name: bors test finished
315     if: github.event.pusher.name == 'bors' && success()
316     runs-on: ubuntu-latest
317     needs: [base, integration]
318
319     steps:
320       - name: Mark the job as successful
321         run: exit 0
322
323   end-failure:
324     name: bors test finished
325     if: github.event.pusher.name == 'bors' && (failure() || cancelled())
326     runs-on: ubuntu-latest
327     needs: [base, integration]
328
329     steps:
330       - name: Mark the job as a failure
331         run: exit 1