Skip to content

Commit 85097b5

Browse files
committed
Working on CI flow
1 parent e7b7662 commit 85097b5

23 files changed

Lines changed: 1450 additions & 191 deletions

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Cargo.lock -diff

.github/workflows/audit.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Dependency Audit
2+
3+
on:
4+
# Automatically run the dependency audit every monday
5+
schedule:
6+
- cron: "0 0 * * 1"
7+
8+
# Re-run the dependency audit whenever our Cargo.toml or
9+
# Cargo.lock changes
10+
push:
11+
paths:
12+
- "**/Cargo.toml"
13+
- "**/Cargo.lock"
14+
- ".github/workflows/audit.yml"
15+
16+
# Run a dependency audit on all PRs
17+
pull_request:
18+
19+
jobs:
20+
audit:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v3
25+
26+
- name: Run audit
27+
uses: actions-rs/audit-check@v1
28+
with:
29+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/coverage.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Coverage
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
check:
7+
name: Coverage
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v3
13+
14+
- name: Install rust
15+
uses: actions-rs/toolchain@v1
16+
with:
17+
profile: minimal
18+
toolchain: nightly
19+
components: llvm-tools-preview
20+
override: true
21+
22+
- name: Restore cache
23+
uses: Swatinem/rust-cache@v1
24+
25+
- name: Install cargo-llvm-cov
26+
uses: taiki-e/install-action@cargo-llvm-cov
27+
28+
- name: Generate code coverage
29+
uses: actions-rs/cargo@v1
30+
with:
31+
command: llvm-cov
32+
args: --all-features --workspace --lcov --output-path coverage.info
33+
34+
- name: Upload to codecov.io
35+
uses: codecov/codecov-action@v1.0.2
36+
with:
37+
token: ${{ secrets.CODECOV_TOKEN }}
38+
files: coverage.info
39+
fail_ci_if_error: true
40+
if: ${{ github.ref == 'refs/heads/main' }}
41+
42+
- name: Archive code coverage results
43+
uses: actions/upload-artifact@v1
44+
with:
45+
name: code-coverage-report
46+
path: coverage.info

