Skip to content

Commit 151ca29

Browse files
committed
Update the CI workflow
1 parent 092a637 commit 151ca29

File tree

6 files changed

+332
-196
lines changed

6 files changed

+332
-196
lines changed

.github/actions/setup-arm/action.yml

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Setup ARM Build Environment
2+
description: Setup an ARM build environment
3+
4+
inputs:
5+
arch:
6+
required: true
7+
target:
8+
required: true
9+
toolchain:
10+
default: stable
11+
required: false
12+
components:
13+
required: false
14+
15+
runs:
16+
using: composite
17+
steps:
18+
- name: Replace target string
19+
uses: mad9000/actions-find-and-replace-string@3
20+
id: findandreplace
21+
with:
22+
source: ${{ inputs.target }}
23+
find: "unknown-"
24+
replace: ""
25+
26+
- name: Install toolchain
27+
uses: dtolnay/rust-toolchain@v1
28+
with:
29+
toolchain: ${{ inputs.toolchain }}
30+
target: ${{ inputs.target }}
31+
components: ${{ inputs.components }}
32+
33+
- uses: Swatinem/rust-cache@v2
34+
35+
- name: Install Cross-Compile Support
36+
uses: cyberjunk/gha-ubuntu-cross@v3
37+
with:
38+
arch: ${{ inputs.arch }}
39+
40+
- name: Install dependencies
41+
shell: bash
42+
run: |
43+
sudo apt install -y \
44+
curl \
45+
gcc-aarch64-linux-gnu \
46+
gcc-arm-linux-gnueabihf \
47+
git \
48+
"libc6:${{ inputs.arch }}" \
49+
"libgcc-s1:${{ inputs.arch }}" \
50+
libudev-dev \
51+
"libudev-dev:${{ inputs.arch }}" \
52+
"libudev1:${{ inputs.arch }}" \
53+
musl-tools \
54+
pkg-config
55+
56+
- name: Set environment variables
57+
shell: bash
58+
run: |
59+
echo "PKG_CONFIG_ALLOW_SYSTEM_LIBS=0" >> $GITHUB_ENV
60+
echo "PKG_CONFIG_DIR=/opt/" >> $GITHUB_ENV
61+
echo "PKG_CONFIG_LIBDIR=/opt/usr/lib/pkgconfig:/opt/usr/share/pkgconfig" >> $GITHUB_ENV
62+
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
63+
if [[ ${{ inputs.arch }} == arm64 ]]; then
64+
echo "PKG_CONFIG_PATH=/usr/lib/${{ steps.findandreplace.outputs.value }}/pkgconfig" >> $GITHUB_ENV
65+
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=${{ steps.findandreplace.outputs.value }}-gcc" >> $GITHUB_ENV
66+
fi
67+
if [[ ${{ inputs.arch }} == armhf ]]; then
68+
echo "PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig" >> $GITHUB_ENV
69+
echo "CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
70+
fi

.github/workflows/ci.yml

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
workflow_dispatch:
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
13+
# Cancel any currently running workflows from the same PR, branch, or
14+
# tag when a new workflow is triggered.
15+
#
16+
# https://stackoverflow.com/a/66336834
17+
concurrency:
18+
cancel-in-progress: true
19+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
20+
21+
jobs:
22+
# --------------------------------------------------------------------------
23+
# Check
24+
25+
check:
26+
name: Check
27+
strategy:
28+
matrix:
29+
os: ["macos-12", "ubuntu-22.04", "windows-2022"]
30+
runs-on: ${{ matrix.os }}
31+
32+
steps:
33+
- name: Install dependencies
34+
if: matrix.os == 'ubuntu-22.04'
35+
run: sudo apt-get install musl-tools libudev-dev
36+
37+
- uses: actions/checkout@v3
38+
- uses: dtolnay/rust-toolchain@stable
39+
- uses: Swatinem/rust-cache@v2
40+
41+
- run: cargo check
42+
43+
check-lib:
44+
name: Check (lib)
45+
runs-on: ubuntu-22.04
46+
47+
steps:
48+
- name: Install dependencies
49+
run: sudo apt-get install musl-tools libudev-dev
50+
51+
- uses: actions/checkout@v3
52+
- uses: dtolnay/rust-toolchain@stable
53+
- uses: Swatinem/rust-cache@v2
54+
55+
- run: cargo check --lib --no-default-features
56+
57+
msrv:
58+
name: Check MSRV
59+
runs-on: ubuntu-22.04
60+
61+
steps:
62+
- name: Install dependencies
63+
run: sudo apt-get install musl-tools libudev-dev
64+
65+
- uses: actions/checkout@v3
66+
- uses: dtolnay/rust-toolchain@v1
67+
with:
68+
toolchain: "1.65"
69+
- uses: Swatinem/rust-cache@v2
70+
71+
- run: cargo check
72+
73+
# --------------------------------------------------------------------------
74+
# Test
75+
76+
test:
77+
name: Unit Tests
78+
runs-on: ubuntu-22.04
79+
80+
steps:
81+
- name: Install dependencies
82+
run: sudo apt-get install musl-tools libudev-dev
83+
84+
- uses: actions/checkout@v3
85+
- uses: dtolnay/rust-toolchain@stable
86+
- uses: Swatinem/rust-cache@v2
87+
88+
- run: cargo test --lib
89+
90+
# --------------------------------------------------------------------------
91+
# Lint
92+
93+
clippy:
94+
name: Clippy
95+
runs-on: ubuntu-22.04
96+
97+
steps:
98+
- name: Install dependencies
99+
run: sudo apt-get install musl-tools libudev-dev
100+
101+
- uses: actions/checkout@v3
102+
- uses: dtolnay/rust-toolchain@stable
103+
with:
104+
components: clippy
105+
- uses: Swatinem/rust-cache@v2
106+
107+
- run: cargo clippy -- -D warnings -A clippy::too_many_arguments
108+
109+
rustfmt:
110+
name: Rustfmt
111+
runs-on: ubuntu-22.04
112+
113+
steps:
114+
- uses: actions/checkout@v3
115+
- uses: dtolnay/rust-toolchain@stable
116+
with:
117+
components: rustfmt
118+
- uses: Swatinem/rust-cache@v2
119+
120+
- run: cargo fmt --all -- --check

