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