Repository navigation
249 lines (201 loc) · 7.21 KB
/
Copy pathbasic.yml
File metadata and controls
249 lines (201 loc) · 7.21 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
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
name: Basic
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: "0 16 * * 0" # Every Sunday at 16:00 UTC
workflow_dispatch:
inputs:
deploy_documentation:
description: Deploy documentation
required: false
type: boolean
default: false
env:
CARGO_TERM_COLOR: always
permissions:
contents: read
jobs:
build-and-test:
if: github.event_name != 'schedule'
runs-on: ["oneapi-rs", "Linux"]
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Setup oneAPI
uses: ./.github/actions/setup-oneapi
- name: Print system info
run: |
sycl-ls --verbose
- name: Check formatting
run: cargo fmt --all -- --check
- name: Check C++ formatting
run: |
git ls-files -z -- ':(glob)**/*.cpp' ':(glob)**/*.hpp' ':(glob)**/*.h' \
| xargs -0 --no-run-if-empty clang-format --dry-run --Werror
- name: Run Clippy
run: cargo clippy --workspace --all-targets -- -D warnings
- name: Build
run: cargo build --verbose
- name: Run workspace tests
run: cargo test --workspace --verbose
- name: Run examples
run: |
for example_path in sycl/sycl-rs/examples/*.rs; do
example="$(basename "$example_path" .rs)"
cargo run -p sycl-rs --example "$example" --verbose
done
- name: Generate documentation
run: |
cargo doc -p sycl-rs --no-deps --verbose
cat > target/doc/index.html <<'HTML'
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="0; url=sycl_rs/">
<title>sycl-rs documentation</title>
</head>
<body>
<p><a href="sycl_rs/">sycl-rs documentation</a></p>
</body>
</html>
HTML
- name: Upload documentation artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: documentation
path: target/doc
hardening:
if: github.event_name != 'schedule'
runs-on: ["oneapi-rs", "Linux"]
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Setup oneAPI
uses: ./.github/actions/setup-oneapi
- name: Install nightly toolchain
run: rustup toolchain install nightly --profile minimal
- name: Build and test with hardening flags
env:
RUSTFLAGS: -Zemit-stack-sizes -Zcf-protection=full
CARGO_TARGET_DIR: target/hardened
run: |
cargo +nightly test --workspace --verbose
cargo +nightly build --workspace --release --verbose
sanitizers:
name: Sanitizer (${{ matrix.sanitizer }})
if: github.event_name != 'schedule'
runs-on: ["oneapi-rs", "Linux"]
strategy:
fail-fast: false
matrix:
# TODO add thread sanitizer
sanitizer: [address, leak]
env:
CARGO_TARGET_DIR: target/sanitizer-${{ matrix.sanitizer }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Setup oneAPI
uses: ./.github/actions/setup-oneapi
- name: Install nightly toolchain
run: rustup toolchain install nightly --profile minimal
- name: Run tests with sanitizers
env:
# Test only CPU to avoid issues with GPU drivers and sanitizers
ONEAPI_DEVICE_SELECTOR: opencl:cpu
# Leave leak detection to the dedicated leak sanitizer job.
ASAN_OPTIONS: detect_leaks=0
LSAN_OPTIONS: suppressions=${{ github.workspace }}/.github/lsan-suppressions.txt
RUSTFLAGS: -Zsanitizer=${{ matrix.sanitizer }}
run: |
cargo +nightly test \
--workspace --lib --tests --target x86_64-unknown-linux-gnu --verbose
trivy:
name: Trivy scan
runs-on: ubuntu-latest
permissions:
contents: write
security-events: write
actions: read
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Generate SPDX SBOM with Trivy
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
scan-type: fs
scan-ref: .
format: spdx-json
output: sbom.spdx.json
- name: Upload SPDX SBOM artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: sbom-spdx
path: sbom.spdx.json
if-no-files-found: error
- name: Submit SPDX SBOM to GitHub dependency graph
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
uses: advanced-security/spdx-dependency-submission-action@b009efcf8b9d562a4569d2028c276522232e631f # v0.4.0
with:
filePath: sbom.spdx.json
- name: Scan repository with Trivy
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
scan-type: fs
scan-ref: .
scanners: vuln,secret,misconfig
format: sarif
output: trivy-results.sarif
exit-code: '1'
- name: Upload Trivy findings
if: ${{ always() && hashFiles('trivy-results.sarif') != '' }}
uses: github/codeql-action/upload-sarif@d8073367669608af8fbcc5f63dd0a0d52bb90cff # v4
with:
sarif_file: trivy-results.sarif
category: trivy
rustsec:
name: RustSec audit
runs-on: ["oneapi-rs", "Linux"]
permissions:
contents: read
security-events: write
actions: read
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Audit dependencies against RustSec
run: |
audit_dir="$(mktemp -d "$RUNNER_TEMP/rustsec.XXXXXX")"
cargo +stable audit --db "$audit_dir/advisory-db" --deny unsound --format sarif > cargo-audit.sarif
- name: Upload RustSec findings
# Upload the report even when the audit step fails on findings.
if: ${{ always() && hashFiles('cargo-audit.sarif') != '' }}
uses: github/codeql-action/upload-sarif@d8073367669608af8fbcc5f63dd0a0d52bb90cff # v4
with:
sarif_file: cargo-audit.sarif
category: rustsec
deploy-documentation:
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'workflow_dispatch' && inputs.deploy_documentation == 'true')
needs: build-and-test
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Download documentation artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: documentation
path: target/doc
- name: Configure GitHub Pages
uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0
- name: Upload documentation to GitHub Pages
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: target/doc
- name: Deploy documentation to GitHub Pages
id: deployment
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0