]> git.lizzy.rs Git - rust.git/blob - .github/workflows/clippy_bors.yml
Merge commit '9e3cd88718cd1912a515d26dbd9c4019fd5a9577' into clippyup
[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
27     - name: Checkout
28       uses: actions/checkout@v2.3.3
29       with:
30         ref: ${{ github.ref }}
31
32     # Run
33     - name: Check Changelog
34       run: |
35         MESSAGE=$(git log --format=%B -n 1)
36         PR=$(echo "$MESSAGE" | grep -o "#[0-9]*" | head -1 | sed -e 's/^#//')
37         body=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$PR" | \
38           python -c "import sys, json; print(json.load(sys.stdin)['body'])")
39         output=$(grep "^changelog:\s*\S" <<< "$body" | sed "s/changelog:\s*//g") || {
40           echo "ERROR: PR body must contain 'changelog: ...'"
41           exit 1
42         }
43         if [[ "$output" = "none" ]]; then
44           echo "WARNING: changelog is 'none'"
45         else
46           echo "changelog: $output"
47         fi
48       env:
49         PYTHONIOENCODING: 'utf-8'
50   base:
51     needs: changelog
52     strategy:
53       matrix:
54         os: [ubuntu-latest, windows-latest, macos-latest]
55         host: [x86_64-unknown-linux-gnu, i686-unknown-linux-gnu, x86_64-apple-darwin, x86_64-pc-windows-msvc]
56         exclude:
57         - os: ubuntu-latest
58           host: x86_64-apple-darwin
59         - os: ubuntu-latest
60           host: x86_64-pc-windows-msvc
61         - os: macos-latest
62           host: x86_64-unknown-linux-gnu
63         - os: macos-latest
64           host: i686-unknown-linux-gnu
65         - os: macos-latest
66           host: x86_64-pc-windows-msvc
67         - os: windows-latest
68           host: x86_64-unknown-linux-gnu
69         - os: windows-latest
70           host: i686-unknown-linux-gnu
71         - os: windows-latest
72           host: x86_64-apple-darwin
73
74     runs-on: ${{ matrix.os }}
75
76     # NOTE: If you modify this job, make sure you copy the changes to clippy.yml
77     steps:
78     # Setup
79     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
80       with:
81         github_token: "${{ secrets.github_token }}"
82
83     - name: Install dependencies (Linux-i686)
84       run: |
85         sudo dpkg --add-architecture i386
86         sudo apt-get update
87         sudo apt-get install gcc-multilib libssl-dev:i386 libgit2-dev:i386
88       if: matrix.host == 'i686-unknown-linux-gnu'
89
90     - name: Checkout
91       uses: actions/checkout@v2.3.3
92
93     # FIXME: should not be necessary once 1.24.2 is the default version on the windows runner
94     - name: Update rustup
95       run: rustup self update
96       if: runner.os == 'Windows'
97
98     - name: Install toolchain
99       run: rustup show active-toolchain
100
101     # Run
102     - name: Set LD_LIBRARY_PATH (Linux)
103       if: runner.os == 'Linux'
104       run: |
105         SYSROOT=$(rustc --print sysroot)
106         echo "LD_LIBRARY_PATH=${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}" >> $GITHUB_ENV
107     - name: Link rustc dylib (MacOS)
108       if: runner.os == 'macOS'
109       run: |
110         SYSROOT=$(rustc --print sysroot)
111         sudo mkdir -p /usr/local/lib
112         sudo find "${SYSROOT}/lib" -maxdepth 1 -name '*dylib' -exec ln -s {} /usr/local/lib \;
113     - name: Set PATH (Windows)
114       if: runner.os == 'Windows'
115       run: |
116         SYSROOT=$(rustc --print sysroot)
117         echo "$SYSROOT/bin" >> $GITHUB_PATH
118
119     - name: Build
120       run: cargo build --features deny-warnings,internal-lints
121
122     - name: Test
123       run: cargo test --features deny-warnings,internal-lints
124
125     - name: Test clippy_lints
126       run: cargo test --features deny-warnings,internal-lints
127       working-directory: clippy_lints
128
129     - name: Test rustc_tools_util
130       run: cargo test --features deny-warnings
131       working-directory: rustc_tools_util
132
133     - name: Test clippy_dev
134       run: cargo test --features deny-warnings
135       working-directory: clippy_dev
136
137     - name: Test cargo-clippy
138       run: ../target/debug/cargo-clippy
139       working-directory: clippy_workspace_tests
140
141     - name: Test cargo-clippy --fix
142       run: ../target/debug/cargo-clippy clippy --fix -Zunstable-options
143       working-directory: clippy_workspace_tests
144
145     - name: Test clippy-driver
146       run: bash .github/driver.sh
147       env:
148         OS: ${{ runner.os }}
149
150     - name: Test cargo dev new lint
151       run: |
152         cargo dev new_lint --name new_early_pass --pass early
153         cargo dev new_lint --name new_late_pass --pass late
154         cargo check
155         git reset --hard HEAD
156
157   integration_build:
158     needs: changelog
159     runs-on: ubuntu-latest
160
161     steps:
162     # Setup
163     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
164       with:
165         github_token: "${{ secrets.github_token }}"
166
167     - name: Checkout
168       uses: actions/checkout@v2.3.3
169
170     - name: Install toolchain
171       run: rustup show active-toolchain
172
173     # Run
174     - name: Build Integration Test
175       run: cargo test --test integration --features integration --no-run
176
177     # Upload
178     - name: Extract Binaries
179       run: |
180         DIR=$CARGO_TARGET_DIR/debug
181         rm $DIR/deps/integration-*.d
182         mv $DIR/deps/integration-* $DIR/integration
183         find $DIR ! -executable -o -type d ! -path $DIR | xargs rm -rf
184         rm -rf $CARGO_TARGET_DIR/release
185
186     - name: Upload Binaries
187       uses: actions/upload-artifact@v1
188       with:
189         name: target
190         path: target
191
192   integration:
193     needs: integration_build
194     strategy:
195       fail-fast: false
196       max-parallel: 6
197       matrix:
198         integration:
199         - 'rust-lang/cargo'
200         # FIXME: re-enable once fmt_macros is renamed in RLS
201         # - 'rust-lang/rls'
202         - 'rust-lang/chalk'
203         - 'rust-lang/rustfmt'
204         - 'Marwes/combine'
205         - 'Geal/nom'
206         - 'rust-lang/stdarch'
207         - 'serde-rs/serde'
208         # FIXME: chrono currently cannot be compiled with `--all-targets`
209         # - 'chronotope/chrono'
210         - 'hyperium/hyper'
211         - 'rust-random/rand'
212         - 'rust-lang/futures-rs'
213         - 'rust-itertools/itertools'
214         - 'rust-lang-nursery/failure'
215         - 'rust-lang/log'
216
217     runs-on: ubuntu-latest
218
219     steps:
220     # Setup
221     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
222       with:
223         github_token: "${{ secrets.github_token }}"
224
225     - name: Checkout
226       uses: actions/checkout@v2.3.3
227
228     - name: Install toolchain
229       run: rustup show active-toolchain
230
231     # Download
232     - name: Download target dir
233       uses: actions/download-artifact@v1
234       with:
235         name: target
236         path: target
237
238     - name: Make Binaries Executable
239       run: chmod +x $CARGO_TARGET_DIR/debug/*
240
241     # Run
242     - name: Test ${{ matrix.integration }}
243       run: |
244         RUSTUP_TOOLCHAIN="$(rustup show active-toolchain | grep -o -E "nightly-[0-9]{4}-[0-9]{2}-[0-9]{2}")" \
245           $CARGO_TARGET_DIR/debug/integration
246       env:
247         INTEGRATION: ${{ matrix.integration }}
248
249   # These jobs doesn't actually test anything, but they're only used to tell
250   # bors the build completed, as there is no practical way to detect when a
251   # workflow is successful listening to webhooks only.
252   #
253   # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
254
255   end-success:
256     name: bors test finished
257     if: github.event.pusher.name == 'bors' && success()
258     runs-on: ubuntu-latest
259     needs: [changelog, base, integration_build, integration]
260
261     steps:
262       - name: Mark the job as successful
263         run: exit 0
264
265   end-failure:
266     name: bors test finished
267     if: github.event.pusher.name == 'bors' && (failure() || cancelled())
268     runs-on: ubuntu-latest
269     needs: [changelog, base, integration_build, integration]
270
271     steps:
272       - name: Mark the job as a failure
273         run: exit 1