]> git.lizzy.rs Git - rust.git/blob - .github/workflows/clippy_bors.yml
Merge commit '0eff589afc83e21a03a168497bbab6b4dfbb4ef6' 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     - name: Install toolchain
94       run: rustup show active-toolchain
95
96     # Run
97     - name: Set LD_LIBRARY_PATH (Linux)
98       if: runner.os == 'Linux'
99       run: |
100         SYSROOT=$(rustc --print sysroot)
101         echo "LD_LIBRARY_PATH=${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}" >> $GITHUB_ENV
102     - name: Link rustc dylib (MacOS)
103       if: runner.os == 'macOS'
104       run: |
105         SYSROOT=$(rustc --print sysroot)
106         sudo mkdir -p /usr/local/lib
107         sudo find "${SYSROOT}/lib" -maxdepth 1 -name '*dylib' -exec ln -s {} /usr/local/lib \;
108     - name: Set PATH (Windows)
109       if: runner.os == 'Windows'
110       run: |
111         SYSROOT=$(rustc --print sysroot)
112         echo "$SYSROOT/bin" >> $GITHUB_PATH
113
114     - name: Build
115       run: cargo build --features deny-warnings,internal-lints,metadata-collector-lint
116
117     - name: Test
118       run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
119
120     - name: Test clippy_lints
121       run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
122       working-directory: clippy_lints
123
124     - name: Test clippy_utils
125       run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
126       working-directory: clippy_utils
127
128     - name: Test rustc_tools_util
129       run: cargo test --features deny-warnings
130       working-directory: rustc_tools_util
131
132     - name: Test clippy_dev
133       run: cargo test --features deny-warnings
134       working-directory: clippy_dev
135
136     - name: Test cargo-clippy
137       run: ../target/debug/cargo-clippy
138       working-directory: clippy_workspace_tests
139
140     - name: Test cargo-clippy --fix
141       run: ../target/debug/cargo-clippy clippy --fix
142       working-directory: clippy_workspace_tests
143
144     - name: Test clippy-driver
145       run: bash .github/driver.sh
146       env:
147         OS: ${{ runner.os }}
148
149     - name: Test cargo dev new lint
150       run: |
151         cargo dev new_lint --name new_early_pass --pass early
152         cargo dev new_lint --name new_late_pass --pass late
153         cargo check
154         git reset --hard HEAD
155
156   integration_build:
157     needs: changelog
158     runs-on: ubuntu-latest
159
160     steps:
161     # Setup
162     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
163       with:
164         github_token: "${{ secrets.github_token }}"
165
166     - name: Checkout
167       uses: actions/checkout@v2.3.3
168
169     - name: Install toolchain
170       run: rustup show active-toolchain
171
172     # Run
173     - name: Build Integration Test
174       run: cargo test --test integration --features integration --no-run
175
176     # Upload
177     - name: Extract Binaries
178       run: |
179         DIR=$CARGO_TARGET_DIR/debug
180         rm $DIR/deps/integration-*.d
181         mv $DIR/deps/integration-* $DIR/integration
182         find $DIR ! -executable -o -type d ! -path $DIR | xargs rm -rf
183         rm -rf $CARGO_TARGET_DIR/release
184
185     - name: Upload Binaries
186       uses: actions/upload-artifact@v1
187       with:
188         name: target
189         path: target
190
191   integration:
192     needs: integration_build
193     strategy:
194       fail-fast: false
195       max-parallel: 6
196       matrix:
197         integration:
198         - 'rust-lang/cargo'
199         # FIXME: re-enable once fmt_macros is renamed in RLS
200         # - 'rust-lang/rls'
201         - 'rust-lang/chalk'
202         - 'rust-lang/rustfmt'
203         - 'Marwes/combine'
204         - 'Geal/nom'
205         - 'rust-lang/stdarch'
206         - 'serde-rs/serde'
207         # FIXME: chrono currently cannot be compiled with `--all-targets`
208         # - 'chronotope/chrono'
209         - 'hyperium/hyper'
210         - 'rust-random/rand'
211         - 'rust-lang/futures-rs'
212         - 'rust-itertools/itertools'
213         - 'rust-lang-nursery/failure'
214         - 'rust-lang/log'
215
216     runs-on: ubuntu-latest
217
218     steps:
219     # Setup
220     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
221       with:
222         github_token: "${{ secrets.github_token }}"
223
224     - name: Checkout
225       uses: actions/checkout@v2.3.3
226
227     - name: Install toolchain
228       run: rustup show active-toolchain
229
230     # Download
231     - name: Download target dir
232       uses: actions/download-artifact@v1
233       with:
234         name: target
235         path: target
236
237     - name: Make Binaries Executable
238       run: chmod +x $CARGO_TARGET_DIR/debug/*
239
240     # Run
241     - name: Test ${{ matrix.integration }}
242       run: |
243         RUSTUP_TOOLCHAIN="$(rustup show active-toolchain | grep -o -E "nightly-[0-9]{4}-[0-9]{2}-[0-9]{2}")" \
244           $CARGO_TARGET_DIR/debug/integration
245       env:
246         INTEGRATION: ${{ matrix.integration }}
247
248   # These jobs doesn't actually test anything, but they're only used to tell
249   # bors the build completed, as there is no practical way to detect when a
250   # workflow is successful listening to webhooks only.
251   #
252   # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
253
254   end-success:
255     name: bors test finished
256     if: github.event.pusher.name == 'bors' && success()
257     runs-on: ubuntu-latest
258     needs: [changelog, base, integration_build, integration]
259
260     steps:
261       - name: Mark the job as successful
262         run: exit 0
263
264   end-failure:
265     name: bors test finished
266     if: github.event.pusher.name == 'bors' && (failure() || cancelled())
267     runs-on: ubuntu-latest
268     needs: [changelog, base, integration_build, integration]
269
270     steps:
271       - name: Mark the job as a failure
272         run: exit 1