Skip to content

Commit 8eeeee8

Browse files
committed
clippy GH Action
1 parent 4d096ff commit 8eeeee8

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: 'rust-setup'
2+
description: 'Prepares a rust environment and relevant caches.'
3+
inputs:
4+
target:
5+
description: 'Additionally install specified target for this toolchain, ex. x86_64-apple-darwin'
6+
required: false
7+
toolchain:
8+
description: 'Toolchain to install. Default: stable.'
9+
required: false
10+
default: stable
11+
components:
12+
description: 'Comma-separated string of additional components to install e.g. `clippy`, `rustfmt`'
13+
required: false
14+
runs:
15+
using: "composite"
16+
steps:
17+
18+
- name: Get current date
19+
shell: bash
20+
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
21+
22+
- name: Setup rust toolchain
23+
shell: bash
24+
run: |
25+
26+
if ! rustup self update; then
27+
echo "rustup self update failed"
28+
fi
29+
30+
TARGET=${{ inputs.target }}
31+
if [[ $TARGET != '' ]]; then
32+
rustup target add $TARGET
33+
fi
34+
35+
rustup update
36+
37+
TOOLCHAIN=${{ inputs.toolchain }}
38+
if [[ $TOOLCHAIN != 'stable' ]]; then
39+
rustup toolchain install $TOOLCHAIN
40+
fi
41+
42+
COMPONENTS=${{ inputs.components }}
43+
if [[ $COMPONENTS != '' ]]; then
44+
for i in ${COMPONENTS//,/ }
45+
do
46+
rustup component add $i $(if [ $TOOLCHAIN != '' ]; then echo --toolchain $TOOLCHAIN; fi)
47+
done
48+
fi
49+
50+
rustup show
51+
52+
# Generate Cargo.lock files for build, sccache cache keys.
53+
# Allows dependencies updated on crates.io between runs to trigger storing an updated cache,
54+
# which hashing Cargo.toml files alone does not.
55+
- name: Cargo update
56+
run: cargo update
57+
shell: bash
58+

.github/actions/workflows/clippy.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Clippy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
- 'epic/**'
11+
- 'support/**'
12+
paths:
13+
- '.github/workflows/clippy.yml'
14+
- '**.rs'
15+
- '**.toml'
16+
17+
jobs:
18+
clippy:
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: false
22+
23+
steps:
24+
- uses: actions/checkout@v3
25+
26+
- name: Setup Rust
27+
uses: './.github/actions/rust/rust-setup'
28+
29+
- name: core clippy check
30+
uses: actions-rs-plus/clippy-check@b09a9c37c9df7db8b1a5d52e8fe8e0b6e3d574c4
31+
with:
32+
args: --all-targets --all-features -- -D warnings

0 commit comments

Comments
 (0)