-
Notifications
You must be signed in to change notification settings - Fork 2
187 lines (148 loc) · 5.24 KB
/
rust-ci.yaml
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: Rust CI
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Setup Rust
run: |
set -e
rustup toolchain install stable --no-self-update --profile minimal --component rustfmt
rustup default stable
- name: Run Clippy
run: cargo fmt --all --check
yara:
needs: lint
uses: ./.github/workflows/yara.yaml
with:
runs-on: ubuntu-22.04
clippy:
needs: yara
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Download YARA
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: ${{ needs.yara.outputs.artifacts }}
path: .yara
- name: Setup Rust
run: |
set -e
rustup toolchain install stable --no-self-update --profile minimal --component clippy
rustup default stable
- name: Cache dependencies
uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0
with:
key: x86_64-unknown-linux-gnu
- name: Run Clippy
env:
YARA_INCLUDE_DIR: ${{ github.workspace }}/.yara/${{ needs.yara.outputs.include-dir }}
YARA_LIBRARY_PATH: ${{ github.workspace }}/.yara/${{ needs.yara.outputs.library-path }}
run: cargo clippy -- -D clippy::all -D clippy::pedantic -D clippy::cargo -A clippy::cargo_common_metadata
yara-test:
needs: clippy
strategy:
fail-fast: true
matrix:
runs-on:
- ubuntu-22.04
uses: ./.github/workflows/yara.yaml
with:
runs-on: ${{ matrix.runs-on }}
yara-test-output:
needs: yara-test
runs-on: ubuntu-22.04
steps:
- name: Read Matrix Output
id: read
uses: cloudposse/github-action-matrix-outputs-read@main
with:
matrix-step-name: yara
outputs:
result: ${{ steps.read.outputs.result }}
test:
needs: [yara-test, yara-test-output]
strategy:
matrix:
triple:
- runs-on: ubuntu-22.04
target: x86_64-unknown-linux-gnu
runs-on: ${{ matrix.triple.runs-on }}
steps:
- name: Checkout repository
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Download YARA
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: ${{ fromJson(needs.yara-test-output.outputs.result).artifacts[matrix.triple.runs-on] }}
path: .yara
- name: Setup Rust
run: |
set -e
rustup toolchain install stable --no-self-update --profile minimal
rustup default stable
- name: Cache dependencies
uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0
with:
key: ${{ matrix.triple.target }}
- name: Run tests
env:
RUST_BACKTRACE: full
YARA_INCLUDE_DIR: ${{ github.workspace }}/.yara/${{ needs.yara-test.outputs.include-dir }}
YARA_LIBRARY_PATH: ${{ github.workspace }}/.yara/${{ needs.yara-test.outputs.library-path }}
run: cargo test --no-fail-fast
docs-build:
needs: [yara]
runs-on: ubuntu-22.04
steps:
- name: "Checkout repository"
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Cache dependencies
uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0
with:
key: x86_64-unknown-linux-gnu
- name: Download YARA
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: ${{ needs.yara.outputs.artifacts }}
path: .yara
- name: "Build docs with cargo"
run: cargo doc --no-deps --document-private-items
env:
YARA_INCLUDE_DIR: ${{ github.workspace }}/.yara/${{ needs.yara.outputs.include-dir }}
YARA_LIBRARY_PATH: ${{ github.workspace }}/.yara/${{ needs.yara.outputs.library-path }}
# `.lock` is set to to rw-------, which causes actions/deploy-pages to fail
# because it's expecting all files to be at least rw-r--r--
- name: "Remove '.lock' file"
run: rm ./target/doc/.lock
- name: "Upload artifact"
uses: actions/upload-pages-artifact@a753861a5debcf57bf8b404356158c8e1e33150c # v2.0.0
with:
path: ./target/doc
docs-deploy:
needs: docs-build
if: github.ref == 'refs/heads/main'
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-22.04
steps:
- name: "Deploy to GitHub Pages"
id: deployment
uses: actions/deploy-pages@9dbe3824824f8a1377b8e298bafde1a50ede43e5 # v2.0.4