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
# GitHub Actions CI check for the 'socketcan' Rust crate
#
# It does the following:
# - Format check of the sources using nightly
# - Build check using the current stable compiler and the MSRV version.
# - Check library, utils, examples, and tests
# - Check each optional feature that brings in its own code: tokio, smol,
# serde, enumerate. A feature that is never built here is a feature that
# can rot: 'tests/serde.rs' declares required-features = ["serde"], so a
# bare 'cargo test' silently skips every one of its tests.
# - Doc generation with all features, denying broken intra-doc links
# - Clippy check using the MSRV compiler, with all features
#
# Note that Cargo.lock is not committed, so each run resolves dependencies
# afresh and a new upstream release can break the MSRV leg without anything
# in this repository changing.
#
on:
name: Continuous integration
env:
CARGO_TERM_COLOR: always
jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rustfmt
- run: cargo fmt --all -- --check
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
- 1.89.0
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
# The 'enumerate' feature binds to libudev through the 'udev' crate.
- name: Install libudev
run: sudo apt-get update && sudo apt-get install -y libudev-dev
- name: Library default build check
run: cargo +${{ matrix.rust }} check
- name: Tokio build check
run: cargo +${{ matrix.rust }} check --all-targets --features=tokio,utils
- name: smol build check
run: cargo +${{ matrix.rust }} check --all-targets --features=smol,utils
- name: serde build check
run: cargo +${{ matrix.rust }} check --all-targets --features=serde
- name: enumerate build check
run: cargo +${{ matrix.rust }} check --all-targets --features=enumerate
- name: Doc generation
run: cargo +${{ matrix.rust }} doc --all-features --no-deps
env:
RUSTDOCFLAGS: -D warnings
- name: Run tests
run: cargo +${{ matrix.rust }} test
# Separate run: 'tests/serde.rs' requires the feature, so the default
# test run above does not execute any of it. Note that the feature list
# stays explicit rather than '--all-features', which would switch on
# 'vcan_tests' and 'netlink_tests' — those need a vcan0 interface and
# root, neither of which a runner has.
- name: Run serde tests
run: cargo +${{ matrix.rust }} test --features=serde
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.89.0
components: clippy
# '--all-features' switches on 'enumerate', which needs libudev.
- name: Install libudev
run: sudo apt-get update && sudo apt-get install -y libudev-dev
- name: Run clippy
run: cargo +1.89.0 clippy --all-features --all-targets -- -D warnings