]> git.lizzy.rs Git - rust.git/blob - .github/workflows/clippy_bors.yml
Check if changelog exists
[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 Clippy 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     - name: Checkout
24       uses: actions/checkout@v2.0.0
25       with:
26         ref: ${{ github.ref }}
27     - name: Check Changelog
28       run: |
29         MESSAGE=$(git log --format=%B -n 1)
30         PR=$(echo "$MESSAGE" | grep -o "#[0-9]*" | head -1 | sed -e 's/^#//')
31         output=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$PR" | \
32           python -c "import sys, json; print(json.load(sys.stdin)['body'])" | \
33           grep "^changelog: " | \
34           sed "s/changelog: //g")
35         if [[ -z "$output" ]]; then
36           echo "ERROR: PR body must contain 'changelog: ...'"
37           exit 1
38         elif [[ "$output" = "none" ]]; then
39           echo "WARNING: changelog is 'none'"
40         fi
41   base:
42     needs: changelog
43     strategy:
44       matrix:
45         os: [ubuntu-latest, windows-latest, macos-latest]
46         host: [x86_64-unknown-linux-gnu, i686-unknown-linux-gnu, x86_64-apple-darwin, x86_64-pc-windows-msvc]
47         exclude:
48         - os: ubuntu-latest
49           host: x86_64-apple-darwin
50         - os: ubuntu-latest
51           host: x86_64-pc-windows-msvc
52         - os: macos-latest
53           host: x86_64-unknown-linux-gnu
54         - os: macos-latest
55           host: i686-unknown-linux-gnu
56         - os: macos-latest
57           host: x86_64-pc-windows-msvc
58         - os: windows-latest
59           host: x86_64-unknown-linux-gnu
60         - os: windows-latest
61           host: i686-unknown-linux-gnu
62         - os: windows-latest
63           host: x86_64-apple-darwin
64
65     runs-on: ${{ matrix.os }}
66
67     steps:
68     - name: Install dependencies (Linux-i686)
69       run: |
70         sudo dpkg --add-architecture i386
71         sudo apt-get update
72         sudo apt-get install gcc-multilib libssl-dev:i386 libgit2-dev:i386
73       if: matrix.host == 'i686-unknown-linux-gnu'
74     - name: rust-toolchain
75       uses: actions-rs/toolchain@v1.0.3
76       with:
77         toolchain: nightly
78         target: ${{ matrix.host }}
79         profile: minimal
80     - name: Cache cargo dir
81       uses: actions/cache@v1
82       with:
83         path: ~/.cargo
84         key: ${{ runner.os }}-${{ matrix.host }}
85     - name: Checkout
86       uses: actions/checkout@v2.0.0
87     - name: Master Toolchain Setup
88       run: bash setup-toolchain.sh
89       env:
90         HOST_TOOLCHAIN: ${{ matrix.host }}
91       shell: bash
92
93     - name: Set LD_LIBRARY_PATH (Linux)
94       if: runner.os == 'Linux'
95       run: |
96         SYSROOT=$(rustc --print sysroot)
97         echo "::set-env name=LD_LIBRARY_PATH::${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}"
98     - name: Link rustc dylib (MacOS)
99       if: runner.os == 'macOS'
100       run: |
101         SYSROOT=$(rustc --print sysroot)
102         sudo mkdir -p /usr/local/lib
103         sudo find "${SYSROOT}/lib" -maxdepth 1 -name '*dylib' -exec ln -s {} /usr/local/lib \;
104     - name: Set PATH (Windows)
105       if: runner.os == 'Windows'
106       run: |
107         $sysroot = rustc --print sysroot
108         $env:PATH += ';' + $sysroot + '\bin'
109         echo "::set-env name=PATH::$env:PATH"
110     - name: Build
111       run: cargo build --features deny-warnings
112       shell: bash
113     - name: Test
114       run: cargo test --features deny-warnings
115       shell: bash
116     - name: Test clippy_lints
117       run: cargo test --features deny-warnings
118       shell: bash
119       working-directory: clippy_lints
120     - name: Test rustc_tools_util
121       run: cargo test --features deny-warnings
122       shell: bash
123       working-directory: rustc_tools_util
124     - name: Test clippy_dev
125       run: cargo test --features deny-warnings
126       shell: bash
127       working-directory: clippy_dev
128     - name: Test cargo-clippy
129       run: ../target/debug/cargo-clippy
130       shell: bash
131       working-directory: clippy_workspace_tests
132     - name: Test clippy-driver
133       run: |
134         (
135           set -ex
136           # Check sysroot handling
137           sysroot=$(./target/debug/clippy-driver --print sysroot)
138           test "$sysroot" = "$(rustc --print sysroot)"
139
140           if [[ ${{ runner.os }} == "Windows" ]]; then
141             desired_sysroot=C:/tmp
142           else
143             desired_sysroot=/tmp
144           fi
145           sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot)
146           test "$sysroot" = $desired_sysroot
147
148           sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot)
149           test "$sysroot" = $desired_sysroot
150
151           # Make sure this isn't set - clippy-driver should cope without it
152           unset CARGO_MANIFEST_DIR
153
154           # Run a lint and make sure it produces the expected output. It's also expected to exit with code 1
155           # FIXME: How to match the clippy invocation in compile-test.rs?
156           ./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr && exit 1
157           sed -e 's,tests/ui,$DIR,' -e '/= help/d' cstring.stderr > normalized.stderr
158           diff normalized.stderr tests/ui/cstring.stderr
159
160           # TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR
161         )
162       shell: bash
163
164     - name: Run cargo-cache --autoclean
165       run: |
166         cargo install cargo-cache --debug
167         /usr/bin/find ~/.cargo/bin ! -type d -exec strip {} \;
168         cargo cache --autoclean
169       shell: bash