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