-
Notifications
You must be signed in to change notification settings - Fork 18
104 lines (87 loc) · 3.03 KB
/
Copy pathrust.yml
File metadata and controls
104 lines (87 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Rust
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
branches:
- main
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
with:
submodules: recursive
- name: Install protobuf compiler
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Install Rust
run: rustup update --no-self-update stable && rustup default stable
- name: Setup cache
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4
- name: Run workspace tests
if: ${{ !startsWith(github.head_ref, 'release-please--') }}
run: cargo test --workspace --verbose
- name: Run release crate tests
if: ${{ startsWith(github.head_ref, 'release-please--') }}
run: |
COMPONENT=$(echo "${{ github.head_ref }}" | sed 's/release-please--branches--main--components--//')
CRATE_DIR=$(find crates -maxdepth 1 -type d | while read dir; do
if [ -f "$dir/Cargo.toml" ]; then
PKG=$(grep '^name = ' "$dir/Cargo.toml" | head -1 | sed 's/name = "//;s/"//')
if [ "$PKG" = "$COMPONENT" ]; then
echo "$dir"
break
fi
fi
done)
if [ -n "$CRATE_DIR" ]; then
cargo test --manifest-path "$CRATE_DIR/Cargo.toml" --verbose
else
cargo test --workspace --verbose
fi
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
with:
submodules: recursive
- name: Install protobuf compiler
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Install Rust
run: rustup update --no-self-update stable && rustup default stable
- name: Check formats
run: cargo fmt --all --check
- name: Setup cache
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4
- name: Check workspace quality
if: ${{ !startsWith(github.head_ref, 'release-please--') }}
run: cargo clippy --workspace -- -D warnings
- name: Check release crate quality
if: ${{ startsWith(github.head_ref, 'release-please--') }}
run: |
COMPONENT=$(echo "${{ github.head_ref }}" | sed 's/release-please--branches--main--components--//')
CRATE_DIR=$(find crates -maxdepth 1 -type d | while read dir; do
if [ -f "$dir/Cargo.toml" ]; then
PKG=$(grep '^name = ' "$dir/Cargo.toml" | head -1 | sed 's/name = "//;s/"//')
if [ "$PKG" = "$COMPONENT" ]; then
echo "$dir"
break
fi
fi
done)
if [ -n "$CRATE_DIR" ]; then
cargo clippy --manifest-path "$CRATE_DIR/Cargo.toml" -- -D warnings
else
cargo clippy --workspace -- -D warnings
fi