.github/workflows/main.yml

Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
name: Rust
2+
3+
on: [push, pull_request]
4+
5+
env:
6+
CARGO_TERM_COLOR: always
7+
CARGO_INCREMENTAL: 0
8+
CARGO_NET_RETRY: 10
9+
RUST_BACKTRACE: short
10+
RUSTUP_MAX_RETRIES: 10
11+
12+
jobs:
13+
tests:
14+
name: Tests
15+
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
# We test the following targets:
21+
# - 64bit Linux stable
22+
# - 64bit Linux beta
23+
# - 64bit Linux nightly
24+
# - 64bit MacOS stable
25+
# - 64bit Windows stable
26+
# - 32bit Windows stable
27+
include:
28+
- {
29+
rust: stable,
30+
target: x86_64-unknown-linux-gnu,
31+
os: ubuntu-latest,
32+
}
33+
- { rust: stable, target: x86_64-apple-darwin, os: macos-latest }
34+
- { rust: stable, target: x86_64-pc-windows-msvc, os: windows-latest }
35+
- { rust: stable, target: i686-pc-windows-msvc, os: windows-latest }
36+
- { rust: beta, target: x86_64-unknown-linux-gnu, os: ubuntu-latest }
37+
- {
38+
rust: nightly,
39+
target: x86_64-unknown-linux-gnu,
40+
os: ubuntu-latest,
41+
}
42+
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@v3
46+
47+
- name: Install rust
48+
uses: actions-rs/toolchain@v1
49+
with:
50+
toolchain: ${{ matrix.rust }}
51+
target: ${{ matrix.target }}
52+
profile: minimal
53+
default: true
54+
55+
- name: Restore cache
56+
uses: Swatinem/rust-cache@v1
57+
58+
# We split building the tests into a separate step
59+
# so that we can easily distinguish between build
60+
# errors and failing tests
61+
- name: Build tests with all features
62+
uses: actions-rs/cargo@v1
63+
with:
64+
command: test
65+
args: --no-run --all-features --target ${{ matrix.target }}
66+
67+
- name: Build tests with no features
68+
uses: actions-rs/cargo@v1
69+
with:
70+
command: test
71+
args: --no-run --no-default-features --target ${{ matrix.target }}
72+
73+
- name: Run tests
74+
uses: actions-rs/cargo@v1
75+
with:
76+
command: test
77+
args: --all-features --target ${{ matrix.target }}
78+
79+
miri:
80+
name: Miri
81+
82+
runs-on: ${{ matrix.os }}
83+
strategy:
84+
fail-fast: false
85+
matrix:
86+
os: [ubuntu-latest, macos-latest, windows-latest]
87+
88+
steps:
89+
- name: Checkout repository
90+
uses: actions/checkout@v3
91+
92+
- name: Install rust
93+
uses: actions-rs/toolchain@v1
94+
with:
95+
toolchain: nightly
96+
profile: minimal
97+
components: miri, rust-src
98+
default: true
99+
100+
- name: Restore cache
101+
uses: Swatinem/rust-cache@v1
102+
103+
- name: Run miri
104+
uses: actions-rs/cargo@v1
105+
env:
106+
OS: ${{ matrix.os }}
107+
MIRIFLAGS: "-Zmiri-tag-raw-pointers -Zmiri-disable-isolation"
108+
with:
109+
command: miri
110+
args: test --all-features
111+
112+
test-sanitizers:
113+
name: Sanitizer Tests
114+
115+
runs-on: ${{ matrix.os }}
116+
strategy:
117+
fail-fast: false
118+
119+
# Note: We use this really sketchy matrix because msan doesn't work on macos,
120+
# I would much rather use `matrix.exclude` for this but for some reason
121+
# github actions in its ever-inspired wisdom decided that `include`
122+
# should calculate its combinations *after* `exclude`` is applied
123+
# and since no one could *ever* want to exclude things added by an
124+
# `include` and in their infinite brilliance they saw fit not to have
125+
# any way of excluding things added by an include. In an ideal world I'd
126+
# just write this since it's what makes sense
127+
# ```
128+
# matrix:
129+
# sanitizer: [address, thread, memory, leak]
130+
# include:
131+
# - { target: x86_64-unknown-linux-gnu, os: ubuntu-latest }
132+
# - { target: x86_64-apple-darwin, os: macos-latest }
133+
# exclude:
134+
# - target: x86_64-apple-darwin
135+
# sanitizer: memory
136+
# ```
137+
# but no, instead we have to do whatever the hell this is
138+
matrix:
139+
os: [ubuntu-latest, macos-latest]
140+
sanitizer: [address, thread, memory, leak]
141+
target: [x86_64-unknown-linux-gnu, x86_64-apple-darwin]
142+
exclude:
143+
# Exclude ubuntu runs with darwin targets
144+
- { os: ubuntu-latest, target: x86_64-apple-darwin }
145+
# Exclude macos runs with linux targets
146+
- { os: macos-latest, target: x86_64-unknown-linux-gnu }
147+
# Exclude darwin runs with memory sanitizers since
148+
# it doesn't support msan
149+
- { target: x86_64-apple-darwin, sanitizer: memory }
150+
151+
steps:
152+
- name: Checkout
153+
uses: actions/checkout@v3
154+
155+
- name: Install rust
156+
uses: actions-rs/toolchain@v1
157+
with:
158+
profile: minimal
159+
toolchain: nightly
160+
target: ${{ matrix.target }}
161+
components: rust-src
162+
default: true
163+
164+
- name: Restore cache
165+
uses: Swatinem/rust-cache@v1
166+
167+
- name: Run tests under ${{ matrix.sanitizer }} sanitizer
168+
uses: actions-rs/cargo@v1
169+
env:
170+
RUSTDOCFLAGS: "-Z sanitizer=${{ matrix.sanitizer }}"
171+
RUSTFLAGS: "-Z sanitizer=${{ matrix.sanitizer }}"
172+
ASAN_OPTIONS: detect_stack_use_after_return=1,detect_leaks=1
173+
# Backtraces sometimes mess with sanitizers
174+
RUST_BACKTRACE: 0
175+
with:
176+
command: test
177+
args: --all-features --target ${{ matrix.target }} -Z build-std
178+
179+
clippy:
180+
name: Clippy
181+
runs-on: ubuntu-latest
182+
183+
steps:
184+
- name: Checkout repository
185+
uses: actions/checkout@v3
186+
187+
- name: Install rust
188+
uses: actions-rs/toolchain@v1
189+
with:
190+
profile: minimal
191+
toolchain: nightly
192+
components: clippy
193+
default: true
194+
195+
- name: Restore cache
196+
uses: Swatinem/rust-cache@v1
197+
198+
- name: Run clippy
199+
uses: actions-rs/clippy-check@v1
200+
with:
201+
token: ${{ secrets.GITHUB_TOKEN }}
202+
args: --all-features --all -- -D warnings
203+
204+
fmt:
205+
name: Rustfmt
206+
runs-on: ubuntu-latest
207+
208+
steps:
209+
- name: Checkout repository
210+
uses: actions/checkout@v3
211+
212+
- name: Install rust
213+
uses: actions-rs/toolchain@v1
214+
with:
215+
profile: minimal
216+
toolchain: nightly
217+
components: rustfmt
218+
default: true
219+
220+
- name: Run rustfmt
221+
uses: actions-rs/cargo@v1
222+
with:
223+
command: fmt
224+
args: --all -- --check
225+
226+
links:
227+
name: Check Doc Links
228+
runs-on: ubuntu-latest
229+
230+
steps:
231+
- name: Checkout
232+
uses: actions/checkout@v3
233+
234+
- name: Install rust
235+
uses: actions-rs/toolchain@v1
236+
with:
237+
toolchain: stable
238+
default: true
239+
240+
- name: Restore cache
241+
uses: Swatinem/rust-cache@v1
242+
243+
- name: Check links
244+
uses: actions-rs/cargo@v1
245+
with:
246+
command: rustdoc
247+
args: --all-features -- -D warnings

.github/workflows/rust.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
# will have compiled files and executables
33
/target/
44

5-
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6-
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
7-
Cargo.lock
8-
95
# These are backup files generated by rustfmt
106
**/*.rs.bk
117

@@ -28,3 +24,5 @@ lcov.info
2824

2925
.idea
3026
*.iml
27+
28+
benches/galen_data/

.vscode/settings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"powerHeader.template": "file://$WORKSPACE_FOLDER/LICENSE_TEMPLATE",
88
"testExplorer.addToEditorContextMenu": true,
99
"testExplorer.showOnRun": true,
10-
"testExplorer.useNativeTesting": true
11-
}
10+
"testExplorer.useNativeTesting": true,
11+
"rust-analyzer.cargo.features": "all",
12+
}

0 commit comments

Comments
 (0)