]> git.proxmox.com Git - rustc.git/blob - src/tools/clippy/.github/workflows/clippy_bors.yml
New upstream version 1.63.0+dfsg1
[rustc.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
27 - name: Checkout
28 uses: actions/checkout@v3.0.2
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@v3.0.2
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
116
117 - name: Test
118 if: runner.os == 'Linux'
119 run: cargo test --features deny-warnings,internal
120
121 - name: Test
122 if: runner.os != 'Linux'
123 run: cargo test --features deny-warnings,internal -- --skip dogfood
124
125 - name: Test clippy_lints
126 run: cargo test --features deny-warnings,internal
127 working-directory: clippy_lints
128
129 - name: Test clippy_utils
130 run: cargo test --features deny-warnings,internal
131 working-directory: clippy_utils
132
133 - name: Test rustc_tools_util
134 run: cargo test --features deny-warnings
135 working-directory: rustc_tools_util
136
137 - name: Test clippy_dev
138 run: cargo test --features deny-warnings
139 working-directory: clippy_dev
140
141 - name: Test clippy-driver
142 run: bash .github/driver.sh
143 env:
144 OS: ${{ runner.os }}
145
146 metadata_collection:
147 needs: base
148 runs-on: ubuntu-latest
149
150 steps:
151 # Setup
152 - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
153 with:
154 github_token: "${{ secrets.github_token }}"
155
156 - name: Checkout
157 uses: actions/checkout@v3.0.2
158
159 - name: Install toolchain
160 run: rustup show active-toolchain
161
162 - name: Test metadata collection
163 run: cargo collect-metadata
164
165 integration_build:
166 needs: changelog
167 runs-on: ubuntu-latest
168
169 steps:
170 # Setup
171 - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
172 with:
173 github_token: "${{ secrets.github_token }}"
174
175 - name: Checkout
176 uses: actions/checkout@v3.0.2
177
178 - name: Install toolchain
179 run: rustup show active-toolchain
180
181 # Run
182 - name: Build Integration Test
183 run: cargo test --test integration --features integration --no-run
184
185 # Upload
186 - name: Extract Binaries
187 run: |
188 DIR=$CARGO_TARGET_DIR/debug
189 rm $DIR/deps/integration-*.d
190 mv $DIR/deps/integration-* $DIR/integration
191 find $DIR ! -executable -o -type d ! -path $DIR | xargs rm -rf
192 rm -rf $CARGO_TARGET_DIR/release
193
194 - name: Upload Binaries
195 uses: actions/upload-artifact@v1
196 with:
197 name: target
198 path: target
199
200 integration:
201 needs: integration_build
202 strategy:
203 fail-fast: false
204 max-parallel: 6
205 matrix:
206 integration:
207 - 'rust-lang/cargo'
208 # FIXME: re-enable once fmt_macros is renamed in RLS
209 # - 'rust-lang/rls'
210 - 'rust-lang/chalk'
211 - 'rust-lang/rustfmt'
212 - 'Marwes/combine'
213 - 'Geal/nom'
214 - 'rust-lang/stdarch'
215 - 'serde-rs/serde'
216 # FIXME: chrono currently cannot be compiled with `--all-targets`
217 # - 'chronotope/chrono'
218 - 'hyperium/hyper'
219 - 'rust-random/rand'
220 - 'rust-lang/futures-rs'
221 - 'rust-itertools/itertools'
222 - 'rust-lang-nursery/failure'
223 - 'rust-lang/log'
224
225 runs-on: ubuntu-latest
226
227 steps:
228 # Setup
229 - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
230 with:
231 github_token: "${{ secrets.github_token }}"
232
233 - name: Checkout
234 uses: actions/checkout@v3.0.2
235
236 - name: Install toolchain
237 run: rustup show active-toolchain
238
239 # Download
240 - name: Download target dir
241 uses: actions/download-artifact@v1
242 with:
243 name: target
244 path: target
245
246 - name: Make Binaries Executable
247 run: chmod +x $CARGO_TARGET_DIR/debug/*
248
249 # Run
250 - name: Test ${{ matrix.integration }}
251 run: |
252 RUSTUP_TOOLCHAIN="$(rustup show active-toolchain | grep -o -E "nightly-[0-9]{4}-[0-9]{2}-[0-9]{2}")" \
253 $CARGO_TARGET_DIR/debug/integration
254 env:
255 INTEGRATION: ${{ matrix.integration }}
256
257 # These jobs doesn't actually test anything, but they're only used to tell
258 # bors the build completed, as there is no practical way to detect when a
259 # workflow is successful listening to webhooks only.
260 #
261 # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
262
263 end-success:
264 name: bors test finished
265 if: github.event.pusher.name == 'bors' && success()
266 runs-on: ubuntu-latest
267 needs: [changelog, base, integration_build, integration]
268
269 steps:
270 - name: Mark the job as successful
271 run: exit 0
272
273 end-failure:
274 name: bors test finished
275 if: github.event.pusher.name == 'bors' && (failure() || cancelled())
276 runs-on: ubuntu-latest
277 needs: [changelog, base, integration_build, integration]
278
279 steps:
280 - name: Mark the job as a failure
281 run: exit 1