-
Notifications
You must be signed in to change notification settings - Fork 33
103 lines (96 loc) · 3.63 KB
/
ci-rust.yml
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
name: 'CI - Rust'
on:
pull_request:
paths:
- .github/workflows/ci-rust.yml
- apps/utils/db-query-checker/*
merge_group:
jobs:
lint:
strategy:
matrix:
project:
- name: db-query-checker
directory: apps/utils/db-query-checker
runs-on: ubuntu-20.04
defaults:
run:
# Note: This only affects `run` steps; not actions.
working-directory: ${{ matrix.project.directory }}
steps:
- name: 'Checkout repo'
uses: actions/checkout@v4
# Try to use cache from this or ancestor branches.
# Also sets a hook that will cache this build after the job is complete.
- name: 'Cache cargo registry'
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles(format('{0}/**/Cargo.lock', matrix.project.directory)) }}
- name: 'Cache cargo index'
uses: actions/cache@v3
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles(format('{0}/**/Cargo.lock', matrix.project.directory)) }}
- name: 'Cache cargo build'
uses: actions/cache@v3
with:
path: ${{ matrix.project.directory }}/target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles(format('{0}/**/Cargo.lock', matrix.project.directory)) }}
- name: 'Install stable toolchain'
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
- name: 'Run `cargo fmt`'
uses: actions-rs/cargo@v1
with:
command: fmt
args: --manifest-path ${{ matrix.project.directory }}/Cargo.toml --all -- --check
- name: '`Run cargo clippy`'
uses: actions-rs/cargo@v1
with:
command: clippy
# Note workaround for subdir support: <https://github.com/actions-rs/cargo/issues/86#issuecomment-667088617>.
args: --manifest-path ${{ matrix.project.directory }}/Cargo.toml -- -D warnings
check:
strategy:
matrix:
project:
- name: db-query-checker
directory: apps/utils/db-query-checker
runs-on: ubuntu-20.04
defaults:
run:
# Note: This only affects `run` steps; not actions.
working-directory: ${{ matrix.project.directory }}
steps:
- name: 'Checkout repo'
uses: actions/checkout@v4
# Try to use cache from this or ancestor branches.
# Also sets a hook that will cache this build after the job is complete.
- name: 'Cache cargo registry'
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles(format('{0}/**/Cargo.lock', matrix.project.directory)) }}
- name: 'Cache cargo index'
uses: actions/cache@v3
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles(format('{0}/**/Cargo.lock', matrix.project.directory)) }}
- name: 'Cache cargo build'
uses: actions/cache@v3
with:
path: ${{ matrix.project.directory }}/target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles(format('{0}/**/Cargo.lock', matrix.project.directory)) }}
- name: 'Install stable toolchain'
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: 'Run `cargo check`'
uses: actions-rs/cargo@v1
with:
command: check
# Note workaround for subdir support: <https://github.com/actions-rs/cargo/issues/86#issuecomment-667088617>.
args: --manifest-path ${{ matrix.project.directory }}/Cargo.toml