]> git.lizzy.rs Git - rust.git/blob - .github/workflows/clippy_bors.yml
e84e3baec625d114ed1dccefa3ef9910372b0579
[rust.git] / .github / workflows / clippy_bors.yml
1 name: Clippy Test (bors)
2
3 on:
4   push:
5     branches: [auto, try]
6     # Don't run tests, when only textfiles were modified
7     paths-ignore:
8     - 'COPYRIGHT'
9     - 'LICENSE-*'
10     - '**.md'
11     - '**.txt'
12
13 env:
14   RUST_BACKTRACE: 1
15   CARGO_TARGET_DIR: '${{ github.workspace }}/target'
16   GHA_CI: 1
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     - name: Checkout
27       uses: actions/checkout@v2.0.0
28       with:
29         ref: ${{ github.ref }}
30     - name: Check Changelog
31       run: |
32         MESSAGE=$(git log --format=%B -n 1)
33         PR=$(echo "$MESSAGE" | grep -o "#[0-9]*" | head -1 | sed -e 's/^#//')
34         output=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$PR" | \
35           python -c "import sys, json; print(json.load(sys.stdin)['body'])" | \
36           grep "^changelog: " | \
37           sed "s/changelog: //g")
38         if [[ -z "$output" ]]; then
39           echo "ERROR: PR body must contain 'changelog: ...'"
40           exit 1
41         elif [[ "$output" = "none" ]]; then
42           echo "WARNING: changelog is 'none'"
43         fi
44       env:
45         PYTHONIOENCODING: 'utf-8'
46   base:
47     needs: changelog
48     strategy:
49       matrix:
50         os: [ubuntu-latest, windows-latest, macos-latest]
51         host: [x86_64-unknown-linux-gnu, i686-unknown-linux-gnu, x86_64-apple-darwin, x86_64-pc-windows-msvc]
52         exclude:
53         - os: ubuntu-latest
54           host: x86_64-apple-darwin
55         - os: ubuntu-latest
56           host: x86_64-pc-windows-msvc
57         - os: macos-latest
58           host: x86_64-unknown-linux-gnu
59         - os: macos-latest
60           host: i686-unknown-linux-gnu
61         - os: macos-latest
62           host: x86_64-pc-windows-msvc
63         - os: windows-latest
64           host: x86_64-unknown-linux-gnu
65         - os: windows-latest
66           host: i686-unknown-linux-gnu
67         - os: windows-latest
68           host: x86_64-apple-darwin
69
70     runs-on: ${{ matrix.os }}
71
72     steps:
73     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
74       with:
75         github_token: "${{ secrets.github_token }}"
76     - name: Install dependencies (Linux-i686)
77       run: |
78         sudo dpkg --add-architecture i386
79         sudo apt-get update
80         sudo apt-get install gcc-multilib libssl-dev:i386 libgit2-dev:i386
81       if: matrix.host == 'i686-unknown-linux-gnu'
82     - name: rust-toolchain
83       uses: actions-rs/toolchain@v1.0.3
84       with:
85         toolchain: nightly
86         target: ${{ matrix.host }}
87         profile: minimal
88     - name: Cache cargo dir
89       uses: actions/cache@v1
90       with:
91         path: ~/.cargo
92         key: ${{ runner.os }}-${{ matrix.host }}
93     - name: Checkout
94       uses: actions/checkout@v2.0.0
95     - name: Master Toolchain Setup
96       run: bash setup-toolchain.sh
97       env:
98         HOST_TOOLCHAIN: ${{ matrix.host }}
99       shell: bash
100
101     - name: Set LD_LIBRARY_PATH (Linux)
102       if: runner.os == 'Linux'
103       run: |
104         SYSROOT=$(rustc --print sysroot)
105         echo "::set-env name=LD_LIBRARY_PATH::${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}"
106     - name: Link rustc dylib (MacOS)
107       if: runner.os == 'macOS'
108       run: |
109         SYSROOT=$(rustc --print sysroot)
110         sudo mkdir -p /usr/local/lib
111         sudo find "${SYSROOT}/lib" -maxdepth 1 -name '*dylib' -exec ln -s {} /usr/local/lib \;
112     - name: Set PATH (Windows)
113       if: runner.os == 'Windows'
114       run: |
115         $sysroot = rustc --print sysroot
116         $env:PATH += ';' + $sysroot + '\bin'
117         echo "::set-env name=PATH::$env:PATH"
118     - name: Build
119       run: cargo build --features deny-warnings
120       shell: bash
121     - name: Test
122       run: cargo test --features deny-warnings
123       shell: bash
124     - name: Test clippy_lints
125       run: cargo test --features deny-warnings
126       shell: bash
127       working-directory: clippy_lints
128     - name: Test rustc_tools_util
129       run: cargo test --features deny-warnings
130       shell: bash
131       working-directory: rustc_tools_util
132     - name: Test clippy_dev
133       run: cargo test --features deny-warnings
134       shell: bash
135       working-directory: clippy_dev
136     - name: Test cargo-clippy
137       run: ../target/debug/cargo-clippy
138       shell: bash
139       working-directory: clippy_workspace_tests
140     - name: Test clippy-driver
141       run: bash .github/driver.sh
142       shell: bash
143       env:
144         OS: ${{ runner.os }}
145
146     - name: Run cargo-cache --autoclean
147       run: |
148         cargo install cargo-cache --debug
149         /usr/bin/find ~/.cargo/bin ! -type d -exec strip {} \;
150         cargo cache --autoclean
151       shell: bash
152   integration_build:
153     needs: changelog
154     runs-on: ubuntu-latest
155
156     steps:
157     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
158       with:
159         github_token: "${{ secrets.github_token }}"
160     - name: rust-toolchain
161       uses: actions-rs/toolchain@v1.0.3
162       with:
163         toolchain: nightly
164         target: x86_64-unknown-linux-gnu
165         profile: minimal
166     - name: Cache cargo dir
167       uses: actions/cache@v1
168       with:
169         path: ~/.cargo
170         key: ${{ runner.os }}-x86_64-unknown-linux-gnu
171     - name: Checkout
172       uses: actions/checkout@v2.0.0
173     - name: Master Toolchain Setup
174       run: bash setup-toolchain.sh
175
176     - name: Build Integration Test
177       run: cargo test --test integration --features integration --no-run
178     - name: Extract Binaries
179       run: |
180         DIR=$CARGO_TARGET_DIR/debug
181         find $DIR ! -executable -o -type d ! -path $DIR | xargs rm -rf
182         mv $DIR/integration-* $DIR/integration
183     - name: Upload Binaries
184       uses: actions/upload-artifact@v1
185       with:
186         name: target
187         path: target
188
189     - name: Run cargo-cache --autoclean
190       run: |
191         cargo install cargo-cache --debug
192         find ~/.cargo/bin ! -type d -exec strip {} \;
193         cargo cache --autoclean
194   integration:
195     needs: integration_build
196     strategy:
197       fail-fast: false
198       max-parallel: 6
199       matrix:
200         integration:
201         - 'rust-lang/cargo'
202         - 'rust-lang/rls'
203         - 'rust-lang/chalk'
204         - 'rust-lang/rustfmt'
205         - 'Marwes/combine'
206         - 'Geal/nom'
207         - 'rust-lang/stdarch'
208         - 'serde-rs/serde'
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     - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
221       with:
222         github_token: "${{ secrets.github_token }}"
223     - name: rust-toolchain
224       uses: actions-rs/toolchain@v1.0.3
225       with:
226         toolchain: nightly
227         target: x86_64-unknown-linux-gnu
228         profile: minimal
229     - name: Cache cargo dir
230       uses: actions/cache@v1
231       with:
232         path: ~/.cargo
233         key: ${{ runner.os }}-x86_64-unknown-linux-gnu
234     - name: Checkout
235       uses: actions/checkout@v2.0.0
236     - name: Master Toolchain Setup
237       run: bash setup-toolchain.sh
238
239     - name: Download target dir
240       uses: actions/download-artifact@v1
241       with:
242         name: target
243         path: target
244     - name: Make Binaries Executable
245       run: chmod +x $CARGO_TARGET_DIR/debug/*
246     - name: Test ${{ matrix.integration }}
247       run: $CARGO_TARGET_DIR/debug/integration
248       env:
249         INTEGRATION: ${{ matrix.integration }}
250         RUSTUP_TOOLCHAIN: master
251
252     - name: Run cargo-cache --autoclean
253       run: |
254         cargo install cargo-cache --debug
255         find ~/.cargo/bin ! -type d -exec strip {} \;
256         cargo cache --autoclean