]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/.github/workflows/clippy_bors.yml
Auto merge of #79780 - camelid:use-summary_opts, r=GuillaumeGomez
[rust.git] / src / tools / clippy / .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 with internal lints
132       run: cargo build --features deny-warnings,internal-lints
133
134     - name: Test with internal lints
135       run: cargo test --features deny-warnings,internal-lints
136
137     - name: Test clippy_lints with internal lints
138       run: cargo test --features deny-warnings,internal-lints
139       working-directory: clippy_lints
140
141     - name: Test rustc_tools_util
142       run: cargo test --features deny-warnings
143       working-directory: rustc_tools_util
144
145     - name: Test clippy_dev
146       run: cargo test --features deny-warnings
147       working-directory: clippy_dev
148
149     - name: Test cargo-clippy
150       run: ../target/debug/cargo-clippy
151       working-directory: clippy_workspace_tests
152
153     - name: Test clippy-driver
154       run: bash .github/driver.sh
155       env:
156         OS: ${{ runner.os }}
157
158     # Cleanup
159     - name: Run cargo-cache --autoclean
160       run: |
161         cargo +nightly install cargo-cache --no-default-features --features ci-autoclean cargo-cache
162         cargo cache
163
164   integration_build:
165     needs: changelog
166     runs-on: ubuntu-latest
167
168     steps:
169     # Setup
170     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
171       with:
172         github_token: "${{ secrets.github_token }}"
173
174     - name: rust-toolchain
175       uses: actions-rs/toolchain@v1.0.6
176       with:
177         toolchain: nightly
178         target: x86_64-unknown-linux-gnu
179         profile: minimal
180
181     - name: Checkout
182       uses: actions/checkout@v2.3.3
183
184     - name: Run cargo update
185       run: cargo update
186
187     - name: Cache cargo dir
188       uses: actions/cache@v2
189       with:
190         path: ~/.cargo
191         key: ${{ runner.os }}-x86_64-unknown-linux-gnu-${{ hashFiles('Cargo.lock') }}
192         restore-keys: |
193           ${{ runner.os }}-x86_64-unknown-linux-gnu
194
195     - name: Master Toolchain Setup
196       run: bash setup-toolchain.sh
197
198     # Run
199     - name: Build Integration Test
200       run: cargo test --test integration --features integration --no-run
201
202     # Upload
203     - name: Extract Binaries
204       run: |
205         DIR=$CARGO_TARGET_DIR/debug
206         rm $DIR/deps/integration-*.d
207         mv $DIR/deps/integration-* $DIR/integration
208         find $DIR ! -executable -o -type d ! -path $DIR | xargs rm -rf
209         rm -rf $CARGO_TARGET_DIR/release
210
211     - name: Upload Binaries
212       uses: actions/upload-artifact@v1
213       with:
214         name: target
215         path: target
216
217     # Cleanup
218     - name: Run cargo-cache --autoclean
219       run: |
220         cargo +nightly install cargo-cache --no-default-features --features ci-autoclean cargo-cache
221         cargo cache
222   integration:
223     needs: integration_build
224     strategy:
225       fail-fast: false
226       max-parallel: 6
227       matrix:
228         integration:
229         - 'rust-lang/cargo'
230         # FIXME: re-enable once fmt_macros is renamed in RLS
231         # - 'rust-lang/rls'
232         - 'rust-lang/chalk'
233         - 'rust-lang/rustfmt'
234         - 'Marwes/combine'
235         - 'Geal/nom'
236         - 'rust-lang/stdarch'
237         - 'serde-rs/serde'
238         # FIXME: chrono currently cannot be compiled with `--all-targets`
239         # - 'chronotope/chrono'
240         - 'hyperium/hyper'
241         - 'rust-random/rand'
242         - 'rust-lang/futures-rs'
243         - 'rust-itertools/itertools'
244         - 'rust-lang-nursery/failure'
245         - 'rust-lang/log'
246
247     runs-on: ubuntu-latest
248
249     steps:
250     # Setup
251     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
252       with:
253         github_token: "${{ secrets.github_token }}"
254
255     - name: rust-toolchain
256       uses: actions-rs/toolchain@v1.0.6
257       with:
258         toolchain: nightly
259         target: x86_64-unknown-linux-gnu
260         profile: minimal
261
262     - name: Checkout
263       uses: actions/checkout@v2.3.3
264
265     - name: Run cargo update
266       run: cargo update
267
268     - name: Cache cargo dir
269       uses: actions/cache@v2
270       with:
271         path: ~/.cargo
272         key: ${{ runner.os }}-x86_64-unknown-linux-gnu-${{ hashFiles('Cargo.lock') }}
273         restore-keys: |
274           ${{ runner.os }}-x86_64-unknown-linux-gnu
275
276     - name: Master Toolchain Setup
277       run: bash setup-toolchain.sh
278
279     # Download
280     - name: Download target dir
281       uses: actions/download-artifact@v1
282       with:
283         name: target
284         path: target
285
286     - name: Make Binaries Executable
287       run: chmod +x $CARGO_TARGET_DIR/debug/*
288
289     # Run
290     - name: Test ${{ matrix.integration }}
291       run: $CARGO_TARGET_DIR/debug/integration
292       env:
293         INTEGRATION: ${{ matrix.integration }}
294         RUSTUP_TOOLCHAIN: master
295
296     # Cleanup
297     - name: Run cargo-cache --autoclean
298       run: |
299         cargo +nightly install cargo-cache --no-default-features --features ci-autoclean cargo-cache
300         cargo cache
301
302   # These jobs doesn't actually test anything, but they're only used to tell
303   # bors the build completed, as there is no practical way to detect when a
304   # workflow is successful listening to webhooks only.
305   #
306   # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
307
308   end-success:
309     name: bors test finished
310     if: github.event.pusher.name == 'bors' && success()
311     runs-on: ubuntu-latest
312     needs: [changelog, base, integration_build, integration]
313
314     steps:
315       - name: Mark the job as successful
316         run: exit 0
317
318   end-failure:
319     name: bors test finished
320     if: github.event.pusher.name == 'bors' && (failure() || cancelled())
321     runs-on: ubuntu-latest
322     needs: [changelog, base, integration_build, integration]
323
324     steps:
325       - name: Mark the job as a failure
326         run: exit 1