-
Notifications
You must be signed in to change notification settings - Fork 5
102 lines (93 loc) · 2.65 KB
/
ci.yml
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
---
name: Rust CI
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
permissions:
contents: read
statuses: write
env:
CARGO_TERM_COLOR: always
jobs:
# Ensure Minimum Supported Rust Version (MSRV)
build-msrv:
name: Build with MSRV
runs-on: ubuntu-latest
outputs:
msrv: ${{ steps.extract_rust_version.outputs.msrv }}
steps:
- uses: actions/checkout@v4
- name: Extract Rust Version
id: extract_rust_version
run: |
rust_version=$(awk -F '"' '/rust-version/ {print $2; exit}' Cargo.toml)
if [ -z "$rust_version" ]; then
echo "Error: rust-version not found in Cargo.toml"
exit 1
fi
echo "msrv=$rust_version" >> "$GITHUB_OUTPUT"
- name: Set Up Rust Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ steps.extract_rust_version.outputs.msrv }}
- uses: Swatinem/rust-cache@v2
- run: cargo build --all
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo check --all
tests:
name: Tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo test --all
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: rustup component add rustfmt
- uses: Swatinem/rust-cache@v2
- run: cargo fmt --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: rustup component add clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --all -- -D warnings
line-endings:
name: Check line endings
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check for CRLF line endings
run: |
echo "Checking for files with CRLF line endings ..."
files_with_crlf=$(git ls-files -z | xargs -0 grep -IlI $'\r$' || true)
if [ -n "$files_with_crlf" ]; then
echo "Error: The following files have CRLF line endings:"
echo "$files_with_crlf"
echo "Please change these files to use LF line endings."
exit 1
else
echo "No files with CRLF line endings found."
fi