]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/.github/workflows/clippy_bors.yml
Rollup merge of #73036 - alexcrichton:update-wasm-fence, r=Mark-Simulacrum
[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 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         sudo apt-get install gcc-multilib libssl-dev:i386 libgit2-dev:i386
81       if: matrix.host == 'i686-unknown-linux-gnu'
82
83     - name: rust-toolchain
84       uses: actions-rs/toolchain@v1.0.3
85       with:
86         toolchain: nightly
87         target: ${{ matrix.host }}
88         profile: minimal
89
90     - name: Checkout
91       uses: actions/checkout@v2.0.0
92
93     - name: Run cargo update
94       run: cargo update
95
96     - name: Cache cargo dir
97       uses: actions/cache@v2
98       with:
99         path: ~/.cargo
100         key: ${{ runner.os }}-${{ matrix.host }}-${{ hashFiles('Cargo.lock') }}
101         restore-keys: |
102           ${{ runner.os }}-${{ matrix.host }}
103
104     - name: Master Toolchain Setup
105       run: bash setup-toolchain.sh
106       env:
107         HOST_TOOLCHAIN: ${{ matrix.host }}
108       shell: bash
109
110     # Run
111     - name: Set LD_LIBRARY_PATH (Linux)
112       if: runner.os == 'Linux'
113       run: |
114         SYSROOT=$(rustc --print sysroot)
115         echo "::set-env name=LD_LIBRARY_PATH::${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}"
116     - name: Link rustc dylib (MacOS)
117       if: runner.os == 'macOS'
118       run: |
119         SYSROOT=$(rustc --print sysroot)
120         sudo mkdir -p /usr/local/lib
121         sudo find "${SYSROOT}/lib" -maxdepth 1 -name '*dylib' -exec ln -s {} /usr/local/lib \;
122     - name: Set PATH (Windows)
123       if: runner.os == 'Windows'
124       run: |
125         $sysroot = rustc --print sysroot
126         $env:PATH += ';' + $sysroot + '\bin'
127         echo "::set-env name=PATH::$env:PATH"
128
129     - name: Build
130       run: cargo build --features deny-warnings
131       shell: bash
132
133     - name: Test
134       run: cargo test --features deny-warnings
135       shell: bash
136
137     - name: Test clippy_lints
138       run: cargo test --features deny-warnings
139       shell: bash
140       working-directory: clippy_lints
141
142     - name: Test rustc_tools_util
143       run: cargo test --features deny-warnings
144       shell: bash
145       working-directory: rustc_tools_util
146
147     - name: Test clippy_dev
148       run: cargo test --features deny-warnings
149       shell: bash
150       working-directory: clippy_dev
151
152     - name: Test cargo-clippy
153       run: ../target/debug/cargo-clippy
154       shell: bash
155       working-directory: clippy_workspace_tests
156
157     - name: Test clippy-driver
158       run: bash .github/driver.sh
159       shell: bash
160       env:
161         OS: ${{ runner.os }}
162
163     # Cleanup
164     - name: Run cargo-cache --autoclean
165       run: |
166         cargo +nightly install cargo-cache --no-default-features --features ci-autoclean cargo-cache
167         cargo cache
168       shell: bash
169   integration_build:
170     needs: changelog
171     runs-on: ubuntu-latest
172
173     steps:
174     # Setup
175     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
176       with:
177         github_token: "${{ secrets.github_token }}"
178
179     - name: rust-toolchain
180       uses: actions-rs/toolchain@v1.0.3
181       with:
182         toolchain: nightly
183         target: x86_64-unknown-linux-gnu
184         profile: minimal
185
186     - name: Checkout
187       uses: actions/checkout@v2.0.0
188
189     - name: Run cargo update
190       run: cargo update
191
192     - name: Cache cargo dir
193       uses: actions/cache@v2
194       with:
195         path: ~/.cargo
196         key: ${{ runner.os }}-x86_64-unknown-linux-gnu-${{ hashFiles('Cargo.lock') }}
197         restore-keys: |
198           ${{ runner.os }}-x86_64-unknown-linux-gnu
199
200     - name: Master Toolchain Setup
201       run: bash setup-toolchain.sh
202
203     # Run
204     - name: Build Integration Test
205       run: cargo test --test integration --features integration --no-run
206
207     # Upload
208     - name: Extract Binaries
209       run: |
210         DIR=$CARGO_TARGET_DIR/debug
211         rm $DIR/deps/integration-*.d
212         mv $DIR/deps/integration-* $DIR/integration
213         find $DIR ! -executable -o -type d ! -path $DIR | xargs rm -rf
214         rm -rf $CARGO_TARGET_DIR/release
215
216     - name: Upload Binaries
217       uses: actions/upload-artifact@v1
218       with:
219         name: target
220         path: target
221
222     # Cleanup
223     - name: Run cargo-cache --autoclean
224       run: |
225         cargo +nightly install cargo-cache --no-default-features --features ci-autoclean cargo-cache
226         cargo cache
227   integration:
228     needs: integration_build
229     strategy:
230       fail-fast: false
231       max-parallel: 6
232       matrix:
233         integration:
234         - 'rust-lang/cargo'
235         # FIXME: re-enable once fmt_macros is renamed in RLS
236         # - 'rust-lang/rls'
237         - 'rust-lang/chalk'
238         - 'rust-lang/rustfmt'
239         - 'Marwes/combine'
240         - 'Geal/nom'
241         - 'rust-lang/stdarch'
242         - 'serde-rs/serde'
243         - 'chronotope/chrono'
244         - 'hyperium/hyper'
245         - 'rust-random/rand'
246         - 'rust-lang/futures-rs'
247         - 'rust-itertools/itertools'
248         - 'rust-lang-nursery/failure'
249         - 'rust-lang/log'
250
251     runs-on: ubuntu-latest
252
253     steps:
254     # Setup
255     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
256       with:
257         github_token: "${{ secrets.github_token }}"
258
259     - name: rust-toolchain
260       uses: actions-rs/toolchain@v1.0.3
261       with:
262         toolchain: nightly
263         target: x86_64-unknown-linux-gnu
264         profile: minimal
265
266     - name: Checkout
267       uses: actions/checkout@v2.0.0
268
269     - name: Run cargo update
270       run: cargo update
271
272     - name: Cache cargo dir
273       uses: actions/cache@v2
274       with:
275         path: ~/.cargo
276         key: ${{ runner.os }}-x86_64-unknown-linux-gnu-${{ hashFiles('Cargo.lock') }}
277         restore-keys: |
278           ${{ runner.os }}-x86_64-unknown-linux-gnu
279
280     - name: Master Toolchain Setup
281       run: bash setup-toolchain.sh
282
283     # Download
284     - name: Download target dir
285       uses: actions/download-artifact@v1
286       with:
287         name: target
288         path: target
289
290     - name: Make Binaries Executable
291       run: chmod +x $CARGO_TARGET_DIR/debug/*
292
293     # Run
294     - name: Test ${{ matrix.integration }}
295       run: $CARGO_TARGET_DIR/debug/integration
296       env:
297         INTEGRATION: ${{ matrix.integration }}
298         RUSTUP_TOOLCHAIN: master
299
300     # Cleanup
301     - name: Run cargo-cache --autoclean
302       run: |
303         cargo +nightly install cargo-cache --no-default-features --features ci-autoclean cargo-cache
304         cargo cache
305
306   # These jobs doesn't actually test anything, but they're only used to tell
307   # bors the build completed, as there is no practical way to detect when a
308   # workflow is successful listening to webhooks only.
309   #
310   # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
311
312   end-success:
313     name: bors test finished
314     if: github.event.pusher.name == 'bors' && success()
315     runs-on: ubuntu-latest
316     needs: [changelog, base, integration_build, integration]
317
318     steps:
319       - name: Mark the job as successful
320         run: exit 0
321
322   end-failure:
323     name: bors test finished
324     if: github.event.pusher.name == 'bors' && (failure() || cancelled())
325     runs-on: ubuntu-latest
326     needs: [changelog, base, integration_build, integration]
327
328     steps:
329       - name: Mark the job as a failure
330         run: exit 1