.github/workflows/raspberry_ci.yml

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: Raspberry Pi CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
workflow_dispatch:
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
13+
# Cancel any currently running workflows from the same PR, branch, or
14+
# tag when a new workflow is triggered.
15+
#
16+
# https://stackoverflow.com/a/66336834
17+
concurrency:
18+
cancel-in-progress: true
19+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
20+
21+
jobs:
22+
# --------------------------------------------------------------------------
23+
# Check
24+
25+
check:
26+
name: Check
27+
runs-on: ubuntu-22.04
28+
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
board:
33+
- arch: arm64
34+
target: aarch64-unknown-linux-gnu
35+
- arch: armhf
36+
target: armv7-unknown-linux-gnueabihf
37+
38+
steps:
39+
- uses: actions/checkout@v3
40+
- uses: ./.github/actions/setup-arm
41+
with:
42+
arch: ${{ matrix.board.arch }}
43+
target: ${{ matrix.board.target }}
44+
45+
- run: cargo check --features=raspberry
46+
47+
check-lib:
48+
name: Check (lib)
49+
runs-on: ubuntu-22.04
50+
51+
strategy:
52+
fail-fast: false
53+
matrix:
54+
board:
55+
- arch: arm64
56+
target: aarch64-unknown-linux-gnu
57+
- arch: armhf
58+
target: armv7-unknown-linux-gnueabihf
59+
60+
steps:
61+
- uses: actions/checkout@v3
62+
- uses: ./.github/actions/setup-arm
63+
with:
64+
arch: ${{ matrix.board.arch }}
65+
target: ${{ matrix.board.target }}
66+
67+
- run: cargo check --lib --no-default-features --features=raspberry
68+
69+
msrv:
70+
name: Check MSRV
71+
runs-on: ubuntu-22.04
72+
73+
strategy:
74+
fail-fast: false
75+
matrix:
76+
board:
77+
- arch: arm64
78+
target: aarch64-unknown-linux-gnu
79+
- arch: armhf
80+
target: armv7-unknown-linux-gnueabihf
81+
82+
steps:
83+
- uses: actions/checkout@v3
84+
- uses: ./.github/actions/setup-arm
85+
with:
86+
arch: ${{ matrix.board.arch }}
87+
target: ${{ matrix.board.target }}
88+
toolchain: "1.65"
89+
90+
- run: cargo check --features=raspberry
91+
92+
# --------------------------------------------------------------------------
93+
# Test
94+
95+
test:
96+
name: Unit Tests
97+
runs-on: ubuntu-22.04
98+
99+
strategy:
100+
fail-fast: false
101+
matrix:
102+
board:
103+
- arch: arm64
104+
target: aarch64-unknown-linux-gnu
105+
- arch: armhf
106+
target: armv7-unknown-linux-gnueabihf
107+
108+
steps:
109+
- uses: actions/checkout@v3
110+
- uses: ./.github/actions/setup-arm
111+
with:
112+
arch: ${{ matrix.board.arch }}
113+
target: ${{ matrix.board.target }}
114+
115+
- run: cargo test --lib --features=raspberry
116+
117+
# --------------------------------------------------------------------------
118+
# Lint
119+
120+
clippy:
121+
name: Clippy
122+
runs-on: ubuntu-22.04
123+
124+
strategy:
125+
fail-fast: false
126+
matrix:
127+
board:
128+
- arch: arm64
129+
target: aarch64-unknown-linux-gnu
130+
- arch: armhf
131+
target: armv7-unknown-linux-gnueabihf
132+
133+
steps:
134+
- uses: actions/checkout@v3
135+
- uses: ./.github/actions/setup-arm
136+
with:
137+
arch: ${{ matrix.board.arch }}
138+
target: ${{ matrix.board.target }}
139+
components: clippy
140+
141+
- run: cargo clippy --features=raspberry -- -D warnings -A clippy::too_many_arguments

0 commit comments

Comments
 (0)