-
-
Notifications
You must be signed in to change notification settings - Fork 23
172 lines (150 loc) · 4.99 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: Continuous Integration
on:
pull_request:
push:
branches:
- main
- staging # for bors
- trying # for bors
schedule:
- cron: "0 0 * * 0"
jobs:
build:
name: Build (${{ matrix.TARGET }})
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
TOOLCHAIN: [nightly]
TARGET:
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- i686-unknown-linux-gnu
- i686-unknown-linux-musl
- aarch64-unknown-linux-gnu
- aarch64-unknown-linux-musl
- armv5te-unknown-linux-gnueabi
- armv7-unknown-linux-gnueabihf
- arm-unknown-linux-gnueabi
- arm-unknown-linux-gnueabihf
- riscv64gc-unknown-linux-gnu
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.TOOLCHAIN }}
targets: ${{ matrix.TARGET }}
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --locked --target ${{ matrix.TARGET }} --no-default-features
test:
name: Test
runs-on: ubuntu-22.04
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
--no-install-recommends \
--allow-unauthenticated \
linux-doc \
libxcb-shape0-dev \
libxcb-xfixes0-dev \
libxkbcommon-dev
- name: Checkout the repository
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
- name: Setup cargo-tarpaulin
shell: bash
run: |
curl -s https://api.github.com/repos/xd009642/tarpaulin/releases/latest | \
grep "browser_download_url.*x86_64-unknown-linux-musl.tar.gz" | cut -d : -f 2,3 | tr -d \" | wget -qi -
tar -xzf cargo-tarpaulin-*.tar.gz
mv cargo-tarpaulin ~/.cargo/bin/
- name: Run tests [default]
run: |
NO_COLOR=1 cargo tarpaulin \
--no-default-features \
--out Xml --verbose
mv cobertura.xml test-output.xml
- name: Run tests [live]
run: |
cp .github/fixtures/sysctl.conf systeroid/
sudo env "PATH=$PATH" "HOME=$HOME" NO_COLOR=1 \
cargo tarpaulin \
--no-default-features \
--features live-tests \
--out Xml --verbose \
-- "test_systeroid"
./.github/fixtures/check_vars.sh systeroid/sysctl.conf
mv cobertura.xml live-test-output.xml
- name: Upload reports to codecov
uses: codecov/codecov-action@v3
with:
name: code-coverage-report
files: test-output.xml,live-test-output.xml
flags: unit-tests
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
lint:
name: Lint
runs-on: ubuntu-22.04
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Run shellcheck
uses: ludeeus/action-shellcheck@master
with:
scandir: "./scripts"
env:
SHELLCHECK_OPTS: -e SC2086
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Check formatting
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Run clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --tests -- -D warnings
- name: Run cargo-deny
uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check licenses sources
- name: Run cargo-msrv
shell: bash
run: |
curl -s 'https://api.github.com/repos/foresterre/cargo-msrv/releases' | \
jq -r "[.[] | select(.prerelease == false)][0].assets[] | select(.name | ascii_downcase | test(\"linux.*x86_64|x86_64.*linux\")).browser_download_url" | \
wget -qi -
tar -xvf cargo-msrv*.tar* -C ~/.cargo/bin/ cargo-msrv
for package in $(cargo metadata --format-version 1 | jq -r ".workspace_members[]" | awk '{print $1}'); do
printf "Checking MSRV for $package..."
cargo msrv --output-format json --path "$package" verify | tail -n 1 | jq --exit-status '.success'
done
- name: Run cargo-audit
uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run lychee
uses: lycheeverse/lychee-action@v1
with:
args: --exclude "repology.org|patreon.com" -v *.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}