]> git.lizzy.rs Git - rust.git/blob - .github/workflows/clippy_bors.yml
b1b207416a1ec90b60c7ea233d40ea147905fa8f
[rust.git] / .github / workflows / clippy_bors.yml
1 name: Clippy Test (bors)
2
3 on:
4   push:
5     branches: [auto, try]
6
7 env:
8   RUST_BACKTRACE: 1
9   CARGO_TARGET_DIR: '${{ github.workspace }}/target'
10   GHA_CI: 1
11
12 jobs:
13   changelog:
14     runs-on: ubuntu-latest
15
16     steps:
17     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
18       with:
19         github_token: "${{ secrets.github_token }}"
20     - name: Checkout
21       uses: actions/checkout@v2.0.0
22       with:
23         ref: ${{ github.ref }}
24     - name: Check Changelog
25       run: |
26         MESSAGE=$(git log --format=%B -n 1)
27         PR=$(echo "$MESSAGE" | grep -o "#[0-9]*" | head -1 | sed -e 's/^#//')
28         output=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$PR" | \
29           python -c "import sys, json; print(json.load(sys.stdin)['body'])" | \
30           grep "^changelog: " | \
31           sed "s/changelog: //g")
32         if [[ -z "$output" ]]; then
33           echo "ERROR: PR body must contain 'changelog: ...'"
34           exit 1
35         elif [[ "$output" = "none" ]]; then
36           echo "WARNING: changelog is 'none'"
37         fi
38       env:
39         PYTHONIOENCODING: 'utf-8'
40   base:
41     needs: changelog
42     strategy:
43       matrix:
44         os: [ubuntu-latest, windows-latest, macos-latest]
45         host: [x86_64-unknown-linux-gnu, i686-unknown-linux-gnu, x86_64-apple-darwin, x86_64-pc-windows-msvc]
46         exclude:
47         - os: ubuntu-latest
48           host: x86_64-apple-darwin
49         - os: ubuntu-latest
50           host: x86_64-pc-windows-msvc
51         - os: macos-latest
52           host: x86_64-unknown-linux-gnu
53         - os: macos-latest
54           host: i686-unknown-linux-gnu
55         - os: macos-latest
56           host: x86_64-pc-windows-msvc
57         - os: windows-latest
58           host: x86_64-unknown-linux-gnu
59         - os: windows-latest
60           host: i686-unknown-linux-gnu
61         - os: windows-latest
62           host: x86_64-apple-darwin
63
64     runs-on: ${{ matrix.os }}
65
66     steps:
67     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
68       with:
69         github_token: "${{ secrets.github_token }}"
70     - name: Install dependencies (Linux-i686)
71       run: |
72         sudo dpkg --add-architecture i386
73         sudo apt-get update
74         sudo apt-get install gcc-multilib libssl-dev:i386 libgit2-dev:i386
75       if: matrix.host == 'i686-unknown-linux-gnu'
76     - name: rust-toolchain
77       uses: actions-rs/toolchain@v1.0.3
78       with:
79         toolchain: nightly
80         target: ${{ matrix.host }}
81         profile: minimal
82     - name: Checkout
83       uses: actions/checkout@v2.0.0
84     - name: Run cargo update
85       run: cargo update
86     - name: Cache cargo dir
87       uses: actions/cache@v1
88       with:
89         path: ~/.cargo
90         key: ${{ runner.os }}-${{ matrix.host }}-${{ hashFiles('Cargo.lock') }}
91         restore-keys: |
92           ${{ runner.os }}-${{ matrix.host }}
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: bash .github/driver.sh
140       shell: bash
141       env:
142         OS: ${{ runner.os }}
143
144     - name: Run cargo-cache --autoclean
145       run: |
146         cargo install cargo-cache --debug
147         /usr/bin/find ~/.cargo/bin ! -type d -exec strip {} \;
148         cargo cache --autoclean
149       shell: bash
150   integration_build:
151     needs: changelog
152     runs-on: ubuntu-latest
153
154     steps:
155     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
156       with:
157         github_token: "${{ secrets.github_token }}"
158     - name: rust-toolchain
159       uses: actions-rs/toolchain@v1.0.3
160       with:
161         toolchain: nightly
162         target: x86_64-unknown-linux-gnu
163         profile: minimal
164     - name: Checkout
165       uses: actions/checkout@v2.0.0
166     - name: Run cargo update
167       run: cargo update
168     - name: Cache cargo dir
169       uses: actions/cache@v1
170       with:
171         path: ~/.cargo
172         key: ${{ runner.os }}-x86_64-unknown-linux-gnu-${{ hashFiles('Cargo.lock') }}
173         restore-keys: |
174           ${{ runner.os }}-x86_64-unknown-linux-gnu
175     - name: Master Toolchain Setup
176       run: bash setup-toolchain.sh
177
178     - name: Build Integration Test
179       run: cargo test --test integration --features integration --no-run
180     - name: Extract Binaries
181       run: |
182         DIR=$CARGO_TARGET_DIR/debug
183         find $DIR ! -executable -o -type d ! -path $DIR | xargs rm -rf
184         mv $DIR/integration-* $DIR/integration
185     - name: Upload Binaries
186       uses: actions/upload-artifact@v1
187       with:
188         name: target
189         path: target
190
191     - name: Run cargo-cache --autoclean
192       run: |
193         cargo install cargo-cache --debug
194         find ~/.cargo/bin ! -type d -exec strip {} \;
195         cargo cache --autoclean
196   integration:
197     needs: integration_build
198     strategy:
199       fail-fast: false
200       max-parallel: 6
201       matrix:
202         integration:
203         - 'rust-lang/cargo'
204         - 'rust-lang/rls'
205         - 'rust-lang/chalk'
206         - 'rust-lang/rustfmt'
207         - 'Marwes/combine'
208         - 'Geal/nom'
209         - 'rust-lang/stdarch'
210         - 'serde-rs/serde'
211         - 'chronotope/chrono'
212         - 'hyperium/hyper'
213         - 'rust-random/rand'
214         - 'rust-lang/futures-rs'
215         - 'rust-itertools/itertools'
216         - 'rust-lang-nursery/failure'
217         - 'rust-lang/log'
218
219     runs-on: ubuntu-latest
220
221     steps:
222     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
223       with:
224         github_token: "${{ secrets.github_token }}"
225     - name: rust-toolchain
226       uses: actions-rs/toolchain@v1.0.3
227       with:
228         toolchain: nightly
229         target: x86_64-unknown-linux-gnu
230         profile: minimal
231     - name: Checkout
232       uses: actions/checkout@v2.0.0
233     - name: Run cargo update
234       run: cargo update
235     - name: Cache cargo dir
236       uses: actions/cache@v1
237       with:
238         path: ~/.cargo
239         key: ${{ runner.os }}-x86_64-unknown-linux-gnu-${{ hashFiles('Cargo.lock') }}
240         restore-keys: |
241           ${{ runner.os }}-x86_64-unknown-linux-gnu
242     - name: Master Toolchain Setup
243       run: bash setup-toolchain.sh
244
245     - name: Download target dir
246       uses: actions/download-artifact@v1
247       with:
248         name: target
249         path: target
250     - name: Make Binaries Executable
251       run: chmod +x $CARGO_TARGET_DIR/debug/*
252     - name: Test ${{ matrix.integration }}
253       run: $CARGO_TARGET_DIR/debug/integration
254       env:
255         INTEGRATION: ${{ matrix.integration }}
256         RUSTUP_TOOLCHAIN: master
257
258     - name: Run cargo-cache --autoclean
259       run: |
260         cargo install cargo-cache --debug
261         find ~/.cargo/bin ! -type d -exec strip {} \;
262         cargo cache --autoclean
263
264   # These jobs doesn't actually test anything, but they're only used to tell
265   # bors the build completed, as there is no practical way to detect when a
266   # workflow is successful listening to webhooks only.
267   #
268   # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
269
270   end-success:
271     name: bors test finished
272     if: github.event.pusher.name == 'bors' && success()
273     runs-on: ubuntu-latest
274     needs: [base, integration]
275
276     steps:
277       - name: Mark the job as successful
278         run: exit 0
279
280   end-failure:
281     name: bors test finished
282     if: github.event.pusher.name == 'bors' && (failure() || cancelled())
283     runs-on: ubuntu-latest
284     needs: [base, integration]
285
286     steps:
287       - name: Mark the job as a failure
288         run: exit 1