Skip to content

Commit 9478247

Browse files
authored
Setup CI on GitHub Actions (#6)
1 parent aea77c3 commit 9478247

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

.github/workflows/ci.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
test:
17+
name: Test
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
os: [ubuntu-latest, macos-latest, windows-latest]
23+
rust: [stable, beta, nightly]
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Install Rust toolchain
29+
uses: dtolnay/rust-toolchain@master
30+
with:
31+
toolchain: ${{ matrix.rust }}
32+
33+
- name: Cache cargo registry
34+
uses: actions/cache@v4
35+
with:
36+
path: ~/.cargo/registry
37+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
38+
39+
- name: Cache cargo index
40+
uses: actions/cache@v4
41+
with:
42+
path: ~/.cargo/git
43+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
44+
45+
- name: Cache cargo build
46+
uses: actions/cache@v4
47+
with:
48+
path: target
49+
key: ${{ runner.os }}-cargo-build-target-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
50+
51+
- name: Build
52+
run: cargo build --verbose
53+
54+
- name: Run tests
55+
run: cargo test --verbose
56+
57+
lint:
58+
name: Lint
59+
runs-on: ubuntu-latest
60+
steps:
61+
- name: Checkout code
62+
uses: actions/checkout@v4
63+
64+
- name: Install Rust toolchain
65+
uses: dtolnay/rust-toolchain@stable
66+
with:
67+
components: rustfmt, clippy
68+
69+
- name: Cache cargo registry
70+
uses: actions/cache@v4
71+
with:
72+
path: ~/.cargo/registry
73+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
74+
75+
- name: Cache cargo index
76+
uses: actions/cache@v4
77+
with:
78+
path: ~/.cargo/git
79+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
80+
81+
- name: Cache cargo build
82+
uses: actions/cache@v4
83+
with:
84+
path: target
85+
key: ${{ runner.os }}-cargo-build-target-stable-${{ hashFiles('**/Cargo.lock') }}
86+
87+
- name: Check formatting
88+
run: cargo fmt --all -- --check
89+
90+
- name: Run clippy
91+
run: cargo clippy --all-targets
92+
93+
doc:
94+
name: Documentation
95+
runs-on: ubuntu-latest
96+
steps:
97+
- name: Checkout code
98+
uses: actions/checkout@v4
99+
100+
- name: Install Rust toolchain
101+
uses: dtolnay/rust-toolchain@stable
102+
103+
- name: Cache cargo registry
104+
uses: actions/cache@v4
105+
with:
106+
path: ~/.cargo/registry
107+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
108+
109+
- name: Cache cargo index
110+
uses: actions/cache@v4
111+
with:
112+
path: ~/.cargo/git
113+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
114+
115+
- name: Cache cargo build
116+
uses: actions/cache@v4
117+
with:
118+
path: target
119+
key: ${{ runner.os }}-cargo-build-target-stable-${{ hashFiles('**/Cargo.lock') }}
120+
121+
- name: Build documentation
122+
run: cargo doc --no-deps

0 commit comments

Comments
 (0)