Skip to content

Commit

Permalink
Update the CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jessebraham committed Jun 1, 2023
1 parent 092a637 commit a102801
Show file tree
Hide file tree
Showing 6 changed files with 332 additions and 196 deletions.
70 changes: 70 additions & 0 deletions .github/actions/setup-arm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Setup ARM Build Environment
description: Setup an ARM build environment

inputs:
arch:
required: true
target:
required: true
toolchain:
default: stable
required: false
components:
required: false

runs:
using: composite
steps:
- name: Replace target string
uses: mad9000/actions-find-and-replace-string@3
id: findandreplace
with:
source: ${{ inputs.target }}
find: "unknown-"
replace: ""

- name: Install toolchain
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ inputs.toolchain }}
target: ${{ inputs.target }}
components: ${{ inputs.components }}

- uses: Swatinem/rust-cache@v2

- name: Install Cross-Compile Support
uses: cyberjunk/gha-ubuntu-cross@v3
with:
arch: ${{ inputs.arch }}

- name: Install dependencies
shell: bash
run: |
sudo apt install -y \
curl \
gcc-aarch64-linux-gnu \
gcc-arm-linux-gnueabihf \
git \
"libc6:${{ inputs.arch }}" \
"libgcc-s1:${{ inputs.arch }}" \
libudev-dev \
"libudev-dev:${{ inputs.arch }}" \
"libudev1:${{ inputs.arch }}" \
musl-tools \
pkg-config
- name: Set environment variables
shell: bash
run: |
echo "PKG_CONFIG_ALLOW_SYSTEM_LIBS=0" >> $GITHUB_ENV
echo "PKG_CONFIG_DIR=/opt/" >> $GITHUB_ENV
echo "PKG_CONFIG_LIBDIR=/opt/usr/lib/pkgconfig:/opt/usr/share/pkgconfig" >> $GITHUB_ENV
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
if [[ ${{ inputs.arch }} == arm64 ]]; then
echo "PKG_CONFIG_PATH=/usr/lib/${{ steps.findandreplace.outputs.value }}/pkgconfig" >> $GITHUB_ENV
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=${{ steps.findandreplace.outputs.value }}-gcc" >> $GITHUB_ENV
fi
if [[ ${{ inputs.arch }} == armhf ]]; then
echo "PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig" >> $GITHUB_ENV
echo "CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
fi
120 changes: 120 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: CI

on:
pull_request:
branches:
- main
push:
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

# Cancel any currently running workflows from the same PR, branch, or
# tag when a new workflow is triggered.
#
# https://stackoverflow.com/a/66336834
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}

jobs:
# --------------------------------------------------------------------------
# Check

check:
name: Check
strategy:
matrix:
os: ["macos-12", "ubuntu-22.04", "windows-2022"]
runs-on: ${{ matrix.os }}

steps:
- name: Install dependencies
if: matrix.os == 'ubuntu-22.04'
run: sudo apt-get install musl-tools libudev-dev

- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2

- run: cargo check

check-lib:
name: Check (lib)
runs-on: ubuntu-22.04

steps:
- name: Install dependencies
run: sudo apt-get install musl-tools libudev-dev

- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2

- run: cargo check --lib --no-default-features

msrv:
name: Check MSRV
runs-on: ubuntu-22.04

steps:
- name: Install dependencies
run: sudo apt-get install musl-tools libudev-dev

- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: "1.65"
- uses: Swatinem/rust-cache@v2

- run: cargo check

# --------------------------------------------------------------------------
# Test

test:
name: Unit Tests
runs-on: ubuntu-22.04

steps:
- name: Install dependencies
run: sudo apt-get install musl-tools libudev-dev

- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2

- run: cargo test --lib

# --------------------------------------------------------------------------
# Lint

clippy:
name: Clippy
runs-on: ubuntu-22.04

steps:
- name: Install dependencies
run: sudo apt-get install musl-tools libudev-dev

- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2

- run: cargo clippy -- -D warnings -A clippy::too_many_arguments

rustfmt:
name: Rustfmt
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- uses: Swatinem/rust-cache@v2

- run: cargo fmt --all -- --check
141 changes: 141 additions & 0 deletions .github/workflows/raspberry_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Raspberry Pi CI

on:
pull_request:
branches:
- main
push:
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

# Cancel any currently running workflows from the same PR, branch, or
# tag when a new workflow is triggered.
#
# https://stackoverflow.com/a/66336834
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}

jobs:
# --------------------------------------------------------------------------
# Check

check:
name: Check
runs-on: ubuntu-22.04

strategy:
fail-fast: false
matrix:
board:
- arch: arm64
target: aarch64-unknown-linux-gnu
- arch: armhf
target: armv7-unknown-linux-gnueabihf

steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-arm
with:
arch: ${{ matrix.board.arch }}
target: ${{ matrix.board.target }}

- run: cargo check --features=raspberry

check-lib:
name: Check (lib)
runs-on: ubuntu-22.04

strategy:
fail-fast: false
matrix:
board:
- arch: arm64
target: aarch64-unknown-linux-gnu
- arch: armhf
target: armv7-unknown-linux-gnueabihf

steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-arm
with:
arch: ${{ matrix.board.arch }}
target: ${{ matrix.board.target }}

- run: cargo check --lib --no-default-features --features=raspberry

msrv:
name: Check MSRV
runs-on: ubuntu-22.04

strategy:
fail-fast: false
matrix:
board:
- arch: arm64
target: aarch64-unknown-linux-gnu
- arch: armhf
target: armv7-unknown-linux-gnueabihf

steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-arm
with:
arch: ${{ matrix.board.arch }}
target: ${{ matrix.board.target }}
toolchain: "1.65"

- run: cargo check --features=raspberry

# --------------------------------------------------------------------------
# Test

test:
name: Unit Tests
runs-on: ubuntu-22.04

strategy:
fail-fast: false
matrix:
board:
- arch: arm64
target: aarch64-unknown-linux-gnu
- arch: armhf
target: armv7-unknown-linux-gnueabihf

steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-arm
with:
arch: ${{ matrix.board.arch }}
target: ${{ matrix.board.target }}

- run: cargo test --lib --features=raspberry

# --------------------------------------------------------------------------
# Lint

clippy:
name: Clippy
runs-on: ubuntu-22.04

strategy:
fail-fast: false
matrix:
board:
- arch: arm64
target: aarch64-unknown-linux-gnu
- arch: armhf
target: armv7-unknown-linux-gnueabihf

steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-arm
with:
arch: ${{ matrix.board.arch }}
target: ${{ matrix.board.target }}
components: clippy

- run: cargo clippy --features=raspberry -- -D warnings -A clippy::too_many_arguments
Loading

0 comments on commit a102801

Please sign in to comment.