Skip to content

Commit 925d495

Browse files
authored
Merge pull request #1 from matrix-org/quenting/ci
2 parents b69e405 + 5819979 commit 925d495

File tree

1 file changed

+164
-0
lines changed

1 file changed

+164
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
env:
14+
CARGO_TERM_COLOR: always
15+
16+
jobs:
17+
rustfmt:
18+
name: Check style
19+
runs-on: ubuntu-latest
20+
21+
permissions:
22+
contents: read
23+
24+
steps:
25+
- name: Checkout the code
26+
uses: actions/checkout@v3
27+
28+
- name: Install toolchain
29+
id: toolchain
30+
uses: actions-rs/toolchain@v1
31+
with:
32+
toolchain: nightly
33+
target: x86_64-unknown-linux-musl
34+
components: rustfmt
35+
profile: minimal
36+
override: true
37+
38+
- name: Check style
39+
uses: actions-rs/cargo@v1
40+
with:
41+
command: fmt
42+
args: --all -- --check
43+
44+
clippy:
45+
name: Run Clippy
46+
runs-on: ubuntu-latest
47+
48+
permissions:
49+
contents: read
50+
51+
steps:
52+
- name: Checkout the code
53+
uses: actions/checkout@v3
54+
55+
- name: Install toolchain
56+
id: toolchain
57+
uses: actions-rs/toolchain@v1
58+
with:
59+
toolchain: stable
60+
target: x86_64-unknown-linux-musl
61+
components: clippy
62+
profile: minimal
63+
override: true
64+
65+
- name: Setup cache
66+
uses: Swatinem/rust-cache@v2
67+
68+
- name: Run Clippy
69+
uses: actions-rs/cargo@v1
70+
with:
71+
command: clippy
72+
args: --workspace -- -D warnings
73+
74+
test:
75+
name: Run test suite with Rust ${{ matrix.toolchain }}
76+
needs: [rustfmt, clippy]
77+
runs-on: ubuntu-latest
78+
79+
permissions:
80+
contents: read
81+
82+
strategy:
83+
fail-fast: false # Continue other jobs if one fails to help filling the cache
84+
matrix:
85+
toolchain:
86+
- "1.61.0" # MSRV
87+
- stable
88+
- beta
89+
- nightly
90+
91+
steps:
92+
- name: Checkout the code
93+
uses: actions/checkout@v3
94+
95+
- name: Install toolchain
96+
id: toolchain
97+
uses: actions-rs/toolchain@v1
98+
with:
99+
toolchain: stable
100+
target: x86_64-unknown-linux-musl
101+
components: clippy
102+
profile: minimal
103+
override: true
104+
105+
- name: Setup cache
106+
uses: Swatinem/rust-cache@v2
107+
108+
- name: Test
109+
id: test
110+
uses: actions-rs/cargo@v1
111+
with:
112+
command: test
113+
args: --workspace
114+
115+
coverage:
116+
name: Code coverage
117+
needs: [rustfmt, clippy]
118+
runs-on: ubuntu-latest
119+
120+
permissions:
121+
contents: read
122+
123+
steps:
124+
- name: Checkout the code
125+
uses: actions/checkout@v3
126+
127+
- name: Install toolchain
128+
id: toolchain
129+
uses: actions-rs/toolchain@v1
130+
with:
131+
toolchain: stable
132+
target: x86_64-unknown-linux-musl
133+
override: true
134+
components: llvm-tools-preview
135+
136+
- name: Setup cache
137+
uses: Swatinem/rust-cache@v2
138+
139+
- name: Download grcov
140+
run: |
141+
mkdir -p "${HOME}/.local/bin"
142+
curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.11/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin"
143+
echo "$HOME/.local/bin" >> $GITHUB_PATH
144+
145+
- name: Run test suite with profiling enabled
146+
uses: actions-rs/cargo@v1
147+
with:
148+
command: test
149+
args: --no-fail-fast --workspace
150+
env:
151+
CARGO_INCREMENTAL: '0'
152+
RUSTFLAGS: '-Cinstrument-coverage'
153+
LLVM_PROFILE_FILE: "cargo-test-%p-%m.profraw"
154+
155+
- name: Build grcov report
156+
run: |
157+
mkdir -p target/coverage
158+
grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/coverage/tests.lcov
159+
160+
- name: Upload to codecov.io
161+
uses: codecov/codecov-action@v3
162+
with:
163+
files: target/coverage/*.lcov
164+
flags: unit

0 commit comments

Comments
 (0)