-
Notifications
You must be signed in to change notification settings - Fork 0
158 lines (136 loc) · 4.52 KB
/
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Rust CI
on:
push:
branches:
- master
- dev
- release/*
#branches-ignore: [ 'temp/*' ]
pull_request:
branches: [ master ]
# https://docs.github.com/en/actions/using-workflows/manually-running-a-workflow
workflow_dispatch:
env:
RUST_VERSIONS: "['1.74.0','stable','beta']"
APT_DEPENDENCIES: "['libasound2-dev']"
jobs:
get-env-vars:
name: Get Environment vars
runs-on: ubuntu-latest
outputs:
RUST_VERSIONS: ${{ env.RUST_VERSIONS }}
APT_DEPENDENCIES: ${{ env.APT_DEPENDENCIES }}
steps:
- run: echo "null"
fmt:
name: Verify formatting with `rustfmt` on rust '${{ matrix.rust }}'
runs-on: ubuntu-latest
needs: [ get-env-vars ]
strategy:
matrix:
# https://github.com/orgs/community/discussions/46785#discussioncomment-4909718
# https://github.com/actions/runner/issues/2372#issuecomment-1591370444
rust: ${{ fromJSON(needs.get-env-vars.outputs.RUST_VERSIONS) }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: recursive
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
components: rustfmt
override: true
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
clippy:
name: Static analysis with `clippy` on rust '${{ matrix.rust }}'
runs-on: ubuntu-latest
needs: [ get-env-vars ]
strategy:
matrix:
rust: ${{ fromJSON(needs.get-env-vars.outputs.RUST_VERSIONS) }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: recursive
- name: Install deps
# https://github.com/orgs/community/discussions/27125#discussioncomment-3254720
if: ${{ fromJSON(needs.get-env-vars.outputs.APT_DEPENDENCIES)[0] != null }}
run: sudo apt-get -y install ${{ join(fromJSON(needs.get-env-vars.outputs.APT_DEPENDENCIES), ' ') }}
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
components: clippy
override: true
# Not using the fixed Cargo.lock results
# in too frequent changes and low cache usage.
# Should be enabled for binary crates which tracks
# Cargo.lock in the repository.
#
#- name: Generate Cargo.lock before the hash
# uses: actions-rs/cargo@v1
# with:
# command: generate-lockfile
- name: Setup caching
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: ""
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --workspace --all-targets -- -D warnings
- name: Run cargo clippy with all features
uses: actions-rs/cargo@v1
#uses: actions-rs/clippy-check@v1 # TODO: annotating does not work: "Error: Resource not accessible by integration"
with:
command: clippy
#token: ${{ secrets.GITHUB_TOKEN }}
args: --workspace --all-targets --all-features -- -D warnings
test:
name: Test Suite on rust '${{ matrix.rust }}'
runs-on: ubuntu-latest
needs: [ get-env-vars, fmt, clippy ]
strategy:
matrix:
rust: ${{ fromJSON(needs.get-env-vars.outputs.RUST_VERSIONS) }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: recursive
- name: Install deps
if: ${{ fromJSON(needs.get-env-vars.outputs.APT_DEPENDENCIES)[0] != null }}
run: sudo apt-get -y install ${{ join(fromJSON(needs.get-env-vars.outputs.APT_DEPENDENCIES), ' ') }}
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true
#- name: Generate Cargo.lock before the hash
# uses: actions-rs/cargo@v1
# with:
# command: generate-lockfile
- name: Setup caching
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: ""
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --all-targets --all-features --workspace
# - name: Run cargo test (ignored)
# uses: actions-rs/cargo@v1
# with:
# command: test
# args: --all-targets --all-features --workspace -- --ignored